Chromium Code Reviews| Index: ios/chrome/browser/dom_distiller/distiller_viewer.h |
| diff --git a/ios/chrome/browser/dom_distiller/distiller_viewer.h b/ios/chrome/browser/dom_distiller/distiller_viewer.h |
| index b4a82b37732736244914d2eb6e0e24ab0b4fa572..65f4a1c1726f63ba933d3c67ae1ab7b64ae68db2 100644 |
| --- a/ios/chrome/browser/dom_distiller/distiller_viewer.h |
| +++ b/ios/chrome/browser/dom_distiller/distiller_viewer.h |
| @@ -17,6 +17,7 @@ class GURL; |
| namespace dom_distiller { |
| class DistilledPagePrefs; |
| +class Distiller; |
| // An interface for a dom_distiller ViewRequestDelegate that distills a URL and |
| // calls the given callback with the distilled HTML string and the images it |
| @@ -35,8 +36,7 @@ class DistillerViewerInterface : public DomDistillerRequestViewBase { |
| const std::string& title)> |
| DistillationFinishedCallback; |
| - DistillerViewerInterface(dom_distiller::DomDistillerService* distillerService, |
| - PrefService* prefs) |
| + DistillerViewerInterface(PrefService* prefs) |
| : DomDistillerRequestViewBase(new DistilledPagePrefs(prefs)) {} |
| ~DistillerViewerInterface() override {} |
| @@ -52,20 +52,36 @@ class DistillerViewerInterface : public DomDistillerRequestViewBase { |
| class DistillerViewer : public DistillerViewerInterface { |
| public: |
| // Creates a |DistillerView| that will be used to distill |url|. |
| - // If |page| is not null, it will be used to load |url| and inject the page. |
| - // If |page| is null, the default factory of |distillerService| will be used. |
| // |callback| is called when distillation is finished with the protobuf |
| // containing the distilled page. |
| DistillerViewer(dom_distiller::DomDistillerService* distillerService, |
|
jif
2017/01/31 10:07:53
I think this constructor is not used.
Olivier
2017/01/31 10:25:24
It is used in ReaderModeController below (even if
|
| PrefService* prefs, |
| const GURL& url, |
| - const DistillationFinishedCallback& callback, |
| - std::unique_ptr<dom_distiller::DistillerPage> page); |
| + const DistillationFinishedCallback& callback); |
| + |
| + // Creates a |DistillerView| without depending on the DomDistillerService. |
| + // Caller must provide |distiller_factory| and |page| which cannot be null. |
| + // |callback| is called when distillation is finished with the protobuf |
| + // containing the distilled page. |
| + DistillerViewer(dom_distiller::DistillerFactory* distiller_factory, |
| + std::unique_ptr<dom_distiller::DistillerPage> page, |
| + PrefService* prefs, |
| + const GURL& url, |
| + const DistillationFinishedCallback& callback); |
| ~DistillerViewer() override; |
| + // Called by the distiller service when article is ready. |
| void OnArticleReady( |
|
jif
2017/01/31 10:07:53
Can you add a "// DistillerViewerInterface impleme
Olivier
2017/01/31 10:25:24
Done.
|
| const dom_distiller::DistilledArticleProto* article_proto) override; |
| + // Called by the distiller when article is ready. |
| + void OnDistillerFinished( |
|
jif
2017/01/31 10:07:53
OnDistillerFinished and OnArticleDistillationUpdat
Olivier
2017/01/31 10:25:24
Done.
|
| + std::unique_ptr<dom_distiller::DistilledArticleProto> distilled_article); |
| + |
| + // Called by the distiller when article is updated. |
| + void OnArticleDistillationUpdated( |
| + const dom_distiller::ArticleDistillationUpdate& article_update); |
| + |
| void SendJavaScript(const std::string& buffer) override; |
| private: |
| @@ -75,6 +91,8 @@ class DistillerViewer : public DistillerViewerInterface { |
| std::string js_buffer_; |
| // Callback to run once distillation is complete. |
| const DistillationFinishedCallback callback_; |
| + // Keep reference of the distiller_ during distillation. |
| + std::unique_ptr<Distiller> distiller_; |
| DISALLOW_COPY_AND_ASSIGN(DistillerViewer); |
| }; |