Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(225)

Unified Diff: components/dom_distiller/content/browser/distillability_driver.h

Issue 1248643004: Test distillability without JavaScript (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@early
Patch Set: move tests, remove dbg msg Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..5fe2d59d3e2a58f60efb57e8cdfe0f8da89b0e84
--- /dev/null
+++ b/components/dom_distiller/content/browser/distillability_driver.h
@@ -0,0 +1,58 @@
+// 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 "content/public/browser/web_contents_observer.h"
+#include "content/public/browser/web_contents_user_data.h"
+
+struct FrameHostMsg_ExtractFeatureResponse_Params;
+
+namespace dom_distiller {
+
+// Extract the features of a page for DOM distiller.
+typedef base::Callback<void(bool isOGArticle,
+ const std::string& url,
+ int numElements,
+ int numAnchors,
+ int numForms,
+ const std::string& innerText,
+ const std::string& textContent,
+ const std::string& innerHTML)>
+ ExtractFeatureCallback;
+
+// This is an IPC helper for determining whether a page should be distilled.
+class WebContentsDistillabilityDriver
+ : public content::WebContentsObserver,
+ public content::WebContentsUserData<WebContentsDistillabilityDriver> {
+ public:
+ ~WebContentsDistillabilityDriver() override;
+
+ // content::WebContentsObserver implementation.
+ bool OnMessageReceived(const IPC::Message& message,
+ content::RenderFrameHost* rfh) override;
+ void RenderProcessGone(base::TerminationStatus status) override;
+
+ void OnExtractFeatureResponse(int id,
+ FrameHostMsg_ExtractFeatureResponse_Params results);
+
+ void ExtractFeatures(const ExtractFeatureCallback& callback);
+
+ private:
+ explicit WebContentsDistillabilityDriver(content::WebContents* web_contents);
+ friend class content::WebContentsUserData<WebContentsDistillabilityDriver>;
+
+ // Removes the observer and clears the WebContents member.
+ void CleanUp();
+
+ int callback_id_;
+ std::map<int, ExtractFeatureCallback> callbacks_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebContentsDistillabilityDriver);
+};
+
+} // namespace dom_distiller
+
+#endif // COMPONENTS_DOM_DISTILLER_CONTENT_BROWSER_DISTILLIBILITY_DRIVER_H_

Powered by Google App Engine
This is Rietveld 408576698