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

Side by Side Diff: chrome/browser/ui/webui/options/font_settings_handler.cc

Issue 8879016: Add more per-tab preferences. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed "migration done" preference Created 9 years 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) 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/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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 WebUIMessageHandler* FontSettingsHandler::Attach(WebUI* web_ui) { 76 WebUIMessageHandler* FontSettingsHandler::Attach(WebUI* web_ui) {
77 // Call through to superclass. 77 // Call through to superclass.
78 WebUIMessageHandler* handler = OptionsPageUIHandler::Attach(web_ui); 78 WebUIMessageHandler* handler = OptionsPageUIHandler::Attach(web_ui);
79 79
80 // Perform validation for saved fonts. 80 // Perform validation for saved fonts.
81 DCHECK(web_ui_); 81 DCHECK(web_ui_);
82 PrefService* pref_service = Profile::FromWebUI(web_ui_)->GetPrefs(); 82 PrefService* pref_service = Profile::FromWebUI(web_ui_)->GetPrefs();
83 FontSettingsUtilities::ValidateSavedFonts(pref_service); 83 FontSettingsUtilities::ValidateSavedFonts(pref_service);
84 84
85 // Register for preferences that we need to observe manually. 85 // Register for preferences that we need to observe manually.
86 standard_font_.Init(prefs::kWebKitStandardFontFamily, pref_service, this); 86 standard_font_.Init(prefs::kWebKitGlobalStandardFontFamily,
87 serif_font_.Init(prefs::kWebKitSerifFontFamily, pref_service, this); 87 pref_service, this);
88 sans_serif_font_.Init(prefs::kWebKitSansSerifFontFamily, pref_service, this); 88 serif_font_.Init(prefs::kWebKitGlobalSerifFontFamily, pref_service, this);
89 fixed_font_.Init(prefs::kWebKitFixedFontFamily, pref_service, this); 89 sans_serif_font_.Init(prefs::kWebKitGlobalSansSerifFontFamily,
90 font_encoding_.Init(prefs::kDefaultCharset, pref_service, this); 90 pref_service, this);
91 default_font_size_.Init(prefs::kWebKitDefaultFontSize, pref_service, this); 91 fixed_font_.Init(prefs::kWebKitGlobalFixedFontFamily, pref_service, this);
92 default_fixed_font_size_.Init(prefs::kWebKitDefaultFixedFontSize, 92 font_encoding_.Init(prefs::kGlobalDefaultCharset, pref_service, this);
93 default_font_size_.Init(prefs::kWebKitGlobalDefaultFontSize,
94 pref_service, this);
95 default_fixed_font_size_.Init(prefs::kWebKitGlobalDefaultFixedFontSize,
93 pref_service, this); 96 pref_service, this);
94 minimum_font_size_.Init(prefs::kWebKitMinimumFontSize, pref_service, this); 97 minimum_font_size_.Init(prefs::kWebKitGlobalMinimumFontSize,
98 pref_service, this);
95 99
96 // Return result from the superclass. 100 // Return result from the superclass.
97 return handler; 101 return handler;
98 } 102 }
99 103
100 void FontSettingsHandler::RegisterMessages() { 104 void FontSettingsHandler::RegisterMessages() {
101 web_ui_->RegisterMessageCallback("fetchFontsData", 105 web_ui_->RegisterMessageCallback("fetchFontsData",
102 base::Bind(&FontSettingsHandler::HandleFetchFontsData, 106 base::Bind(&FontSettingsHandler::HandleFetchFontsData,
103 base::Unretained(this))); 107 base::Unretained(this)));
104 } 108 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 web_ui_->CallJavascriptFunction("FontSettings.setFontsData", 154 web_ui_->CallJavascriptFunction("FontSettings.setFontsData",
151 *list->list.get(), encoding_list, 155 *list->list.get(), encoding_list,
152 selected_values); 156 selected_values);
153 } 157 }
154 158
155 void FontSettingsHandler::Observe(int type, 159 void FontSettingsHandler::Observe(int type,
156 const content::NotificationSource& source, 160 const content::NotificationSource& source,
157 const content::NotificationDetails& details) { 161 const content::NotificationDetails& details) {
158 if (type == chrome::NOTIFICATION_PREF_CHANGED) { 162 if (type == chrome::NOTIFICATION_PREF_CHANGED) {
159 std::string* pref_name = content::Details<std::string>(details).ptr(); 163 std::string* pref_name = content::Details<std::string>(details).ptr();
160 if (*pref_name == prefs::kWebKitStandardFontFamily) { 164 if (*pref_name == prefs::kWebKitGlobalStandardFontFamily) {
161 SetUpStandardFontSample(); 165 SetUpStandardFontSample();
162 } else if (*pref_name == prefs::kWebKitSerifFontFamily) { 166 } else if (*pref_name == prefs::kWebKitGlobalSerifFontFamily) {
163 SetUpSerifFontSample(); 167 SetUpSerifFontSample();
164 } else if (*pref_name == prefs::kWebKitSansSerifFontFamily) { 168 } else if (*pref_name == prefs::kWebKitGlobalSansSerifFontFamily) {
165 SetUpSansSerifFontSample(); 169 SetUpSansSerifFontSample();
166 } else if (*pref_name == prefs::kWebKitFixedFontFamily || 170 } else if (*pref_name == prefs::kWebKitGlobalFixedFontFamily ||
167 *pref_name == prefs::kWebKitDefaultFixedFontSize) { 171 *pref_name == prefs::kWebKitGlobalDefaultFixedFontSize) {
168 SetUpFixedFontSample(); 172 SetUpFixedFontSample();
169 } else if (*pref_name == prefs::kWebKitDefaultFontSize) { 173 } else if (*pref_name == prefs::kWebKitGlobalDefaultFontSize) {
170 SetUpStandardFontSample(); 174 SetUpStandardFontSample();
171 SetUpSerifFontSample(); 175 SetUpSerifFontSample();
172 SetUpSansSerifFontSample(); 176 SetUpSansSerifFontSample();
173 } else if (*pref_name == prefs::kWebKitMinimumFontSize) { 177 } else if (*pref_name == prefs::kWebKitGlobalMinimumFontSize) {
174 SetUpMinimumFontSample(); 178 SetUpMinimumFontSample();
175 } 179 }
176 } 180 }
177 } 181 }
178 182
179 void FontSettingsHandler::SetUpStandardFontSample() { 183 void FontSettingsHandler::SetUpStandardFontSample() {
180 base::StringValue font_value(standard_font_.GetValue()); 184 base::StringValue font_value(standard_font_.GetValue());
181 base::FundamentalValue size_value(default_font_size_.GetValue()); 185 base::FundamentalValue size_value(default_font_size_.GetValue());
182 web_ui_->CallJavascriptFunction( 186 web_ui_->CallJavascriptFunction(
183 "FontSettings.setUpStandardFontSample", font_value, size_value); 187 "FontSettings.setUpStandardFontSample", font_value, size_value);
(...skipping 18 matching lines...) Expand all
202 base::FundamentalValue size_value(default_fixed_font_size_.GetValue()); 206 base::FundamentalValue size_value(default_fixed_font_size_.GetValue());
203 web_ui_->CallJavascriptFunction( 207 web_ui_->CallJavascriptFunction(
204 "FontSettings.setUpFixedFontSample", font_value, size_value); 208 "FontSettings.setUpFixedFontSample", font_value, size_value);
205 } 209 }
206 210
207 void FontSettingsHandler::SetUpMinimumFontSample() { 211 void FontSettingsHandler::SetUpMinimumFontSample() {
208 base::FundamentalValue size_value(minimum_font_size_.GetValue()); 212 base::FundamentalValue size_value(minimum_font_size_.GetValue());
209 web_ui_->CallJavascriptFunction("FontSettings.setUpMinimumFontSample", 213 web_ui_->CallJavascriptFunction("FontSettings.setUpMinimumFontSample",
210 size_value); 214 size_value);
211 } 215 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698