OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 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_CORE_PAGE_DISTILLER_H_ | |
6 #define COMPONENTS_DOM_DISTILLER_CORE_PAGE_DISTILLER_H_ | |
7 | |
8 #include <string> | |
9 #include <vector> | |
10 | |
11 #include "base/callback.h" | |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "base/values.h" | |
14 #include "components/dom_distiller/core/distiller_page.h" | |
15 #include "url/gurl.h" | |
16 | |
17 namespace dom_distiller { | |
18 | |
19 class DistillerImpl; | |
20 | |
21 struct DistilledPageInfo { | |
22 std::string title; | |
23 std::string html; | |
24 std::string next_page_url; | |
25 std::vector<std::string> image_urls; | |
26 DistilledPageInfo(); | |
27 ~DistilledPageInfo(); | |
28 | |
29 private: | |
30 DISALLOW_COPY_AND_ASSIGN(DistilledPageInfo); | |
31 }; | |
32 | |
33 // Distills a single page and | |
cjhopman
2014/02/03 21:47:22
and what?
shashi
2014/02/03 23:19:29
Done, typo.
| |
34 class PageDistiller : public DistillerPage::Delegate { | |
35 public: | |
36 typedef base::Callback<void(const DistilledPageInfo& distilled_page, | |
37 bool distillation_successful)> | |
38 PageDistillerCallback; | |
39 explicit PageDistiller(const DistillerPageFactory& distiller_page_factory); | |
40 virtual ~PageDistiller(); | |
41 | |
42 // Creates an execution context. This must be called once before any calls are | |
43 // made to distill the page. | |
44 virtual void Init(); | |
45 | |
46 virtual void DistillPage(const GURL& url, | |
47 const PageDistillerCallback& callback); | |
48 | |
49 // PageDistillerContext::Delegate | |
50 virtual void OnLoadURLDone() OVERRIDE; | |
51 virtual void OnExecuteJavaScriptDone(const GURL& page_url, | |
52 const base::Value* value) OVERRIDE; | |
53 | |
54 private: | |
55 virtual void LoadURL(const GURL& url); | |
56 | |
57 // Injects JavaScript to distill a loaded page down to its important content, | |
58 // e.g., extracting a news article from its surrounding boilerplate. | |
59 void GetDistilledContent(); | |
60 | |
61 scoped_ptr<DistillerPage> distiller_page_; | |
62 PageDistillerCallback page_distiller_callback_; | |
63 | |
64 DISALLOW_COPY_AND_ASSIGN(PageDistiller); | |
65 }; | |
66 | |
67 } // namespace dom_distiller | |
68 | |
69 #endif // COMPONENTS_DOM_DISTILLER_CORE_PAGE_DISTILLER_H_ | |
OLD | NEW |