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

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

Issue 430473007: Font Family Preferences for Distilled Pages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: synced Created 6 years, 4 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/distilled_page_prefs.cc
diff --git a/components/dom_distiller/core/distilled_page_prefs.cc b/components/dom_distiller/core/distilled_page_prefs.cc
index 5c23fb43f221134fcba473b215f7291a1f605e21..01d1a07c96cea313b4f07fdd378af3febad7fc2f 100644
--- a/components/dom_distiller/core/distilled_page_prefs.cc
+++ b/components/dom_distiller/core/distilled_page_prefs.cc
@@ -14,6 +14,8 @@
namespace {
// Path to the integer corresponding to user's preference theme.
+const char kFontPref[] = "dom_distiller.font_family";
+// Path to the integer corresponding to user's preference font family.
const char kThemePref[] = "dom_distiller.theme";
}
@@ -33,6 +35,31 @@ void DistilledPagePrefs::RegisterProfilePrefs(
kThemePref,
DistilledPagePrefs::LIGHT,
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
+ registry->RegisterIntegerPref(
+ kFontPref,
+ DistilledPagePrefs::SANS_SERIF,
+ user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
+}
+
+void DistilledPagePrefs::SetFontFamily(
+ DistilledPagePrefs::FontFamily new_font_family) {
+ pref_service_->SetInteger(kFontPref, new_font_family);
+ base::MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&DistilledPagePrefs::NotifyOnChangeFontFamily,
+ weak_ptr_factory_.GetWeakPtr(),
+ new_font_family));
+}
+
+DistilledPagePrefs::FontFamily DistilledPagePrefs::GetFontFamily() {
+ int font_family = pref_service_->GetInteger(kFontPref);
+ if (font_family < 0 || font_family >= DistilledPagePrefs::FONT_FAMILY_COUNT) {
+ // Persisted data was incorrect, trying to clean it up by storing the
+ // default.
+ SetFontFamily(DistilledPagePrefs::SANS_SERIF);
+ return DistilledPagePrefs::SANS_SERIF;
+ }
+ return static_cast<FontFamily>(font_family);
}
void DistilledPagePrefs::SetTheme(DistilledPagePrefs::Theme new_theme) {
@@ -52,7 +79,7 @@ DistilledPagePrefs::Theme DistilledPagePrefs::GetTheme() {
SetTheme(DistilledPagePrefs::LIGHT);
return DistilledPagePrefs::LIGHT;
}
- return (Theme) theme;
+ return static_cast<Theme>(theme);
}
void DistilledPagePrefs::AddObserver(Observer* obs) {
@@ -63,6 +90,11 @@ void DistilledPagePrefs::RemoveObserver(Observer* obs) {
observers_.RemoveObserver(obs);
}
+void DistilledPagePrefs::NotifyOnChangeFontFamily(
+ DistilledPagePrefs::FontFamily new_font_family) {
+ FOR_EACH_OBSERVER(Observer, observers_, OnChangeFontFamily(new_font_family));
+}
+
void DistilledPagePrefs::NotifyOnChangeTheme(
DistilledPagePrefs::Theme new_theme) {
FOR_EACH_OBSERVER(Observer, observers_, OnChangeTheme(new_theme));
« no previous file with comments | « components/dom_distiller/core/distilled_page_prefs.h ('k') | components/dom_distiller/core/distilled_page_prefs_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698