| 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 #ifndef COMPONENTS_DOM_DISTILLER_CONTENT_BROWSER_DISTILLIBILITY_DRIVER_H_ | 5 #ifndef COMPONENTS_DOM_DISTILLER_CONTENT_BROWSER_DISTILLIBILITY_DRIVER_H_ |
| 6 #define COMPONENTS_DOM_DISTILLER_CONTENT_BROWSER_DISTILLIBILITY_DRIVER_H_ | 6 #define COMPONENTS_DOM_DISTILLER_CONTENT_BROWSER_DISTILLIBILITY_DRIVER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "components/dom_distiller/content/common/distillability_service.mojom.h
" | 10 #include "components/dom_distiller/content/common/distillability_service.mojom.h
" |
| 11 #include "content/public/browser/web_contents_observer.h" | 11 #include "content/public/browser/web_contents_observer.h" |
| 12 #include "content/public/browser/web_contents_user_data.h" | 12 #include "content/public/browser/web_contents_user_data.h" |
| 13 #include "mojo/public/cpp/bindings/strong_binding.h" | 13 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 14 | 14 |
| 15 namespace dom_distiller { | 15 namespace dom_distiller { |
| 16 | 16 |
| 17 // This is an IPC helper for determining whether a page should be distilled. | 17 // This is an IPC helper for determining whether a page should be distilled. |
| 18 class DistillabilityDriver | 18 class DistillabilityDriver |
| 19 : public content::WebContentsObserver, | 19 : public content::WebContentsObserver, |
| 20 public content::WebContentsUserData<DistillabilityDriver> { | 20 public content::WebContentsUserData<DistillabilityDriver> { |
| 21 public: | 21 public: |
| 22 ~DistillabilityDriver() override; | 22 ~DistillabilityDriver() override; |
| 23 void CreateDistillabilityService( | 23 void CreateDistillabilityService( |
| 24 mojo::InterfaceRequest<mojom::DistillabilityService> request); | 24 mojo::InterfaceRequest<mojom::DistillabilityService> request); |
| 25 | 25 |
| 26 void SetDelegate(const base::Callback<void(bool, bool)>& delegate); | 26 void SetDelegate(const base::Callback<void(bool, bool)>& delegate); |
| 27 | 27 |
| 28 // content::WebContentsObserver implementation. | 28 // content::WebContentsObserver implementation. |
| 29 void DidStartProvisionalLoadForFrame( | 29 void ReadyToCommitNavigation( |
| 30 content::RenderFrameHost* render_frame_host, | 30 content::NavigationHandle* navigation_handle) override; |
| 31 const GURL& validated_url, | |
| 32 bool is_error_page) override; | |
| 33 void RenderFrameHostChanged( | 31 void RenderFrameHostChanged( |
| 34 content::RenderFrameHost* old_host, | 32 content::RenderFrameHost* old_host, |
| 35 content::RenderFrameHost* new_host) override; | 33 content::RenderFrameHost* new_host) override; |
| 36 | 34 |
| 37 private: | 35 private: |
| 38 explicit DistillabilityDriver(content::WebContents* web_contents); | 36 explicit DistillabilityDriver(content::WebContents* web_contents); |
| 39 friend class content::WebContentsUserData<DistillabilityDriver>; | 37 friend class content::WebContentsUserData<DistillabilityDriver>; |
| 40 friend class DistillabilityServiceImpl; | 38 friend class DistillabilityServiceImpl; |
| 41 | 39 |
| 42 void SetupMojoService(content::RenderFrameHost* frame_host); | 40 void SetupMojoService(content::RenderFrameHost* frame_host); |
| 43 void OnDistillability(bool distillable, bool is_last); | 41 void OnDistillability(bool distillable, bool is_last); |
| 44 | 42 |
| 45 void SetNeedsMojoSetup(); | 43 void SetNeedsMojoSetup(); |
| 46 | 44 |
| 47 base::Callback<void(bool, bool)> m_delegate_; | 45 base::Callback<void(bool, bool)> m_delegate_; |
| 48 | 46 |
| 49 bool mojo_needs_setup_; | 47 bool mojo_needs_setup_; |
| 50 | 48 |
| 51 base::WeakPtrFactory<DistillabilityDriver> weak_factory_; | 49 base::WeakPtrFactory<DistillabilityDriver> weak_factory_; |
| 52 | 50 |
| 53 DISALLOW_COPY_AND_ASSIGN(DistillabilityDriver); | 51 DISALLOW_COPY_AND_ASSIGN(DistillabilityDriver); |
| 54 }; | 52 }; |
| 55 | 53 |
| 56 } // namespace dom_distiller | 54 } // namespace dom_distiller |
| 57 | 55 |
| 58 #endif // COMPONENTS_DOM_DISTILLER_CONTENT_BROWSER_DISTILLIBILITY_DRIVER_H_ | 56 #endif // COMPONENTS_DOM_DISTILLER_CONTENT_BROWSER_DISTILLIBILITY_DRIVER_H_ |
| OLD | NEW |