Chromium Code Reviews| 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 #include "ios/chrome/browser/dom_distiller/distiller_viewer.h" | 5 #include "ios/chrome/browser/dom_distiller/distiller_viewer.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "components/dom_distiller/core/distilled_page_prefs.h" | 10 #include "components/dom_distiller/core/distilled_page_prefs.h" |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 this, distillerService->CreateDefaultDistillerPage(gfx::Size()), url); | 32 this, distillerService->CreateDefaultDistillerPage(gfx::Size()), url); |
| 33 | 33 |
| 34 TakeViewerHandle(std::move(viewer_handle)); | 34 TakeViewerHandle(std::move(viewer_handle)); |
| 35 } | 35 } |
| 36 | 36 |
| 37 DistillerViewer::~DistillerViewer() {} | 37 DistillerViewer::~DistillerViewer() {} |
| 38 | 38 |
| 39 void DistillerViewer::OnArticleReady( | 39 void DistillerViewer::OnArticleReady( |
| 40 const dom_distiller::DistilledArticleProto* article_proto) { | 40 const dom_distiller::DistilledArticleProto* article_proto) { |
| 41 DomDistillerRequestViewBase::OnArticleReady(article_proto); | 41 DomDistillerRequestViewBase::OnArticleReady(article_proto); |
| 42 if (article_proto->pages_size() > 0) { | |
| 43 std::vector<ImageInfo> images; | |
| 44 for (int i = 0; i < article_proto->pages(0).image_size(); i++) { | |
| 45 auto image = article_proto->pages(0).image(i); | |
| 46 images.push_back({GURL(image.url()), image.data()}); | |
|
sdefresne
2016/09/09 09:58:57
I think this should be:
images.push_back(ImageInf
| |
| 47 } | |
| 42 | 48 |
| 43 std::vector<ImageInfo> images; | 49 const std::string html = viewer::GetUnsafeArticleTemplateHtml( |
| 44 for (int i = 0; i < article_proto->pages(0).image_size(); i++) { | 50 url_.spec(), distilled_page_prefs_->GetTheme(), |
| 45 auto image = article_proto->pages(0).image(i); | 51 distilled_page_prefs_->GetFontFamily()); |
| 46 images.push_back({GURL(image.url()), image.data()}); | 52 |
| 53 std::string html_and_script(html); | |
| 54 html_and_script += | |
| 55 "<script> distiller_on_ios = true; " + js_buffer_ + "</script>"; | |
| 56 callback_.Run(url_, html_and_script, images, article_proto->title()); | |
| 57 } else { | |
| 58 callback_.Run(url_, "", {}, ""); | |
|
sdefresne
2016/09/09 09:58:57
Please prefer std::string() to "".
lody
2016/09/09 12:17:53
Done.
| |
| 47 } | 59 } |
| 48 | |
| 49 const std::string html = viewer::GetUnsafeArticleTemplateHtml( | |
| 50 url_.spec(), distilled_page_prefs_->GetTheme(), | |
| 51 distilled_page_prefs_->GetFontFamily()); | |
| 52 | |
| 53 std::string html_and_script(html); | |
| 54 html_and_script += | |
| 55 "<script> distiller_on_ios = true; " + js_buffer_ + "</script>"; | |
| 56 callback_.Run(url_, html_and_script, images); | |
| 57 } | 60 } |
| 58 | 61 |
| 59 void DistillerViewer::SendJavaScript(const std::string& buffer) { | 62 void DistillerViewer::SendJavaScript(const std::string& buffer) { |
| 60 js_buffer_ += buffer; | 63 js_buffer_ += buffer; |
| 61 } | 64 } |
| 62 | 65 |
| 63 } // namespace dom_distiller | 66 } // namespace dom_distiller |
| OLD | NEW |