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..85dacd82cab9c438c67b3ef27ee9a7837da1e1f7 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" |
@@ -28,6 +29,14 @@ namespace dom_distiller { |
namespace { |
+std::string GetBodyInsertionText(ReaderModePrefs* reader_mode_prefs) { |
+ if (reader_mode_prefs->GetHighContrastPref()) { |
+ return "background-color: #000;\ncolor: #FFF;"; // White on black. |
nyquist
2014/06/24 23:08:49
Could you have this as a CSS class on the document
smaslo
2014/06/26 20:05:38
Done.
|
+ } else { |
+ return "background-color: #FFF;\ncolor: #000;"; // Black on white. |
+ } |
+} |
+ |
std::string ReplaceHtmlTemplateValues( |
const std::string& title, |
const std::string& content, |
@@ -127,10 +136,13 @@ 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) { |
+ 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); |
} |
const std::string GetJavaScript() { |