| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/webui/options2/font_settings_handler2.h" | 5 #include "chrome/browser/ui/webui/options2/font_settings_handler2.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 SetUpFixedFontSample(); | 99 SetUpFixedFontSample(); |
| 100 SetUpMinimumFontSample(); | 100 SetUpMinimumFontSample(); |
| 101 } | 101 } |
| 102 | 102 |
| 103 void FontSettingsHandler::RegisterMessages() { | 103 void FontSettingsHandler::RegisterMessages() { |
| 104 // Perform validation for saved fonts. | 104 // Perform validation for saved fonts. |
| 105 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); | 105 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
| 106 FontSettingsUtilities::ValidateSavedFonts(pref_service); | 106 FontSettingsUtilities::ValidateSavedFonts(pref_service); |
| 107 | 107 |
| 108 // Register for preferences that we need to observe manually. | 108 // Register for preferences that we need to observe manually. |
| 109 standard_font_.Init(prefs::kWebKitGlobalStandardFontFamily, | 109 standard_font_.Init(prefs::kWebKitStandardFontFamily, |
| 110 pref_service, this); | 110 pref_service, this); |
| 111 serif_font_.Init(prefs::kWebKitGlobalSerifFontFamily, pref_service, this); | 111 serif_font_.Init(prefs::kWebKitSerifFontFamily, pref_service, this); |
| 112 sans_serif_font_.Init(prefs::kWebKitGlobalSansSerifFontFamily, | 112 sans_serif_font_.Init(prefs::kWebKitSansSerifFontFamily, |
| 113 pref_service, this); | 113 pref_service, this); |
| 114 fixed_font_.Init(prefs::kWebKitGlobalFixedFontFamily, pref_service, this); | 114 fixed_font_.Init(prefs::kWebKitFixedFontFamily, pref_service, this); |
| 115 font_encoding_.Init(prefs::kGlobalDefaultCharset, pref_service, this); | 115 font_encoding_.Init(prefs::kGlobalDefaultCharset, pref_service, this); |
| 116 default_font_size_.Init(prefs::kWebKitGlobalDefaultFontSize, | 116 default_font_size_.Init(prefs::kWebKitGlobalDefaultFontSize, |
| 117 pref_service, this); | 117 pref_service, this); |
| 118 default_fixed_font_size_.Init(prefs::kWebKitGlobalDefaultFixedFontSize, | 118 default_fixed_font_size_.Init(prefs::kWebKitGlobalDefaultFixedFontSize, |
| 119 pref_service, this); | 119 pref_service, this); |
| 120 minimum_font_size_.Init(prefs::kWebKitGlobalMinimumFontSize, | 120 minimum_font_size_.Init(prefs::kWebKitGlobalMinimumFontSize, |
| 121 pref_service, this); | 121 pref_service, this); |
| 122 | 122 |
| 123 web_ui()->RegisterMessageCallback("fetchFontsData", | 123 web_ui()->RegisterMessageCallback("fetchFontsData", |
| 124 base::Bind(&FontSettingsHandler::HandleFetchFontsData, | 124 base::Bind(&FontSettingsHandler::HandleFetchFontsData, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 web_ui()->CallJavascriptFunction("FontSettings.setFontsData", | 176 web_ui()->CallJavascriptFunction("FontSettings.setFontsData", |
| 177 *list.get(), encoding_list, | 177 *list.get(), encoding_list, |
| 178 selected_values); | 178 selected_values); |
| 179 } | 179 } |
| 180 | 180 |
| 181 void FontSettingsHandler::Observe(int type, | 181 void FontSettingsHandler::Observe(int type, |
| 182 const content::NotificationSource& source, | 182 const content::NotificationSource& source, |
| 183 const content::NotificationDetails& details) { | 183 const content::NotificationDetails& details) { |
| 184 if (type == chrome::NOTIFICATION_PREF_CHANGED) { | 184 if (type == chrome::NOTIFICATION_PREF_CHANGED) { |
| 185 std::string* pref_name = content::Details<std::string>(details).ptr(); | 185 std::string* pref_name = content::Details<std::string>(details).ptr(); |
| 186 if (*pref_name == prefs::kWebKitGlobalStandardFontFamily) { | 186 if (*pref_name == prefs::kWebKitStandardFontFamily) { |
| 187 SetUpStandardFontSample(); | 187 SetUpStandardFontSample(); |
| 188 } else if (*pref_name == prefs::kWebKitGlobalSerifFontFamily) { | 188 } else if (*pref_name == prefs::kWebKitSerifFontFamily) { |
| 189 SetUpSerifFontSample(); | 189 SetUpSerifFontSample(); |
| 190 } else if (*pref_name == prefs::kWebKitGlobalSansSerifFontFamily) { | 190 } else if (*pref_name == prefs::kWebKitSansSerifFontFamily) { |
| 191 SetUpSansSerifFontSample(); | 191 SetUpSansSerifFontSample(); |
| 192 } else if (*pref_name == prefs::kWebKitGlobalFixedFontFamily || | 192 } else if (*pref_name == prefs::kWebKitFixedFontFamily || |
| 193 *pref_name == prefs::kWebKitGlobalDefaultFixedFontSize) { | 193 *pref_name == prefs::kWebKitDefaultFixedFontSize) { |
| 194 SetUpFixedFontSample(); | 194 SetUpFixedFontSample(); |
| 195 } else if (*pref_name == prefs::kWebKitGlobalDefaultFontSize) { | 195 } else if (*pref_name == prefs::kWebKitGlobalDefaultFontSize) { |
| 196 SetUpStandardFontSample(); | 196 SetUpStandardFontSample(); |
| 197 SetUpSerifFontSample(); | 197 SetUpSerifFontSample(); |
| 198 SetUpSansSerifFontSample(); | 198 SetUpSansSerifFontSample(); |
| 199 } else if (*pref_name == prefs::kWebKitGlobalMinimumFontSize) { | 199 } else if (*pref_name == prefs::kWebKitGlobalMinimumFontSize) { |
| 200 SetUpMinimumFontSample(); | 200 SetUpMinimumFontSample(); |
| 201 } | 201 } |
| 202 } | 202 } |
| 203 } | 203 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 230 "FontSettings.setUpFixedFontSample", font_value, size_value); | 230 "FontSettings.setUpFixedFontSample", font_value, size_value); |
| 231 } | 231 } |
| 232 | 232 |
| 233 void FontSettingsHandler::SetUpMinimumFontSample() { | 233 void FontSettingsHandler::SetUpMinimumFontSample() { |
| 234 base::FundamentalValue size_value(minimum_font_size_.GetValue()); | 234 base::FundamentalValue size_value(minimum_font_size_.GetValue()); |
| 235 web_ui()->CallJavascriptFunction("FontSettings.setUpMinimumFontSample", | 235 web_ui()->CallJavascriptFunction("FontSettings.setUpMinimumFontSample", |
| 236 size_value); | 236 size_value); |
| 237 } | 237 } |
| 238 | 238 |
| 239 } // namespace options2 | 239 } // namespace options2 |
| OLD | NEW |