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

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

Issue 667323002: Update protobuff and template to handle text direction (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Text directionality fix Created 6 years, 2 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
« no previous file with comments | « components/dom_distiller/core/proto/distilled_page.proto ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/dom_distiller/core/viewer.cc
diff --git a/components/dom_distiller/core/viewer.cc b/components/dom_distiller/core/viewer.cc
index b0365e075bd30dd63ffd4500c3ffe2c7f8d039e6..00e05ca447e2a8665bdffd1376ef9a5a590d91c5 100644
--- a/components/dom_distiller/core/viewer.cc
+++ b/components/dom_distiller/core/viewer.cc
@@ -102,6 +102,7 @@ void EnsureNonEmptyTitleAndContent(std::string* title, std::string* content) {
std::string ReplaceHtmlTemplateValues(
const std::string& title,
+ const std::string& textDirection,
const std::string& content,
const std::string& loading_indicator_class,
const std::string& original_url,
@@ -121,6 +122,7 @@ std::string ReplaceHtmlTemplateValues(
substitutions.push_back(original_url); // $7
substitutions.push_back(
l10n_util::GetStringUTF8(IDS_DOM_DISTILLER_VIEWER_VIEW_ORIGINAL)); // $8
+ substitutions.push_back(textDirection); // $9
return ReplaceStringPlaceholders(html_template, substitutions, NULL);
}
@@ -160,7 +162,8 @@ const std::string GetUnsafePartialArticleHtml(
EnsureNonEmptyTitleAndContent(&title, &unsafe_article_html);
std::string original_url = page_proto->url();
return ReplaceHtmlTemplateValues(
- title, unsafe_article_html, "visible", original_url, theme, font_family);
+ title, page_proto->text_direction(), unsafe_article_html, "visible",
+ original_url, theme, font_family);
}
const std::string GetUnsafeArticleHtml(
@@ -170,6 +173,7 @@ const std::string GetUnsafeArticleHtml(
DCHECK(article_proto);
std::string title;
std::string unsafe_article_html;
+ std::string text_direction = "";
if (article_proto->has_title() && article_proto->pages_size() > 0 &&
article_proto->pages(0).has_html()) {
title = net::EscapeForHTML(article_proto->title());
@@ -178,6 +182,7 @@ const std::string GetUnsafeArticleHtml(
unsafe_output_stream << article_proto->pages(page_num).html();
}
unsafe_article_html = unsafe_output_stream.str();
+ text_direction = article_proto->pages(0).text_direction();
}
EnsureNonEmptyTitleAndContent(&title, &unsafe_article_html);
@@ -188,7 +193,8 @@ const std::string GetUnsafeArticleHtml(
}
return ReplaceHtmlTemplateValues(
- title, unsafe_article_html, "hidden", original_url, theme, font_family);
+ title, text_direction, unsafe_article_html, "hidden", original_url,
+ theme, font_family);
}
const std::string GetErrorPageHtml(
@@ -199,7 +205,7 @@ const std::string GetErrorPageHtml(
std::string content = l10n_util::GetStringUTF8(
IDS_DOM_DISTILLER_VIEWER_FAILED_TO_FIND_ARTICLE_CONTENT);
return ReplaceHtmlTemplateValues(
- title, content, "hidden", "", theme, font_family);
+ title, "", content, "hidden", "", theme, font_family);
}
const std::string GetCss() {
« no previous file with comments | « components/dom_distiller/core/proto/distilled_page.proto ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698