OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef COMPONENTS_DOM_DISTILLER_CONTENT_BROWSER_DISTILLIBILITY_DRIVER_H_ |
| 6 #define COMPONENTS_DOM_DISTILLER_CONTENT_BROWSER_DISTILLIBILITY_DRIVER_H_ |
| 7 |
| 8 #include "content/public/browser/web_contents_observer.h" |
| 9 #include "content/public/browser/web_contents_user_data.h" |
| 10 |
| 11 namespace dom_distiller { |
| 12 |
| 13 // This is an IPC helper for determining whether a page should be distilled. |
| 14 class WebContentsDistillabilityDriver |
| 15 : public content::WebContentsObserver, |
| 16 public content::WebContentsUserData<WebContentsDistillabilityDriver> { |
| 17 public: |
| 18 ~WebContentsDistillabilityDriver() override; |
| 19 |
| 20 void SetCallback(const base::Callback<void(bool, bool)>& callback); |
| 21 |
| 22 // content::WebContentsObserver implementation. |
| 23 bool OnMessageReceived(const IPC::Message& message, |
| 24 content::RenderFrameHost* rfh) override; |
| 25 void RenderProcessGone(base::TerminationStatus status) override; |
| 26 |
| 27 private: |
| 28 explicit WebContentsDistillabilityDriver(content::WebContents* web_contents); |
| 29 friend class content::WebContentsUserData<WebContentsDistillabilityDriver>; |
| 30 |
| 31 void OnDistillability(bool distillable, bool is_last); |
| 32 |
| 33 // Removes the observer and clears the WebContents member. |
| 34 void CleanUp(); |
| 35 |
| 36 base::Callback<void(bool, bool)> m_callback_; |
| 37 |
| 38 DISALLOW_COPY_AND_ASSIGN(WebContentsDistillabilityDriver); |
| 39 }; |
| 40 |
| 41 } // namespace dom_distiller |
| 42 |
| 43 #endif // COMPONENTS_DOM_DISTILLER_CONTENT_BROWSER_DISTILLIBILITY_DRIVER_H_ |
OLD | NEW |