Chromium Code Reviews| 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..3d0563a41eda8a46d9d51126e21bfeba6db31381 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({GURL(image.url()), image.data()}); |
|
sdefresne
2016/09/09 09:58:57
I think this should be:
images.push_back(ImageInf
|
| + } |
| - 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_, "", {}, ""); |
|
sdefresne
2016/09/09 09:58:57
Please prefer std::string() to "".
lody
2016/09/09 12:17:53
Done.
|
| + } |
| } |
| void DistillerViewer::SendJavaScript(const std::string& buffer) { |