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..b2f2c62daf0c700910b038595e69ae879717f05c 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,28 @@ namespace dom_distiller { |
namespace { |
+const char kWhite[] = "#FFF"; |
nyquist
2014/06/23 16:03:06
Nit: I think these two can go away if you follow b
smaslo
2014/06/23 22:14:33
Done.
|
+const char kBlack[] = "#000"; |
+ |
+std::string GetBodyInsertionText(ReaderModePrefs* reader_mode_prefs) { |
nyquist
2014/06/23 16:03:06
Is there a way of writing a test to ensure we use
smaslo
2014/06/23 22:14:33
The only way I've heard so far is doing a string t
|
+ if (reader_mode_prefs->GetHighContrastPref()) { |
+ std::string body_insertion_text = "background-color: "; |
+ body_insertion_text += kBlack; |
+ body_insertion_text += ";\ncolor: "; |
+ body_insertion_text += kWhite; |
+ body_insertion_text += ";"; |
+ return body_insertion_text; |
+ } |
+ else { |
+ std::string body_insertion_text = "background-color: "; |
+ body_insertion_text += kWhite; |
+ body_insertion_text += ";\ncolor: "; |
+ body_insertion_text += kBlack; |
+ body_insertion_text += ";"; |
+ return body_insertion_text; |
+ } |
battre
2014/06/23 08:37:23
Opt:
Wouldn't this be more readable if you phrase
smaslo
2014/06/23 22:14:33
Done.
|
+} |
+ |
std::string ReplaceHtmlTemplateValues( |
const std::string& title, |
const std::string& content, |
@@ -51,6 +74,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 +159,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); |
nyquist
2014/06/23 16:03:06
This is only used once, so maybe you could inline
smaslo
2014/06/23 22:14:34
Done.
|
} |
const std::string GetJavaScript() { |