| 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" |
| 10 #include "components/dom_distiller/content/common/distillability_service.mojom.h
" |
| 9 #include "content/public/browser/web_contents_observer.h" | 11 #include "content/public/browser/web_contents_observer.h" |
| 10 #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" |
| 11 | 14 |
| 12 namespace dom_distiller { | 15 namespace dom_distiller { |
| 13 | 16 |
| 14 // 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. |
| 15 class DistillabilityDriver | 18 class DistillabilityDriver |
| 16 : public content::WebContentsObserver, | 19 : public content::WebContentsObserver, |
| 17 public content::WebContentsUserData<DistillabilityDriver> { | 20 public content::WebContentsUserData<DistillabilityDriver> { |
| 18 public: | 21 public: |
| 19 ~DistillabilityDriver() override; | 22 ~DistillabilityDriver() override; |
| 23 void CreateDistillabilityService( |
| 24 mojo::InterfaceRequest<DistillabilityService> request); |
| 20 | 25 |
| 21 void SetDelegate(const base::Callback<void(bool, bool)>& delegate); | 26 void SetDelegate(const base::Callback<void(bool, bool)>& delegate); |
| 22 | 27 |
| 23 // content::WebContentsObserver implementation. | 28 // content::WebContentsObserver implementation. |
| 24 bool OnMessageReceived(const IPC::Message& message, | |
| 25 content::RenderFrameHost* rfh) override; | |
| 26 void RenderProcessGone(base::TerminationStatus status) override; | 29 void RenderProcessGone(base::TerminationStatus status) override; |
| 27 | 30 |
| 28 private: | 31 private: |
| 29 explicit DistillabilityDriver(content::WebContents* web_contents); | 32 explicit DistillabilityDriver(content::WebContents* web_contents); |
| 30 friend class content::WebContentsUserData<DistillabilityDriver>; | 33 friend class content::WebContentsUserData<DistillabilityDriver>; |
| 34 friend class DistillabilityServiceImpl; |
| 31 | 35 |
| 32 void OnDistillability(bool distillable, bool is_last); | 36 void OnDistillability(bool distillable, bool is_last); |
| 33 | 37 |
| 34 // Removes the observer and clears the WebContents member. | 38 // Removes the observer, clears the WebContents member, and removed mojo |
| 39 // service from registry. |
| 35 void CleanUp(); | 40 void CleanUp(); |
| 36 | 41 |
| 37 base::Callback<void(bool, bool)> m_delegate_; | 42 base::Callback<void(bool, bool)> m_delegate_; |
| 38 | 43 |
| 44 base::WeakPtrFactory<DistillabilityDriver> weak_factory_; |
| 45 |
| 39 DISALLOW_COPY_AND_ASSIGN(DistillabilityDriver); | 46 DISALLOW_COPY_AND_ASSIGN(DistillabilityDriver); |
| 40 }; | 47 }; |
| 41 | 48 |
| 42 } // namespace dom_distiller | 49 } // namespace dom_distiller |
| 43 | 50 |
| 44 #endif // COMPONENTS_DOM_DISTILLER_CONTENT_BROWSER_DISTILLIBILITY_DRIVER_H_ | 51 #endif // COMPONENTS_DOM_DISTILLER_CONTENT_BROWSER_DISTILLIBILITY_DRIVER_H_ |
| OLD | NEW |