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

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

Issue 341563002: Theme Preferences for Distilled Pages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Switched to Profile from PrefService Created 6 years, 6 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 e3c77962dce2a522e0c6ae5ccf016f09629151eb..3fc8142bbb0bd5b4831fb17d932bebc72f288b88 100644
--- a/components/dom_distiller/core/viewer.cc
+++ b/components/dom_distiller/core/viewer.cc
@@ -13,6 +13,7 @@
#include "components/dom_distiller/core/dom_distiller_service.h"
#include "components/dom_distiller/core/proto/distilled_article.pb.h"
#include "components/dom_distiller/core/proto/distilled_page.pb.h"
+#include "components/dom_distiller/core/reader_mode_preferences.h"
#include "components/dom_distiller/core/task_tracker.h"
#include "components/dom_distiller/core/url_constants.h"
#include "components/dom_distiller/core/url_utils.h"
@@ -27,6 +28,27 @@
namespace dom_distiller {
namespace {
robliao 2014/06/17 23:08:16 Add an extra linebreak here.
smaslo 2014/06/18 16:57:15 Done.
+const char WHITE[] = "#FFF";
robliao 2014/06/17 23:08:16 Sorry, I got mixed up in Chrome Windows convention
smaslo 2014/06/18 16:57:15 Done.
+const char BLACK[] = "#000";
+
+std::string GetBodyInsertionText(ReaderModePrefs* reader_mode_prefs) {
+ if (reader_mode_prefs->GetHighContrastPref()) {
+ std::string body_insertion_text = "background-color: ";
+ body_insertion_text += BLACK;
+ body_insertion_text += ";\ncolor: ";
+ body_insertion_text += WHITE;
+ body_insertion_text += ";";
+ return body_insertion_text;
+ }
+ else {
+ std::string body_insertion_text = "background-color: ";
+ body_insertion_text += WHITE;
+ body_insertion_text += ";\ncolor: ";
+ body_insertion_text += BLACK;
+ body_insertion_text += ";";
+ return body_insertion_text;
+ }
+}
std::string ReplaceHtmlTemplateValues(
const std::string& title,
@@ -51,6 +73,15 @@ std::string ReplaceHtmlTemplateValues(
return ReplaceStringPlaceholders(html_template, substitutions, NULL);
}
+std::string ReplaceCSSTemplateValues(ReaderModePrefs* reader_mode_prefs) {
+ std::vector<std::string> substitutions;
+ substitutions.push_back(GetBodyInsertionText(reader_mode_prefs));
+ base::StringPiece css_template =
+ ResourceBundle::GetSharedInstance().GetRawDataResource(
+ IDR_DISTILLER_CSS);
+ return ReplaceStringPlaceholders(css_template, substitutions, NULL);
+}
+
} // namespace
namespace viewer {
@@ -127,10 +158,8 @@ const std::string GetErrorPageHtml() {
return ReplaceHtmlTemplateValues(title, content, "hidden", "");
}
-const std::string GetCss() {
- return ResourceBundle::GetSharedInstance()
- .GetRawDataResource(IDR_DISTILLER_CSS)
- .as_string();
+const std::string GetCss(ReaderModePrefs* reader_mode_prefs) {
+ return ReplaceCSSTemplateValues(reader_mode_prefs);
}
const std::string GetJavaScript() {

Powered by Google App Engine
This is Rietveld 408576698