| 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 <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 const dom_distiller::DistilledArticleProto* article_proto) override = 0; | 44 const dom_distiller::DistilledArticleProto* article_proto) override = 0; |
| 45 | 45 |
| 46 void SendJavaScript(const std::string& buffer) override = 0; | 46 void SendJavaScript(const std::string& buffer) override = 0; |
| 47 | 47 |
| 48 DISALLOW_COPY_AND_ASSIGN(DistillerViewerInterface); | 48 DISALLOW_COPY_AND_ASSIGN(DistillerViewerInterface); |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 // A very simple and naive implementation of the DistillerViewer. | 51 // A very simple and naive implementation of the DistillerViewer. |
| 52 class DistillerViewer : public DistillerViewerInterface { | 52 class DistillerViewer : public DistillerViewerInterface { |
| 53 public: | 53 public: |
| 54 // Creates a |DistillerView| that will be used to distill |url|. |
| 55 // If |factory| is not null, it will be used to create the DistillerPage that |
| 56 // will load the URL and distill the page. If |factory| is null, the default |
| 57 // factory of |distillerService| will be used. |
| 58 // |callback| is called when distillation is finished with the protobuf |
| 59 // containing the distilled page. |
| 54 DistillerViewer(dom_distiller::DomDistillerService* distillerService, | 60 DistillerViewer(dom_distiller::DomDistillerService* distillerService, |
| 55 PrefService* prefs, | 61 PrefService* prefs, |
| 56 const GURL& url, | 62 const GURL& url, |
| 57 const DistillationFinishedCallback& callback); | 63 const DistillationFinishedCallback& callback, |
| 64 const DistillerPageFactory* factory); |
| 58 ~DistillerViewer() override; | 65 ~DistillerViewer() override; |
| 59 | 66 |
| 60 void OnArticleReady( | 67 void OnArticleReady( |
| 61 const dom_distiller::DistilledArticleProto* article_proto) override; | 68 const dom_distiller::DistilledArticleProto* article_proto) override; |
| 62 | 69 |
| 63 void SendJavaScript(const std::string& buffer) override; | 70 void SendJavaScript(const std::string& buffer) override; |
| 64 | 71 |
| 65 private: | 72 private: |
| 66 // The url of the distilled page. | 73 // The url of the distilled page. |
| 67 const GURL url_; | 74 const GURL url_; |
| 68 // JavaScript buffer. | 75 // JavaScript buffer. |
| 69 std::string js_buffer_; | 76 std::string js_buffer_; |
| 70 // Callback to run once distillation is complete. | 77 // Callback to run once distillation is complete. |
| 71 const DistillationFinishedCallback callback_; | 78 const DistillationFinishedCallback callback_; |
| 72 | 79 |
| 73 DISALLOW_COPY_AND_ASSIGN(DistillerViewer); | 80 DISALLOW_COPY_AND_ASSIGN(DistillerViewer); |
| 74 }; | 81 }; |
| 75 | 82 |
| 76 } // namespace dom_distiller | 83 } // namespace dom_distiller |
| 77 | 84 |
| 78 #endif // IOS_CHROME_BROWSER_DOM_DISTILLER_DISTILLER_VIEWER_H_ | 85 #endif // IOS_CHROME_BROWSER_DOM_DISTILLER_DISTILLER_VIEWER_H_ |
| OLD | NEW |