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 std::string title(l10n_util::GetStringUTF8( | 38 std::string title(l10n_util::GetStringUTF8( |
39 IDS_DOM_DISTILLER_VIEWER_FAILED_TO_FIND_ARTICLE_CONTENT)); | 39 IDS_DOM_DISTILLER_VIEWER_FAILED_TO_FIND_ARTICLE_CONTENT)); |
40 SendJavaScript(viewer::GetSetTitleJs(title)); | 40 SendJavaScript(viewer::GetSetTitleJs(title)); |
41 | 41 |
42 SendJavaScript(viewer::GetSetTextDirectionJs(std::string("auto"))); | 42 SendJavaScript(viewer::GetSetTextDirectionJs(std::string("auto"))); |
43 SendJavaScript(viewer::GetShowFeedbackFormJs()); | 43 SendJavaScript(viewer::GetShowFeedbackFormJs()); |
44 is_error_page_ = true; | 44 is_error_page_ = true; |
45 } | 45 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 void DomDistillerRequestViewBase::OnChangeTheme( | 107 void DomDistillerRequestViewBase::OnChangeTheme( |
108 DistilledPagePrefs::Theme new_theme) { | 108 DistilledPagePrefs::Theme new_theme) { |
109 SendJavaScript(viewer::GetDistilledPageThemeJs(new_theme)); | 109 SendJavaScript(viewer::GetDistilledPageThemeJs(new_theme)); |
110 } | 110 } |
111 | 111 |
112 void DomDistillerRequestViewBase::OnChangeFontFamily( | 112 void DomDistillerRequestViewBase::OnChangeFontFamily( |
113 DistilledPagePrefs::FontFamily new_font) { | 113 DistilledPagePrefs::FontFamily new_font) { |
114 SendJavaScript(viewer::GetDistilledPageFontFamilyJs(new_font)); | 114 SendJavaScript(viewer::GetDistilledPageFontFamilyJs(new_font)); |
115 } | 115 } |
116 | 116 |
| 117 void DomDistillerRequestViewBase::OnChangeFontScaling(float scaling) { |
| 118 SendJavaScript(viewer::GetDistilledPageFontScalingJs(scaling)); |
| 119 } |
| 120 |
117 void DomDistillerRequestViewBase::TakeViewerHandle( | 121 void DomDistillerRequestViewBase::TakeViewerHandle( |
118 scoped_ptr<ViewerHandle> viewer_handle) { | 122 scoped_ptr<ViewerHandle> viewer_handle) { |
119 viewer_handle_ = viewer_handle.Pass(); | 123 viewer_handle_ = viewer_handle.Pass(); |
120 // Getting the viewer handle means this is not an error page, send | 124 // Getting the viewer handle means this is not an error page, send |
121 // the viewer JavaScript and show the loading indicator. | 125 // the viewer JavaScript and show the loading indicator. |
122 SendJavaScript(viewer::GetJavaScript()); | 126 SendCommonJavaScript(); |
123 SendJavaScript(viewer::GetToggleLoadingIndicatorJs(false)); | 127 SendJavaScript(viewer::GetToggleLoadingIndicatorJs(false)); |
124 } | 128 } |
125 | 129 |
| 130 void DomDistillerRequestViewBase::SendCommonJavaScript() { |
| 131 SendJavaScript(viewer::GetJavaScript()); |
| 132 SendJavaScript(viewer::GetDistilledPageFontScalingJs( |
| 133 distilled_page_prefs_->GetFontScaling())); |
| 134 } |
| 135 |
126 } // namespace dom_distiller | 136 } // namespace dom_distiller |
OLD | NEW |