#ifndef CHROME_BROWSER_DOM_DISTILLER_TEST_DISTILLATION_OBSERVERS_H_
#define CHROME_BROWSER_DOM_DISTILLER_TEST_DISTILLATION_OBSERVERS_H_
#include "base/run_loop.h"
#include "content/public/browser/web_contents_observer.h"
namespace dom_distiller {
class NavigationObserver : public content::WebContentsObserver {
public:
explicit NavigationObserver(content::WebContents* observed_contents) {
content::WebContentsObserver::Observe(observed_contents);
}
void WaitUntilFinishedLoading() { new_url_loaded_runner_.Run(); }
protected:
void Stop() { new_url_loaded_runner_.Quit(); }
private:
base::RunLoop new_url_loaded_runner_;
};
class OriginalPageNavigationObserver : public NavigationObserver {
public:
using NavigationObserver::NavigationObserver;
private:
void DidFinishLoad(content::RenderFrameHost* render_frame_host,
const GURL& validated_url) override;
};
class DistilledPageObserver : public NavigationObserver {
public:
using NavigationObserver::NavigationObserver;
private:
void DidFinishLoad(content::RenderFrameHost* render_frame_host,
const GURL& validated_url) override;
void TitleWasSet(content::NavigationEntry* entry) override;
void MaybeNotifyLoaded();
int title_set_count_ = 0;
bool loaded_distiller_page_ = false;
};
}
#endif