Chromium Code Reviews| 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 5154f1eccba6d8e3b634abb7714def94e633ca74..ecff3066d4e8d27bfdfef057a5fc4d213aea0764 100644 |
| --- a/components/dom_distiller/content/browser/distillability_driver.cc |
| +++ b/components/dom_distiller/content/browser/distillability_driver.cc |
| @@ -40,14 +40,13 @@ 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(); |
| + web_contents()->GetMainFrame()->GetServiceRegistry() |
|
wychen
2016/04/15 06:22:21
Would web_cotents() always be nullptr here? If the
mdjones
2016/04/15 21:04:09
Done.
|
| + ->RemoveService<DistillabilityService>(); |
| + content::WebContentsObserver::Observe(nullptr); |
| } |
| void DistillabilityDriver::CreateDistillabilityService( |
| @@ -67,15 +66,17 @@ void DistillabilityDriver::OnDistillability( |
| m_delegate_.Run(distillable, is_last); |
| } |
| -void DistillabilityDriver::RenderProcessGone( |
| - base::TerminationStatus status) { |
| - CleanUp(); |
| +void DistillabilityDriver::DidNavigateMainFrame( |
| + const content::LoadCommittedDetails& details, |
| + const content::FrameNavigateParams& params) { |
| + if (details.is_in_page) return; |
| + SetupMojoService(); |
| } |
| -void DistillabilityDriver::CleanUp() { |
| - web_contents()->GetMainFrame()->GetServiceRegistry() |
| - ->RemoveService<DistillabilityService>(); |
| - content::WebContentsObserver::Observe(NULL); |
| +void DistillabilityDriver::SetupMojoService() { |
| + web_contents()->GetMainFrame()->GetServiceRegistry()->AddService( |
| + base::Bind(&DistillabilityDriver::CreateDistillabilityService, |
| + weak_factory_.GetWeakPtr())); |
| } |
| } // namespace dom_distiller |