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..842b98d908af0b0a5e9cec4666c079a3cd949fa5 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() |
| + ->RemoveService<DistillabilityService>(); |
| + content::WebContentsObserver::Observe(NULL); |
|
wychen
2016/04/14 20:41:25
nit: nullptr
It's my fault though.
mdjones
2016/04/15 00:29:45
Done.
|
| } |
| 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 |