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

Unified Diff: components/dom_distiller/core/viewer.cc

Issue 1130703003: Show template before distiller finishes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ios-superclass
Patch Set: Rebase and add file to gypi Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: components/dom_distiller/core/viewer.cc
diff --git a/components/dom_distiller/core/viewer.cc b/components/dom_distiller/core/viewer.cc
index 0244a4f51733d59f06ff0ef96f3752fcbeb0a465..67c3f3ff849f04e5c5d8728884141ebd827c57e6 100644
--- a/components/dom_distiller/core/viewer.cc
+++ b/components/dom_distiller/core/viewer.cc
@@ -104,9 +104,6 @@ void EnsureNonEmptyContent(std::string* content) {
}
std::string ReplaceHtmlTemplateValues(
- const std::string& title,
- const std::string& textDirection,
- const std::string& loading_indicator_class,
const std::string& original_url,
const DistilledPagePrefs::Theme theme,
const DistilledPagePrefs::FontFamily font_family) {
@@ -116,7 +113,6 @@ std::string ReplaceHtmlTemplateValues(
// TODO(mdjones): Many or all of these substitutions can be placed on the
// page via JavaScript.
std::vector<std::string> substitutions;
- substitutions.push_back(title); // $1
std::ostringstream css;
std::ostringstream script;
@@ -129,16 +125,14 @@ std::string ReplaceHtmlTemplateValues(
css << "<link rel=\"stylesheet\" href=\"/" << kViewerCssPath << "\">";
script << "<script src=\"" << kViewerJsPath << "\"></script>";
#endif // defined(OS_IOS)
- substitutions.push_back(css.str()); // $2
- substitutions.push_back(script.str()); // $3
+ substitutions.push_back(css.str()); // $1
+ substitutions.push_back(script.str()); // $2
substitutions.push_back(GetThemeCssClass(theme) + " " +
- GetFontCssClass(font_family)); // $4
- substitutions.push_back(loading_indicator_class); // $5
- substitutions.push_back(original_url); // $6
+ GetFontCssClass(font_family)); // $3
+ substitutions.push_back(original_url); // $4
substitutions.push_back(
- l10n_util::GetStringUTF8(IDS_DOM_DISTILLER_VIEWER_VIEW_ORIGINAL)); // $7
- substitutions.push_back(textDirection); // $8
+ l10n_util::GetStringUTF8(IDS_DOM_DISTILLER_VIEWER_VIEW_ORIGINAL)); // $5
return ReplaceStringPlaceholders(html_template, substitutions, NULL);
}
@@ -190,6 +184,21 @@ const std::string GetErrorPageJs() {
return page_update;
}
+const std::string GetSetTitleJs(std::string& title) {
+ EnsureNonEmptyTitle(&title);
+ base::StringValue value(title);
+ std::string output;
+ base::JSONWriter::Write(value, &output);
+ return "setTitle(" + output + ");";
+}
+
+const std::string GetSetTextDirectionJs(const std::string& direction) {
+ base::StringValue value(direction);
+ std::string output;
+ base::JSONWriter::Write(value, &output);
+ return "setTextDirection(" + output + ");";
+}
+
const std::string GetToggleLoadingIndicatorJs(const bool is_last_page) {
if (is_last_page)
return "showLoadingIndicator(true);";
@@ -198,20 +207,10 @@ const std::string GetToggleLoadingIndicatorJs(const bool is_last_page) {
}
const std::string GetUnsafeArticleTemplateHtml(
- const DistilledPageProto* page_proto,
+ const std::string original_url,
const DistilledPagePrefs::Theme theme,
const DistilledPagePrefs::FontFamily font_family) {
- DCHECK(page_proto);
-
- std::string title = net::EscapeForHTML(page_proto->title());
-
- EnsureNonEmptyTitle(&title);
-
- std::string text_direction = page_proto->text_direction();
- std::string original_url = page_proto->url();
-
- return ReplaceHtmlTemplateValues(title, text_direction, "hidden",
- original_url, theme, font_family);
+ return ReplaceHtmlTemplateValues(original_url, theme, font_family);
}
const std::string GetUnsafeArticleContentJs(
@@ -232,15 +231,6 @@ const std::string GetUnsafeArticleContentJs(
return page_update + GetToggleLoadingIndicatorJs(true);
}
-const std::string GetErrorPageHtml(
- const DistilledPagePrefs::Theme theme,
- const DistilledPagePrefs::FontFamily font_family) {
- std::string title = l10n_util::GetStringUTF8(
- IDS_DOM_DISTILLER_VIEWER_FAILED_TO_FIND_ARTICLE_TITLE);
- return ReplaceHtmlTemplateValues(title, "auto", "hidden", "", theme,
- font_family);
-}
-
const std::string GetCss() {
return ResourceBundle::GetSharedInstance().GetRawDataResource(
IDR_DISTILLER_CSS).as_string();

Powered by Google App Engine
This is Rietveld 408576698