Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(328)

Side by Side Diff: components/dom_distiller/core/viewer.cc

Issue 1008993007: Fix style on iOS for distilled content. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Real fix. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/dom_distiller/core/html/dom_distiller_viewer.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
117 substitutions.push_back(kViewerJsPath); // $3 117 std::ostringstream css;
118 std::ostringstream script;
119 #if defined(OS_IOS)
120 // On iOS the content is inlined as there is no API to detect those requests
121 // and return the local data once a page is loaded.
122 css << "<style>" << viewer::GetCss() << "</style>";
123 script << "<script>\n" << viewer::GetJavaScript() << "\n</script>";
124 #else
125 css << "<link rel=\"stylesheet\" href=\"/" << kViewerCssPath << "\">";
126 script << "<script src=\"" << kViewerJsPath << "\"></script>";
127 #endif // defined(OS_IOS)
128 substitutions.push_back(css.str()); // $2
129 substitutions.push_back(script.str()); // $3
130
118 substitutions.push_back(GetThemeCssClass(theme) + " " + 131 substitutions.push_back(GetThemeCssClass(theme) + " " +
119 GetFontCssClass(font_family)); // $4 132 GetFontCssClass(font_family)); // $4
120 substitutions.push_back(content); // $5 133 substitutions.push_back(content); // $5
121 substitutions.push_back(loading_indicator_class); // $6 134 substitutions.push_back(loading_indicator_class); // $6
122 substitutions.push_back(original_url); // $7 135 substitutions.push_back(original_url); // $7
123 substitutions.push_back( 136 substitutions.push_back(
124 l10n_util::GetStringUTF8(IDS_DOM_DISTILLER_VIEWER_VIEW_ORIGINAL)); // $8 137 l10n_util::GetStringUTF8(IDS_DOM_DISTILLER_VIEWER_VIEW_ORIGINAL)); // $8
125 substitutions.push_back(textDirection); // $9 138 substitutions.push_back(textDirection); // $9
126 return ReplaceStringPlaceholders(html_template, substitutions, NULL); 139 return ReplaceStringPlaceholders(html_template, substitutions, NULL);
127 } 140 }
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 } 274 }
262 275
263 const std::string GetDistilledPageFontFamilyJs( 276 const std::string GetDistilledPageFontFamilyJs(
264 DistilledPagePrefs::FontFamily font_family) { 277 DistilledPagePrefs::FontFamily font_family) {
265 return "useFontFamily('" + GetJsFontFamily(font_family) + "');"; 278 return "useFontFamily('" + GetJsFontFamily(font_family) + "');";
266 } 279 }
267 280
268 } // namespace viewer 281 } // namespace viewer
269 282
270 } // namespace dom_distiller 283 } // namespace dom_distiller
OLDNEW
« no previous file with comments | « components/dom_distiller/core/html/dom_distiller_viewer.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698