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

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

Issue 10409046: Migrate the rest of the "global" prefs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: style fixes 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::kWebKitStandardFontFamily, 109 standard_font_.Init(prefs::kWebKitStandardFontFamily, pref_service, this);
110 pref_service, this);
111 serif_font_.Init(prefs::kWebKitSerifFontFamily, pref_service, this); 110 serif_font_.Init(prefs::kWebKitSerifFontFamily, pref_service, this);
112 sans_serif_font_.Init(prefs::kWebKitSansSerifFontFamily, 111 sans_serif_font_.Init(prefs::kWebKitSansSerifFontFamily, pref_service, this);
113 pref_service, this);
114 fixed_font_.Init(prefs::kWebKitFixedFontFamily, pref_service, this); 112 fixed_font_.Init(prefs::kWebKitFixedFontFamily, pref_service, this);
115 font_encoding_.Init(prefs::kGlobalDefaultCharset, pref_service, this); 113 font_encoding_.Init(prefs::kDefaultCharset, pref_service, this);
116 default_font_size_.Init(prefs::kWebKitGlobalDefaultFontSize, 114 default_font_size_.Init(prefs::kWebKitDefaultFontSize, pref_service, this);
117 pref_service, this); 115 default_fixed_font_size_.Init(prefs::kWebKitDefaultFixedFontSize,
118 default_fixed_font_size_.Init(prefs::kWebKitGlobalDefaultFixedFontSize,
119 pref_service, this); 116 pref_service, this);
120 minimum_font_size_.Init(prefs::kWebKitGlobalMinimumFontSize, 117 minimum_font_size_.Init(prefs::kWebKitMinimumFontSize, pref_service, this);
121 pref_service, this);
122 118
123 web_ui()->RegisterMessageCallback("fetchFontsData", 119 web_ui()->RegisterMessageCallback("fetchFontsData",
124 base::Bind(&FontSettingsHandler::HandleFetchFontsData, 120 base::Bind(&FontSettingsHandler::HandleFetchFontsData,
125 base::Unretained(this))); 121 base::Unretained(this)));
126 } 122 }
127 123
128 void FontSettingsHandler::HandleFetchFontsData(const ListValue* args) { 124 void FontSettingsHandler::HandleFetchFontsData(const ListValue* args) {
129 content::GetFontListAsync( 125 content::GetFontListAsync(
130 base::Bind(&FontSettingsHandler::FontsListHasLoaded, 126 base::Bind(&FontSettingsHandler::FontsListHasLoaded,
131 base::Unretained(this))); 127 base::Unretained(this)));
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 std::string* pref_name = content::Details<std::string>(details).ptr(); 194 std::string* pref_name = content::Details<std::string>(details).ptr();
199 if (*pref_name == prefs::kWebKitStandardFontFamily) { 195 if (*pref_name == prefs::kWebKitStandardFontFamily) {
200 SetUpStandardFontSample(); 196 SetUpStandardFontSample();
201 } else if (*pref_name == prefs::kWebKitSerifFontFamily) { 197 } else if (*pref_name == prefs::kWebKitSerifFontFamily) {
202 SetUpSerifFontSample(); 198 SetUpSerifFontSample();
203 } else if (*pref_name == prefs::kWebKitSansSerifFontFamily) { 199 } else if (*pref_name == prefs::kWebKitSansSerifFontFamily) {
204 SetUpSansSerifFontSample(); 200 SetUpSansSerifFontSample();
205 } else if (*pref_name == prefs::kWebKitFixedFontFamily || 201 } else if (*pref_name == prefs::kWebKitFixedFontFamily ||
206 *pref_name == prefs::kWebKitDefaultFixedFontSize) { 202 *pref_name == prefs::kWebKitDefaultFixedFontSize) {
207 SetUpFixedFontSample(); 203 SetUpFixedFontSample();
208 } else if (*pref_name == prefs::kWebKitGlobalDefaultFontSize) { 204 } else if (*pref_name == prefs::kWebKitDefaultFontSize) {
209 SetUpStandardFontSample(); 205 SetUpStandardFontSample();
210 SetUpSerifFontSample(); 206 SetUpSerifFontSample();
211 SetUpSansSerifFontSample(); 207 SetUpSansSerifFontSample();
212 } else if (*pref_name == prefs::kWebKitGlobalMinimumFontSize) { 208 } else if (*pref_name == prefs::kWebKitMinimumFontSize) {
213 SetUpMinimumFontSample(); 209 SetUpMinimumFontSample();
214 } 210 }
215 } 211 }
216 } 212 }
217 213
218 void FontSettingsHandler::SetUpStandardFontSample() { 214 void FontSettingsHandler::SetUpStandardFontSample() {
219 base::StringValue font_value(standard_font_.GetValue()); 215 base::StringValue font_value(standard_font_.GetValue());
220 base::FundamentalValue size_value(default_font_size_.GetValue()); 216 base::FundamentalValue size_value(default_font_size_.GetValue());
221 web_ui()->CallJavascriptFunction( 217 web_ui()->CallJavascriptFunction(
222 "FontSettings.setUpStandardFontSample", font_value, size_value); 218 "FontSettings.setUpStandardFontSample", font_value, size_value);
(...skipping 20 matching lines...) Expand all
243 "FontSettings.setUpFixedFontSample", font_value, size_value); 239 "FontSettings.setUpFixedFontSample", font_value, size_value);
244 } 240 }
245 241
246 void FontSettingsHandler::SetUpMinimumFontSample() { 242 void FontSettingsHandler::SetUpMinimumFontSample() {
247 base::FundamentalValue size_value(minimum_font_size_.GetValue()); 243 base::FundamentalValue size_value(minimum_font_size_.GetValue());
248 web_ui()->CallJavascriptFunction("FontSettings.setUpMinimumFontSample", 244 web_ui()->CallJavascriptFunction("FontSettings.setUpMinimumFontSample",
249 size_value); 245 size_value);
250 } 246 }
251 247
252 } // namespace options2 248 } // namespace options2
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698