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/options/font_settings_handler.h" | 5 #include "chrome/browser/ui/webui/options/font_settings_handler.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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 sans_serif_font_.GetValue()))); | 180 sans_serif_font_.GetValue()))); |
181 selected_values.Append(Value::CreateStringValue(MaybeGetLocalizedFontName( | 181 selected_values.Append(Value::CreateStringValue(MaybeGetLocalizedFontName( |
182 fixed_font_.GetValue()))); | 182 fixed_font_.GetValue()))); |
183 selected_values.Append(Value::CreateStringValue(font_encoding_.GetValue())); | 183 selected_values.Append(Value::CreateStringValue(font_encoding_.GetValue())); |
184 | 184 |
185 web_ui()->CallJavascriptFunction("FontSettings.setFontsData", | 185 web_ui()->CallJavascriptFunction("FontSettings.setFontsData", |
186 *list.get(), encoding_list, | 186 *list.get(), encoding_list, |
187 selected_values); | 187 selected_values); |
188 } | 188 } |
189 | 189 |
190 void FontSettingsHandler::Observe(int type, | 190 void FontSettingsHandler::OnPreferenceChanged(PrefServiceBase* service, |
191 const content::NotificationSource& source, | 191 const std::string& pref_name) { |
192 const content::NotificationDetails& details) { | 192 if (pref_name == prefs::kWebKitStandardFontFamily) { |
193 if (type == chrome::NOTIFICATION_PREF_CHANGED) { | 193 SetUpStandardFontSample(); |
194 std::string* pref_name = content::Details<std::string>(details).ptr(); | 194 } else if (pref_name == prefs::kWebKitSerifFontFamily) { |
195 if (*pref_name == prefs::kWebKitStandardFontFamily) { | 195 SetUpSerifFontSample(); |
196 SetUpStandardFontSample(); | 196 } else if (pref_name == prefs::kWebKitSansSerifFontFamily) { |
197 } else if (*pref_name == prefs::kWebKitSerifFontFamily) { | 197 SetUpSansSerifFontSample(); |
198 SetUpSerifFontSample(); | 198 } else if (pref_name == prefs::kWebKitFixedFontFamily || |
199 } else if (*pref_name == prefs::kWebKitSansSerifFontFamily) { | 199 pref_name == prefs::kWebKitDefaultFixedFontSize) { |
200 SetUpSansSerifFontSample(); | 200 SetUpFixedFontSample(); |
201 } else if (*pref_name == prefs::kWebKitFixedFontFamily || | 201 } else if (pref_name == prefs::kWebKitDefaultFontSize) { |
202 *pref_name == prefs::kWebKitDefaultFixedFontSize) { | 202 SetUpStandardFontSample(); |
203 SetUpFixedFontSample(); | 203 SetUpSerifFontSample(); |
204 } else if (*pref_name == prefs::kWebKitDefaultFontSize) { | 204 SetUpSansSerifFontSample(); |
205 SetUpStandardFontSample(); | 205 } else if (pref_name == prefs::kWebKitMinimumFontSize) { |
206 SetUpSerifFontSample(); | 206 SetUpMinimumFontSample(); |
207 SetUpSansSerifFontSample(); | |
208 } else if (*pref_name == prefs::kWebKitMinimumFontSize) { | |
209 SetUpMinimumFontSample(); | |
210 } | |
211 } | 207 } |
212 } | 208 } |
213 | 209 |
214 void FontSettingsHandler::SetUpStandardFontSample() { | 210 void FontSettingsHandler::SetUpStandardFontSample() { |
215 base::StringValue font_value(standard_font_.GetValue()); | 211 base::StringValue font_value(standard_font_.GetValue()); |
216 base::FundamentalValue size_value(default_font_size_.GetValue()); | 212 base::FundamentalValue size_value(default_font_size_.GetValue()); |
217 web_ui()->CallJavascriptFunction( | 213 web_ui()->CallJavascriptFunction( |
218 "FontSettings.setUpStandardFontSample", font_value, size_value); | 214 "FontSettings.setUpStandardFontSample", font_value, size_value); |
219 } | 215 } |
220 | 216 |
(...skipping 18 matching lines...) Expand all Loading... |
239 "FontSettings.setUpFixedFontSample", font_value, size_value); | 235 "FontSettings.setUpFixedFontSample", font_value, size_value); |
240 } | 236 } |
241 | 237 |
242 void FontSettingsHandler::SetUpMinimumFontSample() { | 238 void FontSettingsHandler::SetUpMinimumFontSample() { |
243 base::FundamentalValue size_value(minimum_font_size_.GetValue()); | 239 base::FundamentalValue size_value(minimum_font_size_.GetValue()); |
244 web_ui()->CallJavascriptFunction("FontSettings.setUpMinimumFontSample", | 240 web_ui()->CallJavascriptFunction("FontSettings.setUpMinimumFontSample", |
245 size_value); | 241 size_value); |
246 } | 242 } |
247 | 243 |
248 } // namespace options | 244 } // namespace options |
OLD | NEW |