| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 SetUpFixedFontSample(); | 74 SetUpFixedFontSample(); |
| 75 SetUpMinimumFontSample(); | 75 SetUpMinimumFontSample(); |
| 76 } | 76 } |
| 77 | 77 |
| 78 void FontSettingsHandler::RegisterMessages() { | 78 void FontSettingsHandler::RegisterMessages() { |
| 79 // Perform validation for saved fonts. | 79 // Perform validation for saved fonts. |
| 80 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); | 80 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
| 81 FontSettingsUtilities::ValidateSavedFonts(pref_service); | 81 FontSettingsUtilities::ValidateSavedFonts(pref_service); |
| 82 | 82 |
| 83 // Register for preferences that we need to observe manually. | 83 // Register for preferences that we need to observe manually. |
| 84 standard_font_.Init(prefs::kWebKitStandardFontFamily, pref_service, this); | 84 standard_font_.Init(prefs::kWebKitGlobalStandardFontFamily, |
| 85 serif_font_.Init(prefs::kWebKitSerifFontFamily, pref_service, this); | 85 pref_service, this); |
| 86 sans_serif_font_.Init(prefs::kWebKitSansSerifFontFamily, pref_service, this); | 86 serif_font_.Init(prefs::kWebKitGlobalSerifFontFamily, pref_service, this); |
| 87 fixed_font_.Init(prefs::kWebKitFixedFontFamily, pref_service, this); | 87 sans_serif_font_.Init(prefs::kWebKitGlobalSansSerifFontFamily, |
| 88 font_encoding_.Init(prefs::kDefaultCharset, pref_service, this); | 88 pref_service, this); |
| 89 default_font_size_.Init(prefs::kWebKitDefaultFontSize, pref_service, this); | 89 fixed_font_.Init(prefs::kWebKitGlobalFixedFontFamily, pref_service, this); |
| 90 default_fixed_font_size_.Init(prefs::kWebKitDefaultFixedFontSize, | 90 font_encoding_.Init(prefs::kGlobalDefaultCharset, pref_service, this); |
| 91 default_font_size_.Init(prefs::kWebKitGlobalDefaultFontSize, |
| 92 pref_service, this); |
| 93 default_fixed_font_size_.Init(prefs::kWebKitGlobalDefaultFixedFontSize, |
| 91 pref_service, this); | 94 pref_service, this); |
| 92 minimum_font_size_.Init(prefs::kWebKitMinimumFontSize, pref_service, this); | 95 minimum_font_size_.Init(prefs::kWebKitGlobalMinimumFontSize, |
| 96 pref_service, this); |
| 93 | 97 |
| 94 web_ui()->RegisterMessageCallback("fetchFontsData", | 98 web_ui()->RegisterMessageCallback("fetchFontsData", |
| 95 base::Bind(&FontSettingsHandler::HandleFetchFontsData, | 99 base::Bind(&FontSettingsHandler::HandleFetchFontsData, |
| 96 base::Unretained(this))); | 100 base::Unretained(this))); |
| 97 } | 101 } |
| 98 | 102 |
| 99 void FontSettingsHandler::HandleFetchFontsData(const ListValue* args) { | 103 void FontSettingsHandler::HandleFetchFontsData(const ListValue* args) { |
| 100 content::GetFontListAsync( | 104 content::GetFontListAsync( |
| 101 base::Bind(&FontSettingsHandler::FontsListHasLoaded, | 105 base::Bind(&FontSettingsHandler::FontsListHasLoaded, |
| 102 base::Unretained(this))); | 106 base::Unretained(this))); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 web_ui()->CallJavascriptFunction("FontSettings.setFontsData", | 147 web_ui()->CallJavascriptFunction("FontSettings.setFontsData", |
| 144 *list->list.get(), encoding_list, | 148 *list->list.get(), encoding_list, |
| 145 selected_values); | 149 selected_values); |
| 146 } | 150 } |
| 147 | 151 |
| 148 void FontSettingsHandler::Observe(int type, | 152 void FontSettingsHandler::Observe(int type, |
| 149 const content::NotificationSource& source, | 153 const content::NotificationSource& source, |
| 150 const content::NotificationDetails& details) { | 154 const content::NotificationDetails& details) { |
| 151 if (type == chrome::NOTIFICATION_PREF_CHANGED) { | 155 if (type == chrome::NOTIFICATION_PREF_CHANGED) { |
| 152 std::string* pref_name = content::Details<std::string>(details).ptr(); | 156 std::string* pref_name = content::Details<std::string>(details).ptr(); |
| 153 if (*pref_name == prefs::kWebKitStandardFontFamily) { | 157 if (*pref_name == prefs::kWebKitGlobalStandardFontFamily) { |
| 154 SetUpStandardFontSample(); | 158 SetUpStandardFontSample(); |
| 155 } else if (*pref_name == prefs::kWebKitSerifFontFamily) { | 159 } else if (*pref_name == prefs::kWebKitGlobalSerifFontFamily) { |
| 156 SetUpSerifFontSample(); | 160 SetUpSerifFontSample(); |
| 157 } else if (*pref_name == prefs::kWebKitSansSerifFontFamily) { | 161 } else if (*pref_name == prefs::kWebKitGlobalSansSerifFontFamily) { |
| 158 SetUpSansSerifFontSample(); | 162 SetUpSansSerifFontSample(); |
| 159 } else if (*pref_name == prefs::kWebKitFixedFontFamily || | 163 } else if (*pref_name == prefs::kWebKitGlobalFixedFontFamily || |
| 160 *pref_name == prefs::kWebKitDefaultFixedFontSize) { | 164 *pref_name == prefs::kWebKitGlobalDefaultFixedFontSize) { |
| 161 SetUpFixedFontSample(); | 165 SetUpFixedFontSample(); |
| 162 } else if (*pref_name == prefs::kWebKitDefaultFontSize) { | 166 } else if (*pref_name == prefs::kWebKitGlobalDefaultFontSize) { |
| 163 SetUpStandardFontSample(); | 167 SetUpStandardFontSample(); |
| 164 SetUpSerifFontSample(); | 168 SetUpSerifFontSample(); |
| 165 SetUpSansSerifFontSample(); | 169 SetUpSansSerifFontSample(); |
| 166 } else if (*pref_name == prefs::kWebKitMinimumFontSize) { | 170 } else if (*pref_name == prefs::kWebKitGlobalMinimumFontSize) { |
| 167 SetUpMinimumFontSample(); | 171 SetUpMinimumFontSample(); |
| 168 } | 172 } |
| 169 } | 173 } |
| 170 } | 174 } |
| 171 | 175 |
| 172 void FontSettingsHandler::SetUpStandardFontSample() { | 176 void FontSettingsHandler::SetUpStandardFontSample() { |
| 173 base::StringValue font_value(standard_font_.GetValue()); | 177 base::StringValue font_value(standard_font_.GetValue()); |
| 174 base::FundamentalValue size_value(default_font_size_.GetValue()); | 178 base::FundamentalValue size_value(default_font_size_.GetValue()); |
| 175 web_ui()->CallJavascriptFunction( | 179 web_ui()->CallJavascriptFunction( |
| 176 "FontSettings.setUpStandardFontSample", font_value, size_value); | 180 "FontSettings.setUpStandardFontSample", font_value, size_value); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 197 "FontSettings.setUpFixedFontSample", font_value, size_value); | 201 "FontSettings.setUpFixedFontSample", font_value, size_value); |
| 198 } | 202 } |
| 199 | 203 |
| 200 void FontSettingsHandler::SetUpMinimumFontSample() { | 204 void FontSettingsHandler::SetUpMinimumFontSample() { |
| 201 base::FundamentalValue size_value(minimum_font_size_.GetValue()); | 205 base::FundamentalValue size_value(minimum_font_size_.GetValue()); |
| 202 web_ui()->CallJavascriptFunction("FontSettings.setUpMinimumFontSample", | 206 web_ui()->CallJavascriptFunction("FontSettings.setUpMinimumFontSample", |
| 203 size_value); | 207 size_value); |
| 204 } | 208 } |
| 205 | 209 |
| 206 } // namespace options2 | 210 } // namespace options2 |
| OLD | NEW |