| 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 "components/dom_distiller/core/dom_distiller_request_view_base.h" | 5 #include "components/dom_distiller/core/dom_distiller_request_view_base.h" |
| 6 | 6 |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 distilled_page_prefs_(distilled_page_prefs), | 25 distilled_page_prefs_(distilled_page_prefs), |
| 26 is_error_page_(false) { | 26 is_error_page_(false) { |
| 27 } | 27 } |
| 28 | 28 |
| 29 DomDistillerRequestViewBase::~DomDistillerRequestViewBase() { | 29 DomDistillerRequestViewBase::~DomDistillerRequestViewBase() { |
| 30 } | 30 } |
| 31 | 31 |
| 32 void DomDistillerRequestViewBase::FlagAsErrorPage() { | 32 void DomDistillerRequestViewBase::FlagAsErrorPage() { |
| 33 // Viewer handle is not passed to this in the case of error pages | 33 // Viewer handle is not passed to this in the case of error pages |
| 34 // so send all JavaScript now. | 34 // so send all JavaScript now. |
| 35 SendJavaScript(viewer::GetJavaScript()); | 35 SendCommonJavaScript(); |
| 36 SendJavaScript(viewer::GetErrorPageJs()); | 36 SendJavaScript(viewer::GetErrorPageJs()); |
| 37 | 37 |
| 38 is_error_page_ = true; | 38 is_error_page_ = true; |
| 39 } | 39 } |
| 40 | 40 |
| 41 bool DomDistillerRequestViewBase::IsErrorPage() { | 41 bool DomDistillerRequestViewBase::IsErrorPage() { |
| 42 return is_error_page_; | 42 return is_error_page_; |
| 43 } | 43 } |
| 44 | 44 |
| 45 void DomDistillerRequestViewBase::OnArticleReady( | 45 void DomDistillerRequestViewBase::OnArticleReady( |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 void DomDistillerRequestViewBase::OnChangeTheme( | 101 void DomDistillerRequestViewBase::OnChangeTheme( |
| 102 DistilledPagePrefs::Theme new_theme) { | 102 DistilledPagePrefs::Theme new_theme) { |
| 103 SendJavaScript(viewer::GetDistilledPageThemeJs(new_theme)); | 103 SendJavaScript(viewer::GetDistilledPageThemeJs(new_theme)); |
| 104 } | 104 } |
| 105 | 105 |
| 106 void DomDistillerRequestViewBase::OnChangeFontFamily( | 106 void DomDistillerRequestViewBase::OnChangeFontFamily( |
| 107 DistilledPagePrefs::FontFamily new_font) { | 107 DistilledPagePrefs::FontFamily new_font) { |
| 108 SendJavaScript(viewer::GetDistilledPageFontFamilyJs(new_font)); | 108 SendJavaScript(viewer::GetDistilledPageFontFamilyJs(new_font)); |
| 109 } | 109 } |
| 110 | 110 |
| 111 void DomDistillerRequestViewBase::OnChangeFontScaling(float scaling) { |
| 112 SendJavaScript(viewer::GetDistilledPageFontScalingJs(scaling)); |
| 113 } |
| 114 |
| 111 void DomDistillerRequestViewBase::TakeViewerHandle( | 115 void DomDistillerRequestViewBase::TakeViewerHandle( |
| 112 scoped_ptr<ViewerHandle> viewer_handle) { | 116 scoped_ptr<ViewerHandle> viewer_handle) { |
| 113 viewer_handle_ = viewer_handle.Pass(); | 117 viewer_handle_ = viewer_handle.Pass(); |
| 114 // Getting the viewer handle means this is not an error page, send | 118 // Getting the viewer handle means this is not an error page, send |
| 115 // the viewer JavaScript and show the loading indicator. | 119 // the viewer JavaScript and show the loading indicator. |
| 116 SendJavaScript(viewer::GetJavaScript()); | 120 SendCommonJavaScript(); |
| 117 SendJavaScript(viewer::GetToggleLoadingIndicatorJs(false)); | 121 SendJavaScript(viewer::GetToggleLoadingIndicatorJs(false)); |
| 118 } | 122 } |
| 119 | 123 |
| 124 void DomDistillerRequestViewBase::SendCommonJavaScript() { |
| 125 SendJavaScript(viewer::GetJavaScript()); |
| 126 SendJavaScript(viewer::GetDistilledPageFontScalingJs( |
| 127 distilled_page_prefs_->GetFontScaling())); |
| 128 } |
| 129 |
| 120 } // namespace dom_distiller | 130 } // namespace dom_distiller |
| OLD | NEW |