| 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" |
| 11 #include "content/public/common/service_registry.h" | 11 #include "services/shell/public/cpp/interface_registry.h" |
| 12 | 12 |
| 13 DEFINE_WEB_CONTENTS_USER_DATA_KEY( | 13 DEFINE_WEB_CONTENTS_USER_DATA_KEY( |
| 14 dom_distiller::DistillabilityDriver); | 14 dom_distiller::DistillabilityDriver); |
| 15 | 15 |
| 16 namespace dom_distiller { | 16 namespace dom_distiller { |
| 17 | 17 |
| 18 // Implementation of the Mojo DistillabilityService. This is called by the | 18 // Implementation of the Mojo DistillabilityService. This is called by the |
| 19 // renderer to notify the browser that a page is distillable. | 19 // renderer to notify the browser that a page is distillable. |
| 20 class DistillabilityServiceImpl : public mojom::DistillabilityService { | 20 class DistillabilityServiceImpl : public mojom::DistillabilityService { |
| 21 public: | 21 public: |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 void DistillabilityDriver::DidStartProvisionalLoadForFrame( | 68 void DistillabilityDriver::DidStartProvisionalLoadForFrame( |
| 69 content::RenderFrameHost* render_frame_host, const GURL& validated_url, | 69 content::RenderFrameHost* render_frame_host, const GURL& validated_url, |
| 70 bool is_error_page, bool is_iframe_srcdoc) { | 70 bool is_error_page, bool is_iframe_srcdoc) { |
| 71 SetupMojoService(); | 71 SetupMojoService(); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void DistillabilityDriver::SetupMojoService() { | 74 void DistillabilityDriver::SetupMojoService() { |
| 75 if (!web_contents()) return; | 75 if (!web_contents()) return; |
| 76 | 76 |
| 77 content::RenderFrameHost* frame_host = web_contents()->GetMainFrame(); | 77 content::RenderFrameHost* frame_host = web_contents()->GetMainFrame(); |
| 78 if (!frame_host || !frame_host->GetServiceRegistry()) return; | 78 if (!frame_host || !frame_host->GetInterfaceRegistry()) return; |
| 79 | 79 |
| 80 frame_host->GetServiceRegistry()->AddService( | 80 frame_host->GetInterfaceRegistry()->AddInterface( |
| 81 base::Bind(&DistillabilityDriver::CreateDistillabilityService, | 81 base::Bind(&DistillabilityDriver::CreateDistillabilityService, |
| 82 weak_factory_.GetWeakPtr())); | 82 weak_factory_.GetWeakPtr())); |
| 83 } | 83 } |
| 84 | 84 |
| 85 } // namespace dom_distiller | 85 } // namespace dom_distiller |
| OLD | NEW |