#include "weblayer/test/load_completion_observer.h"
#include "weblayer/public/navigation_controller.h"
#include "weblayer/public/tab.h"
#include "weblayer/shell/browser/shell.h"
namespace weblayer {
LoadCompletionObserver::LoadCompletionObserver(Shell* shell)
: tab_(shell->tab()) {
tab_->GetNavigationController()->AddObserver(this);
}
LoadCompletionObserver::~LoadCompletionObserver() {
tab_->GetNavigationController()->RemoveObserver(this);
}
void LoadCompletionObserver::LoadStateChanged(bool is_loading,
bool should_show_loading_ui) {
if (!is_loading)
run_loop_.Quit();
}
void LoadCompletionObserver::Wait() {
run_loop_.Run();
}
}