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

Side by Side Diff: chrome/browser/ui/webui/options2/font_settings_handler2.cc

Issue 10107014: Migrate WebKit "global script" font prefs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 8 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 web_ui()->CallJavascriptFunction("FontSettings.setFontsData", 189 web_ui()->CallJavascriptFunction("FontSettings.setFontsData",
190 *list.get(), encoding_list, 190 *list.get(), encoding_list,
191 selected_values); 191 selected_values);
192 } 192 }
193 193
194 void FontSettingsHandler::Observe(int type, 194 void FontSettingsHandler::Observe(int type,
195 const content::NotificationSource& source, 195 const content::NotificationSource& source,
196 const content::NotificationDetails& details) { 196 const content::NotificationDetails& details) {
197 if (type == chrome::NOTIFICATION_PREF_CHANGED) { 197 if (type == chrome::NOTIFICATION_PREF_CHANGED) {
198 std::string* pref_name = content::Details<std::string>(details).ptr(); 198 std::string* pref_name = content::Details<std::string>(details).ptr();
199 if (*pref_name == prefs::kWebKitGlobalStandardFontFamily) { 199 if (*pref_name == prefs::kWebKitStandardFontFamily) {
200 SetUpStandardFontSample(); 200 SetUpStandardFontSample();
201 } else if (*pref_name == prefs::kWebKitGlobalSerifFontFamily) { 201 } else if (*pref_name == prefs::kWebKitSerifFontFamily) {
202 SetUpSerifFontSample(); 202 SetUpSerifFontSample();
203 } else if (*pref_name == prefs::kWebKitGlobalSansSerifFontFamily) { 203 } else if (*pref_name == prefs::kWebKitSansSerifFontFamily) {
204 SetUpSansSerifFontSample(); 204 SetUpSansSerifFontSample();
205 } else if (*pref_name == prefs::kWebKitGlobalFixedFontFamily || 205 } else if (*pref_name == prefs::kWebKitFixedFontFamily ||
206 *pref_name == prefs::kWebKitGlobalDefaultFixedFontSize) { 206 *pref_name == prefs::kWebKitDefaultFixedFontSize) {
207 SetUpFixedFontSample(); 207 SetUpFixedFontSample();
208 } else if (*pref_name == prefs::kWebKitGlobalDefaultFontSize) { 208 } else if (*pref_name == prefs::kWebKitGlobalDefaultFontSize) {
209 SetUpStandardFontSample(); 209 SetUpStandardFontSample();
210 SetUpSerifFontSample(); 210 SetUpSerifFontSample();
211 SetUpSansSerifFontSample(); 211 SetUpSansSerifFontSample();
212 } else if (*pref_name == prefs::kWebKitGlobalMinimumFontSize) { 212 } else if (*pref_name == prefs::kWebKitGlobalMinimumFontSize) {
213 SetUpMinimumFontSample(); 213 SetUpMinimumFontSample();
214 } 214 }
215 } 215 }
216 } 216 }
(...skipping 26 matching lines...) Expand all
243 "FontSettings.setUpFixedFontSample", font_value, size_value); 243 "FontSettings.setUpFixedFontSample", font_value, size_value);
244 } 244 }
245 245
246 void FontSettingsHandler::SetUpMinimumFontSample() { 246 void FontSettingsHandler::SetUpMinimumFontSample() {
247 base::FundamentalValue size_value(minimum_font_size_.GetValue()); 247 base::FundamentalValue size_value(minimum_font_size_.GetValue());
248 web_ui()->CallJavascriptFunction("FontSettings.setUpMinimumFontSample", 248 web_ui()->CallJavascriptFunction("FontSettings.setUpMinimumFontSample",
249 size_value); 249 size_value);
250 } 250 }
251 251
252 } // namespace options2 252 } // namespace options2
OLDNEW
« no previous file with comments | « chrome/browser/ui/prefs/prefs_tab_helper_browsertest.cc ('k') | chrome/browser/ui/webui/options2/font_settings_utils2_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698