| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/dom_distiller/content/browser/distillability_driver.h" | 5 #include "components/dom_distiller/content/browser/distillability_driver.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "content/public/browser/navigation_handle.h" | 8 #include "content/public/browser/navigation_handle.h" |
| 9 #include "content/public/browser/render_frame_host.h" | 9 #include "content/public/browser/render_frame_host.h" |
| 10 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 if (!web_contents() || web_contents()->GetMainFrame() != new_host) return; | 84 if (!web_contents() || web_contents()->GetMainFrame() != new_host) return; |
| 85 | 85 |
| 86 // If the RenderFrameHost changes (this will happen if the user navigates to | 86 // If the RenderFrameHost changes (this will happen if the user navigates to |
| 87 // or from a native page), the service needs to be attached to that host. | 87 // or from a native page), the service needs to be attached to that host. |
| 88 mojo_needs_setup_ = true; | 88 mojo_needs_setup_ = true; |
| 89 SetupMojoService(new_host); | 89 SetupMojoService(new_host); |
| 90 } | 90 } |
| 91 | 91 |
| 92 void DistillabilityDriver::ReadyToCommitNavigation( | 92 void DistillabilityDriver::ReadyToCommitNavigation( |
| 93 content::NavigationHandle* navigation_handle) { | 93 content::NavigationHandle* navigation_handle) { |
| 94 if (!navigation_handle->IsSamePage()) | 94 if (!navigation_handle->IsSameDocument()) |
| 95 SetupMojoService(navigation_handle->GetRenderFrameHost()); | 95 SetupMojoService(navigation_handle->GetRenderFrameHost()); |
| 96 } | 96 } |
| 97 | 97 |
| 98 void DistillabilityDriver::SetupMojoService( | 98 void DistillabilityDriver::SetupMojoService( |
| 99 content::RenderFrameHost* frame_host) { | 99 content::RenderFrameHost* frame_host) { |
| 100 if (!frame_host || !frame_host->GetInterfaceRegistry() | 100 if (!frame_host || !frame_host->GetInterfaceRegistry() |
| 101 || !mojo_needs_setup_) { | 101 || !mojo_needs_setup_) { |
| 102 return; | 102 return; |
| 103 } | 103 } |
| 104 | 104 |
| 105 frame_host->GetInterfaceRegistry()->AddInterface( | 105 frame_host->GetInterfaceRegistry()->AddInterface( |
| 106 base::Bind(&DistillabilityDriver::CreateDistillabilityService, | 106 base::Bind(&DistillabilityDriver::CreateDistillabilityService, |
| 107 weak_factory_.GetWeakPtr())); | 107 weak_factory_.GetWeakPtr())); |
| 108 mojo_needs_setup_ = false; | 108 mojo_needs_setup_ = false; |
| 109 } | 109 } |
| 110 | 110 |
| 111 } // namespace dom_distiller | 111 } // namespace dom_distiller |
| OLD | NEW |