OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/viewer.h" | 5 #include "components/dom_distiller/core/viewer.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
106 const std::string& content, | 106 const std::string& content, |
107 const std::string& loading_indicator_class, | 107 const std::string& loading_indicator_class, |
108 const std::string& original_url, | 108 const std::string& original_url, |
109 const DistilledPagePrefs::Theme theme, | 109 const DistilledPagePrefs::Theme theme, |
110 const DistilledPagePrefs::FontFamily font_family) { | 110 const DistilledPagePrefs::FontFamily font_family) { |
111 base::StringPiece html_template = | 111 base::StringPiece html_template = |
112 ResourceBundle::GetSharedInstance().GetRawDataResource( | 112 ResourceBundle::GetSharedInstance().GetRawDataResource( |
113 IDR_DOM_DISTILLER_VIEWER_HTML); | 113 IDR_DOM_DISTILLER_VIEWER_HTML); |
114 std::vector<std::string> substitutions; | 114 std::vector<std::string> substitutions; |
115 substitutions.push_back(title); // $1 | 115 substitutions.push_back(title); // $1 |
116 substitutions.push_back(kViewerCssPath); // $2 | 116 #if defined(OS_IOS) |
117 substitutions.push_back(kViewerJsPath); // $3 | 117 // On iOS the content is inlined as there is no API to detect those requests |
118 // and return the local data once a page is loaded. | |
cjhopman
2015/03/19 21:24:52
I was under the impression that on iOS we could ha
nyquist
2015/03/19 21:39:15
+1 many times. I think at least up to a +4 here.
| |
119 substitutions.push_back(viewer::GetCss()); // $2 | |
120 std::ostringstream script; | |
121 script << "<script>\n" << viewer::GetJavaScript() << "\n</script>"; | |
122 substitutions.push_back(script.str()); // $3 | |
123 #else | |
124 std::ostringstream css; | |
125 css << "<link rel=\"stylesheet\" href=\"/" << kViewerCssPath << "\">"; | |
126 substitutions.push_back(css.str()); // $2 | |
127 std::ostringstream script; | |
128 script << "<script src=\"" << kViewerJsPath << "\"></script>"; | |
129 substitutions.push_back(script.str()); // $3 | |
130 #endif // defined(OS_IOS) | |
131 | |
118 substitutions.push_back(GetThemeCssClass(theme) + " " + | 132 substitutions.push_back(GetThemeCssClass(theme) + " " + |
119 GetFontCssClass(font_family)); // $4 | 133 GetFontCssClass(font_family)); // $4 |
120 substitutions.push_back(content); // $5 | 134 substitutions.push_back(content); // $5 |
121 substitutions.push_back(loading_indicator_class); // $6 | 135 substitutions.push_back(loading_indicator_class); // $6 |
122 substitutions.push_back(original_url); // $7 | 136 substitutions.push_back(original_url); // $7 |
123 substitutions.push_back( | 137 substitutions.push_back( |
124 l10n_util::GetStringUTF8(IDS_DOM_DISTILLER_VIEWER_VIEW_ORIGINAL)); // $8 | 138 l10n_util::GetStringUTF8(IDS_DOM_DISTILLER_VIEWER_VIEW_ORIGINAL)); // $8 |
125 substitutions.push_back(textDirection); // $9 | 139 substitutions.push_back(textDirection); // $9 |
126 return ReplaceStringPlaceholders(html_template, substitutions, NULL); | 140 return ReplaceStringPlaceholders(html_template, substitutions, NULL); |
127 } | 141 } |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
261 } | 275 } |
262 | 276 |
263 const std::string GetDistilledPageFontFamilyJs( | 277 const std::string GetDistilledPageFontFamilyJs( |
264 DistilledPagePrefs::FontFamily font_family) { | 278 DistilledPagePrefs::FontFamily font_family) { |
265 return "useFontFamily('" + GetJsFontFamily(font_family) + "');"; | 279 return "useFontFamily('" + GetJsFontFamily(font_family) + "');"; |
266 } | 280 } |
267 | 281 |
268 } // namespace viewer | 282 } // namespace viewer |
269 | 283 |
270 } // namespace dom_distiller | 284 } // namespace dom_distiller |
OLD | NEW |