Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1440)

Unified Diff: components/dom_distiller/content/browser/distillability_driver.cc

Issue 1883023004: Reader Mode triggers after tab crash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@distillability-mojo
Patch Set: different lifecycle Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/dom_distiller/content/browser/distillability_driver.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/dom_distiller/content/browser/distillability_driver.cc
diff --git a/components/dom_distiller/content/browser/distillability_driver.cc b/components/dom_distiller/content/browser/distillability_driver.cc
index 0a2c739d1179454f55c5455de86d6964556501ed..3feb13bbad2c08a908e558e307d19472e74c6ddd 100644
--- a/components/dom_distiller/content/browser/distillability_driver.cc
+++ b/components/dom_distiller/content/browser/distillability_driver.cc
@@ -40,14 +40,11 @@ DistillabilityDriver::DistillabilityDriver(
content::WebContents* web_contents)
: content::WebContentsObserver(web_contents),
weak_factory_(this) {
- if (!web_contents) return;
- web_contents->GetMainFrame()->GetServiceRegistry()->AddService(
- base::Bind(&DistillabilityDriver::CreateDistillabilityService,
- weak_factory_.GetWeakPtr()));
+ SetupMojoService();
}
DistillabilityDriver::~DistillabilityDriver() {
- CleanUp();
+ content::WebContentsObserver::Observe(nullptr);
}
void DistillabilityDriver::CreateDistillabilityService(
@@ -65,18 +62,24 @@ void DistillabilityDriver::OnDistillability(
if (m_delegate_.is_null()) return;
m_delegate_.Run(distillable, is_last);
+
+ if (web_contents() && is_last) {
+ web_contents()->GetMainFrame()->GetServiceRegistry()
+ ->RemoveService<DistillabilityService>();
+ }
}
-void DistillabilityDriver::RenderProcessGone(
- base::TerminationStatus status) {
- CleanUp();
+void DistillabilityDriver::DidStartProvisionalLoadForFrame(
+ content::RenderFrameHost* render_frame_host, const GURL& validated_url,
+ bool is_error_page, bool is_iframe_srcdoc) {
+ SetupMojoService();
}
-void DistillabilityDriver::CleanUp() {
+void DistillabilityDriver::SetupMojoService() {
if (!web_contents()) return;
- web_contents()->GetMainFrame()->GetServiceRegistry()
- ->RemoveService<DistillabilityService>();
- content::WebContentsObserver::Observe(NULL);
+ web_contents()->GetMainFrame()->GetServiceRegistry()->AddService(
+ base::Bind(&DistillabilityDriver::CreateDistillabilityService,
+ weak_factory_.GetWeakPtr()));
}
} // namespace dom_distiller
« no previous file with comments | « components/dom_distiller/content/browser/distillability_driver.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698