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 "content/public/browser/render_frame_host.h" | 7 #include "content/public/browser/render_frame_host.h" |
8 #include "content/public/browser/web_contents.h" | 8 #include "content/public/browser/web_contents.h" |
9 #include "content/public/browser/web_contents_observer.h" | 9 #include "content/public/browser/web_contents_observer.h" |
10 #include "content/public/browser/web_contents_user_data.h" | 10 #include "content/public/browser/web_contents_user_data.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 if (!web_contents() || web_contents()->GetMainFrame() != new_host) return; | 82 if (!web_contents() || web_contents()->GetMainFrame() != new_host) return; |
83 | 83 |
84 // If the RenderFrameHost changes (this will happen if the user navigates to | 84 // If the RenderFrameHost changes (this will happen if the user navigates to |
85 // or from a native page), the service needs to be attached to that host. | 85 // or from a native page), the service needs to be attached to that host. |
86 mojo_needs_setup_ = true; | 86 mojo_needs_setup_ = true; |
87 SetupMojoService(new_host); | 87 SetupMojoService(new_host); |
88 } | 88 } |
89 | 89 |
90 void DistillabilityDriver::DidStartProvisionalLoadForFrame( | 90 void DistillabilityDriver::DidStartProvisionalLoadForFrame( |
91 content::RenderFrameHost* render_frame_host, const GURL& validated_url, | 91 content::RenderFrameHost* render_frame_host, const GURL& validated_url, |
92 bool is_error_page, bool is_iframe_srcdoc) { | 92 bool is_error_page) { |
93 SetupMojoService(render_frame_host); | 93 SetupMojoService(render_frame_host); |
94 } | 94 } |
95 | 95 |
96 void DistillabilityDriver::SetupMojoService( | 96 void DistillabilityDriver::SetupMojoService( |
97 content::RenderFrameHost* frame_host) { | 97 content::RenderFrameHost* frame_host) { |
98 if (!frame_host || !frame_host->GetInterfaceRegistry() | 98 if (!frame_host || !frame_host->GetInterfaceRegistry() |
99 || !mojo_needs_setup_) { | 99 || !mojo_needs_setup_) { |
100 return; | 100 return; |
101 } | 101 } |
102 | 102 |
103 frame_host->GetInterfaceRegistry()->AddInterface( | 103 frame_host->GetInterfaceRegistry()->AddInterface( |
104 base::Bind(&DistillabilityDriver::CreateDistillabilityService, | 104 base::Bind(&DistillabilityDriver::CreateDistillabilityService, |
105 weak_factory_.GetWeakPtr())); | 105 weak_factory_.GetWeakPtr())); |
106 mojo_needs_setup_ = false; | 106 mojo_needs_setup_ = false; |
107 } | 107 } |
108 | 108 |
109 } // namespace dom_distiller | 109 } // namespace dom_distiller |
OLD | NEW |