| 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 14 matching lines...) Expand all Loading... |
| 25 : DomDistillerRequestViewBase( | 25 : DomDistillerRequestViewBase( |
| 26 new DistilledPagePrefs(browser_state->GetPrefs())), | 26 new DistilledPagePrefs(browser_state->GetPrefs())), |
| 27 url_(url), | 27 url_(url), |
| 28 callback_(callback) { | 28 callback_(callback) { |
| 29 DCHECK(browser_state); | 29 DCHECK(browser_state); |
| 30 DCHECK(url.is_valid()); | 30 DCHECK(url.is_valid()); |
| 31 dom_distiller::DomDistillerService* distillerService = | 31 dom_distiller::DomDistillerService* distillerService = |
| 32 dom_distiller::DomDistillerServiceFactory::GetForBrowserState( | 32 dom_distiller::DomDistillerServiceFactory::GetForBrowserState( |
| 33 browser_state); | 33 browser_state); |
| 34 | 34 |
| 35 scoped_ptr<ViewerHandle> viewer_handle = distillerService->ViewUrl( | 35 std::unique_ptr<ViewerHandle> viewer_handle = distillerService->ViewUrl( |
| 36 this, distillerService->CreateDefaultDistillerPage(gfx::Size()), url); | 36 this, distillerService->CreateDefaultDistillerPage(gfx::Size()), url); |
| 37 | 37 |
| 38 TakeViewerHandle(std::move(viewer_handle)); | 38 TakeViewerHandle(std::move(viewer_handle)); |
| 39 } | 39 } |
| 40 | 40 |
| 41 DistillerViewer::~DistillerViewer() { | 41 DistillerViewer::~DistillerViewer() { |
| 42 } | 42 } |
| 43 | 43 |
| 44 void DistillerViewer::OnArticleReady( | 44 void DistillerViewer::OnArticleReady( |
| 45 const dom_distiller::DistilledArticleProto* article_proto) { | 45 const dom_distiller::DistilledArticleProto* article_proto) { |
| 46 DomDistillerRequestViewBase::OnArticleReady(article_proto); | 46 DomDistillerRequestViewBase::OnArticleReady(article_proto); |
| 47 | 47 |
| 48 const std::string html = viewer::GetUnsafeArticleTemplateHtml( | 48 const std::string html = viewer::GetUnsafeArticleTemplateHtml( |
| 49 url_.spec(), distilled_page_prefs_->GetTheme(), | 49 url_.spec(), distilled_page_prefs_->GetTheme(), |
| 50 distilled_page_prefs_->GetFontFamily()); | 50 distilled_page_prefs_->GetFontFamily()); |
| 51 | 51 |
| 52 std::string html_and_script(html); | 52 std::string html_and_script(html); |
| 53 html_and_script += | 53 html_and_script += |
| 54 "<script> distiller_on_ios = true; " + js_buffer_ + "</script>"; | 54 "<script> distiller_on_ios = true; " + js_buffer_ + "</script>"; |
| 55 callback_.Run(url_, html_and_script); | 55 callback_.Run(url_, html_and_script); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void DistillerViewer::SendJavaScript(const std::string& buffer) { | 58 void DistillerViewer::SendJavaScript(const std::string& buffer) { |
| 59 js_buffer_ += buffer; | 59 js_buffer_ += buffer; |
| 60 } | 60 } |
| 61 | 61 |
| 62 } // namespace dom_distiller | 62 } // namespace dom_distiller |
| OLD | NEW |