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

Unified Diff: chrome/browser/ui/webui/options/font_settings_handler.cc

Issue 11421029: Remove PrefObserver usages, batch 13. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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: chrome/browser/ui/webui/options/font_settings_handler.cc
diff --git a/chrome/browser/ui/webui/options/font_settings_handler.cc b/chrome/browser/ui/webui/options/font_settings_handler.cc
index 22f200e989fa7eceaaac0c9628fe510f6d87d824..0c722eb5fb7a9a884d4ce848f7ee3e670b033730 100644
--- a/chrome/browser/ui/webui/options/font_settings_handler.cc
+++ b/chrome/browser/ui/webui/options/font_settings_handler.cc
@@ -106,15 +106,41 @@ void FontSettingsHandler::RegisterMessages() {
FontSettingsUtilities::ValidateSavedFonts(pref_service);
// Register for preferences that we need to observe manually.
- standard_font_.Init(prefs::kWebKitStandardFontFamily, pref_service, this);
- serif_font_.Init(prefs::kWebKitSerifFontFamily, pref_service, this);
- sans_serif_font_.Init(prefs::kWebKitSansSerifFontFamily, pref_service, this);
- fixed_font_.Init(prefs::kWebKitFixedFontFamily, pref_service, this);
- font_encoding_.Init(prefs::kDefaultCharset, pref_service, this);
- default_font_size_.Init(prefs::kWebKitDefaultFontSize, pref_service, this);
- default_fixed_font_size_.Init(prefs::kWebKitDefaultFixedFontSize,
- pref_service, this);
- minimum_font_size_.Init(prefs::kWebKitMinimumFontSize, pref_service, this);
+ standard_font_.Init(prefs::kWebKitStandardFontFamily,
+ pref_service,
+ base::Bind(&FontSettingsHandler::SetUpStandardFontSample,
+ base::Unretained(this)));
+ serif_font_.Init(prefs::kWebKitSerifFontFamily,
+ pref_service,
+ base::Bind(&FontSettingsHandler::SetUpSerifFontSample,
+ base::Unretained(this)));
+ sans_serif_font_.Init(
+ prefs::kWebKitSansSerifFontFamily,
+ pref_service,
+ base::Bind(&FontSettingsHandler::SetUpSansSerifFontSample,
+ base::Unretained(this)));
+ fixed_font_.Init(prefs::kWebKitFixedFontFamily,
+ pref_service,
+ base::Bind(&FontSettingsHandler::SetUpFixedFontSample,
Jói 2012/11/21 13:37:45 I would group the initialization of fixed_font_ an
tfarina 2012/11/21 13:48:33 Done.
+ base::Unretained(this)));
+ font_encoding_.Init(prefs::kDefaultCharset,
+ pref_service,
+ base::Bind(&base::DoNothing));
Mattias Nissler (ping if slow) 2012/11/21 13:29:26 If we really don't want a change notification call
tfarina 2012/11/21 13:36:24 That was my first attempt. But dropping it causes
Jói 2012/11/21 13:37:45 Agreed we should ask an OWNER.
Jói 2012/11/21 13:52:39 For now, you can pass a NULL as the 3rd argument.
falken 2012/11/21 14:21:45 Right, there's nothing to do when the encoding cha
+ default_font_size_.Init(
+ prefs::kWebKitDefaultFontSize,
+ pref_service,
+ base::Bind(&FontSettingsHandler::OnWebKitDefaultFontSizeChanged,
+ base::Unretained(this)));
+ default_fixed_font_size_.Init(
+ prefs::kWebKitDefaultFixedFontSize,
+ pref_service,
+ base::Bind(&FontSettingsHandler::SetUpFixedFontSample,
+ base::Unretained(this)));
+ minimum_font_size_.Init(
+ prefs::kWebKitMinimumFontSize,
+ pref_service,
+ base::Bind(&FontSettingsHandler::SetUpMinimumFontSample,
+ base::Unretained(this)));
web_ui()->RegisterMessageCallback("fetchFontsData",
base::Bind(&FontSettingsHandler::HandleFetchFontsData,
@@ -187,26 +213,6 @@ void FontSettingsHandler::FontsListHasLoaded(
selected_values);
}
-void FontSettingsHandler::OnPreferenceChanged(PrefServiceBase* service,
- const std::string& pref_name) {
- if (pref_name == prefs::kWebKitStandardFontFamily) {
- SetUpStandardFontSample();
- } else if (pref_name == prefs::kWebKitSerifFontFamily) {
- SetUpSerifFontSample();
- } else if (pref_name == prefs::kWebKitSansSerifFontFamily) {
- SetUpSansSerifFontSample();
- } else if (pref_name == prefs::kWebKitFixedFontFamily ||
- pref_name == prefs::kWebKitDefaultFixedFontSize) {
- SetUpFixedFontSample();
- } else if (pref_name == prefs::kWebKitDefaultFontSize) {
- SetUpStandardFontSample();
- SetUpSerifFontSample();
- SetUpSansSerifFontSample();
- } else if (pref_name == prefs::kWebKitMinimumFontSize) {
- SetUpMinimumFontSample();
- }
-}
-
void FontSettingsHandler::SetUpStandardFontSample() {
base::StringValue font_value(standard_font_.GetValue());
base::FundamentalValue size_value(default_font_size_.GetValue());
@@ -241,4 +247,10 @@ void FontSettingsHandler::SetUpMinimumFontSample() {
size_value);
}
+void FontSettingsHandler::OnWebKitDefaultFontSizeChanged() {
+ SetUpStandardFontSample();
+ SetUpSerifFontSample();
+ SetUpSansSerifFontSample();
+}
+
} // namespace options

Powered by Google App Engine
This is Rietveld 408576698