Index: components/dom_distiller/content/browser/distillability_driver.h |
diff --git a/components/dom_distiller/content/browser/distillability_driver.h b/components/dom_distiller/content/browser/distillability_driver.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f65a7ae4ea0f66691daaf06ddcec2e8f2a5a005c |
--- /dev/null |
+++ b/components/dom_distiller/content/browser/distillability_driver.h |
@@ -0,0 +1,44 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef COMPONENTS_DOM_DISTILLER_CONTENT_BROWSER_DISTILLIBILITY_DRIVER_H_ |
+#define COMPONENTS_DOM_DISTILLER_CONTENT_BROWSER_DISTILLIBILITY_DRIVER_H_ |
+ |
+#include "base/macros.h" |
+#include "content/public/browser/web_contents_observer.h" |
+#include "content/public/browser/web_contents_user_data.h" |
+ |
+namespace dom_distiller { |
+ |
+// This is an IPC helper for determining whether a page should be distilled. |
+class WebContentsDistillabilityDriver |
blundell
2015/11/05 09:42:41
drive-by nit: this should be named web_contents_do
wychen
2015/11/12 04:59:45
Changed the class name.
|
+ : public content::WebContentsObserver, |
+ public content::WebContentsUserData<WebContentsDistillabilityDriver> { |
+ public: |
+ ~WebContentsDistillabilityDriver() override; |
+ |
+ void SetDelegate(const base::Callback<void(bool, bool)>& delegate); |
+ |
+ // content::WebContentsObserver implementation. |
+ bool OnMessageReceived(const IPC::Message& message, |
+ content::RenderFrameHost* rfh) override; |
+ void RenderProcessGone(base::TerminationStatus status) override; |
+ |
+ private: |
+ explicit WebContentsDistillabilityDriver(content::WebContents* web_contents); |
+ friend class content::WebContentsUserData<WebContentsDistillabilityDriver>; |
+ |
+ void OnDistillability(bool distillable, bool is_last); |
+ |
+ // Removes the observer and clears the WebContents member. |
+ void CleanUp(); |
+ |
+ base::Callback<void(bool, bool)> m_delegate_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(WebContentsDistillabilityDriver); |
+}; |
+ |
+} // namespace dom_distiller |
+ |
+#endif // COMPONENTS_DOM_DISTILLER_CONTENT_BROWSER_DISTILLIBILITY_DRIVER_H_ |