Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Unified Diff: ios/chrome/browser/dom_distiller/distiller_viewer.cc

Issue 2666643002: Remove usage of DomDistillerService in ReadingListDownloadService. (Closed)
Patch Set: feedback Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/dom_distiller/distiller_viewer.cc
diff --git a/ios/chrome/browser/dom_distiller/distiller_viewer.cc b/ios/chrome/browser/dom_distiller/distiller_viewer.cc
index ef2977896eef448bb601aed485bec5ad053733e4..44edeb700c82b33fbae29f760fd301b3bf1542ee 100644
--- a/ios/chrome/browser/dom_distiller/distiller_viewer.cc
+++ b/ios/chrome/browser/dom_distiller/distiller_viewer.cc
@@ -8,6 +8,7 @@
#include <utility>
#include "components/dom_distiller/core/distilled_page_prefs.h"
+#include "components/dom_distiller/core/distiller.h"
#include "components/dom_distiller/core/dom_distiller_request_view_base.h"
#include "components/dom_distiller/core/dom_distiller_service.h"
#include "components/dom_distiller/core/proto/distilled_article.pb.h"
@@ -21,25 +22,45 @@ DistillerViewer::DistillerViewer(
dom_distiller::DomDistillerService* distillerService,
PrefService* prefs,
const GURL& url,
- const DistillationFinishedCallback& callback,
- std::unique_ptr<dom_distiller::DistillerPage> page)
- : DistillerViewerInterface(distillerService, prefs),
- url_(url),
- callback_(callback) {
+ const DistillationFinishedCallback& callback)
+ : DistillerViewerInterface(prefs), url_(url), callback_(callback) {
DCHECK(distillerService);
DCHECK(url.is_valid());
- if (!page) {
- page = distillerService->CreateDefaultDistillerPage(gfx::Size());
- }
-
+ std::unique_ptr<dom_distiller::DistillerPage> page =
+ distillerService->CreateDefaultDistillerPage(gfx::Size());
std::unique_ptr<ViewerHandle> viewer_handle =
distillerService->ViewUrl(this, std::move(page), url);
TakeViewerHandle(std::move(viewer_handle));
}
+DistillerViewer::DistillerViewer(
+ dom_distiller::DistillerFactory* distiller_factory,
+ std::unique_ptr<dom_distiller::DistillerPage> page,
+ PrefService* prefs,
+ const GURL& url,
+ const DistillationFinishedCallback& callback)
+ : DistillerViewerInterface(prefs), url_(url), callback_(callback) {
+ DCHECK(url.is_valid());
+ SendCommonJavaScript();
+ distiller_ = distiller_factory->CreateDistillerForUrl(url);
+ distiller_->DistillPage(
+ url, std::move(page),
+ base::Bind(&DistillerViewer::OnDistillerFinished, base::Unretained(this)),
+ base::Bind(&DistillerViewer::OnArticleDistillationUpdated,
+ base::Unretained(this)));
+}
+
DistillerViewer::~DistillerViewer() {}
+void DistillerViewer::OnArticleDistillationUpdated(
+ const dom_distiller::ArticleDistillationUpdate& article_update) {}
+
+void DistillerViewer::OnDistillerFinished(
+ std::unique_ptr<dom_distiller::DistilledArticleProto> distilled_article) {
+ OnArticleReady(distilled_article.get());
+}
+
void DistillerViewer::OnArticleReady(
const dom_distiller::DistilledArticleProto* article_proto) {
DomDistillerRequestViewBase::OnArticleReady(article_proto);

Powered by Google App Engine
This is Rietveld 408576698