OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef IOS_CHROME_BROWSER_DOM_DISTILLER_DISTILLER_VIEWER_H_ | 5 #ifndef IOS_CHROME_BROWSER_DOM_DISTILLER_DISTILLER_VIEWER_H_ |
6 #define IOS_CHROME_BROWSER_DOM_DISTILLER_DISTILLER_VIEWER_H_ | 6 #define IOS_CHROME_BROWSER_DOM_DISTILLER_DISTILLER_VIEWER_H_ |
7 | 7 |
| 8 #include <string> |
| 9 |
8 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "components/dom_distiller/core/dom_distiller_request_view_base.h" |
9 #include "components/dom_distiller/core/task_tracker.h" | 12 #include "components/dom_distiller/core/task_tracker.h" |
10 | 13 |
11 class GURL; | 14 class GURL; |
12 | 15 |
13 namespace ios { | 16 namespace ios { |
14 class ChromeBrowserState; | 17 class ChromeBrowserState; |
15 } | 18 } |
16 | 19 |
17 namespace dom_distiller { | 20 namespace dom_distiller { |
18 | 21 |
19 class DistilledPagePrefs; | 22 class DistilledPagePrefs; |
20 | 23 |
21 // A very simple and naive implementation of the dom_distiller | 24 // A very simple and naive implementation of the dom_distiller |
22 // ViewRequestDelegate: From an URL it builds an HTML string and notifies when | 25 // ViewRequestDelegate: From an URL it builds an HTML string and notifies when |
23 // finished. | 26 // finished. |
24 class DistillerViewer : public dom_distiller::ViewRequestDelegate { | 27 class DistillerViewer : public DomDistillerRequestViewBase { |
25 public: | 28 public: |
26 typedef base::Callback<void(const GURL&, const std::string&)> | 29 typedef base::Callback<void(const GURL&, const std::string&)> |
27 DistillationFinishedCallback; | 30 DistillationFinishedCallback; |
28 | 31 |
29 DistillerViewer(ios::ChromeBrowserState* browser_state, | 32 DistillerViewer(ios::ChromeBrowserState* browser_state, |
30 const GURL& url, | 33 const GURL& url, |
31 const DistillationFinishedCallback& callback); | 34 const DistillationFinishedCallback& callback); |
32 ~DistillerViewer() override; | 35 ~DistillerViewer() override; |
33 | 36 |
34 // ViewRequestDelegate. | 37 void SendJavaScript(const std::string& buffer) override; |
35 void OnArticleUpdated( | 38 |
36 dom_distiller::ArticleDistillationUpdate article_update) override {} | 39 std::string GetJavaScriptBuffer(); |
37 void OnArticleReady(const DistilledArticleProto* article_proto) override; | |
38 | 40 |
39 private: | 41 private: |
40 // The url of the distilled page. | 42 // The url of the distilled page. |
41 const GURL url_; | 43 const GURL url_; |
42 // Callback to invoke when the page is finished. | |
43 DistillationFinishedCallback callback_; | |
44 // Interface for accessing preferences for distilled pages. | 44 // Interface for accessing preferences for distilled pages. |
45 scoped_ptr<DistilledPagePrefs> distilled_page_prefs_; | 45 scoped_ptr<DistilledPagePrefs> distilled_page_prefs_; |
46 // Keeps the distiller going until the view is released. | 46 // JavaScript buffer. |
47 scoped_ptr<dom_distiller::ViewerHandle> viewer_handle_; | 47 std::string js_buffer_; |
48 | 48 |
49 DISALLOW_COPY_AND_ASSIGN(DistillerViewer); | 49 DISALLOW_COPY_AND_ASSIGN(DistillerViewer); |
50 }; | 50 }; |
51 | 51 |
52 } // namespace dom_distiller | 52 } // namespace dom_distiller |
53 | 53 |
54 #endif // IOS_CHROME_BROWSER_DOM_DISTILLER_DISTILLER_VIEWER_H_ | 54 #endif // IOS_CHROME_BROWSER_DOM_DISTILLER_DISTILLER_VIEWER_H_ |
OLD | NEW |