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

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

Issue 2320403002: Update reading list entry on download (Closed)
Patch Set: address comments Created 4 years, 3 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 143324661d438f14fe70dc3d39aa8f22ab82d971..a0bd94ab33f1f85bdf72d8163c7e06f943d71308 100644
--- a/ios/chrome/browser/dom_distiller/distiller_viewer.cc
+++ b/ios/chrome/browser/dom_distiller/distiller_viewer.cc
@@ -39,21 +39,24 @@ DistillerViewer::~DistillerViewer() {}
void DistillerViewer::OnArticleReady(
const dom_distiller::DistilledArticleProto* article_proto) {
DomDistillerRequestViewBase::OnArticleReady(article_proto);
+ if (article_proto->pages_size() > 0) {
+ std::vector<ImageInfo> images;
+ for (int i = 0; i < article_proto->pages(0).image_size(); i++) {
+ auto image = article_proto->pages(0).image(i);
+ images.push_back(ImageInfo{GURL(image.url()), image.data()});
noyau (Ping after 24h) 2016/09/09 12:45:22 imageInfo{ ? Should this be ImageInfo( instead? I
+ }
- std::vector<ImageInfo> images;
- for (int i = 0; i < article_proto->pages(0).image_size(); i++) {
- auto image = article_proto->pages(0).image(i);
- images.push_back({GURL(image.url()), image.data()});
- }
-
- const std::string html = viewer::GetUnsafeArticleTemplateHtml(
- url_.spec(), distilled_page_prefs_->GetTheme(),
- distilled_page_prefs_->GetFontFamily());
+ const std::string html = viewer::GetUnsafeArticleTemplateHtml(
+ url_.spec(), distilled_page_prefs_->GetTheme(),
+ distilled_page_prefs_->GetFontFamily());
- std::string html_and_script(html);
- html_and_script +=
- "<script> distiller_on_ios = true; " + js_buffer_ + "</script>";
- callback_.Run(url_, html_and_script, images);
+ std::string html_and_script(html);
+ html_and_script +=
+ "<script> distiller_on_ios = true; " + js_buffer_ + "</script>";
+ callback_.Run(url_, html_and_script, images, article_proto->title());
+ } else {
+ callback_.Run(url_, std::string(), {}, std::string());
+ }
}
void DistillerViewer::SendJavaScript(const std::string& buffer) {

Powered by Google App Engine
This is Rietveld 408576698