| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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|. | 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 | 55 // If |page| is not null, it will be used to load |url| and inject the page. |
| 56 // will load the URL and distill the page. If |factory| is null, the default | 56 // If |page| is null, the default factory of |distillerService| will be used. |
| 57 // factory of |distillerService| will be used. | |
| 58 // |callback| is called when distillation is finished with the protobuf | 57 // |callback| is called when distillation is finished with the protobuf |
| 59 // containing the distilled page. | 58 // containing the distilled page. |
| 60 DistillerViewer(dom_distiller::DomDistillerService* distillerService, | 59 DistillerViewer(dom_distiller::DomDistillerService* distillerService, |
| 61 PrefService* prefs, | 60 PrefService* prefs, |
| 62 const GURL& url, | 61 const GURL& url, |
| 63 const DistillationFinishedCallback& callback, | 62 const DistillationFinishedCallback& callback, |
| 64 const DistillerPageFactory* factory); | 63 std::unique_ptr<dom_distiller::DistillerPage> page); |
| 65 ~DistillerViewer() override; | 64 ~DistillerViewer() override; |
| 66 | 65 |
| 67 void OnArticleReady( | 66 void OnArticleReady( |
| 68 const dom_distiller::DistilledArticleProto* article_proto) override; | 67 const dom_distiller::DistilledArticleProto* article_proto) override; |
| 69 | 68 |
| 70 void SendJavaScript(const std::string& buffer) override; | 69 void SendJavaScript(const std::string& buffer) override; |
| 71 | 70 |
| 72 private: | 71 private: |
| 73 // The url of the distilled page. | 72 // The url of the distilled page. |
| 74 const GURL url_; | 73 const GURL url_; |
| 75 // JavaScript buffer. | 74 // JavaScript buffer. |
| 76 std::string js_buffer_; | 75 std::string js_buffer_; |
| 77 // Callback to run once distillation is complete. | 76 // Callback to run once distillation is complete. |
| 78 const DistillationFinishedCallback callback_; | 77 const DistillationFinishedCallback callback_; |
| 79 | 78 |
| 80 DISALLOW_COPY_AND_ASSIGN(DistillerViewer); | 79 DISALLOW_COPY_AND_ASSIGN(DistillerViewer); |
| 81 }; | 80 }; |
| 82 | 81 |
| 83 } // namespace dom_distiller | 82 } // namespace dom_distiller |
| 84 | 83 |
| 85 #endif // IOS_CHROME_BROWSER_DOM_DISTILLER_DISTILLER_VIEWER_H_ | 84 #endif // IOS_CHROME_BROWSER_DOM_DISTILLER_DISTILLER_VIEWER_H_ |
| OLD | NEW |