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

Side by Side 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, 2 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 unified diff | Download patch
OLDNEW
(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 struct FrameHostMsg_ExtractFeatureResponse_Params;
12
13 namespace dom_distiller {
14
15 // Extract the features of a page for DOM distiller.
16 typedef base::Callback<void(bool isOGArticle,
17 const std::string& url,
18 int numElements,
19 int numAnchors,
20 int numForms,
21 const std::string& innerText,
22 const std::string& textContent,
23 const std::string& innerHTML)>
24 ExtractFeatureCallback;
25
26 // This is an IPC helper for determining whether a page should be distilled.
27 class WebContentsDistillabilityDriver
28 : public content::WebContentsObserver,
29 public content::WebContentsUserData<WebContentsDistillabilityDriver> {
30 public:
31 ~WebContentsDistillabilityDriver() override;
32
33 // content::WebContentsObserver implementation.
34 bool OnMessageReceived(const IPC::Message& message,
35 content::RenderFrameHost* rfh) override;
36 void RenderProcessGone(base::TerminationStatus status) override;
37
38 void OnExtractFeatureResponse(int id,
39 FrameHostMsg_ExtractFeatureResponse_Params results);
40
41 void ExtractFeatures(const ExtractFeatureCallback& callback);
42
43 private:
44 explicit WebContentsDistillabilityDriver(content::WebContents* web_contents);
45 friend class content::WebContentsUserData<WebContentsDistillabilityDriver>;
46
47 // Removes the observer and clears the WebContents member.
48 void CleanUp();
49
50 int callback_id_;
51 std::map<int, ExtractFeatureCallback> callbacks_;
52
53 DISALLOW_COPY_AND_ASSIGN(WebContentsDistillabilityDriver);
54 };
55
56 } // namespace dom_distiller
57
58 #endif // COMPONENTS_DOM_DISTILLER_CONTENT_BROWSER_DISTILLIBILITY_DRIVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698