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

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

Issue 6602021: web-ui settings: Standard font setting now correlates to WebKit's standard fo... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: rebase Created 9 years, 9 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
« no previous file with comments | « chrome/browser/ui/webui/options/font_settings_handler.h ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 RegisterStrings(localized_strings, resources, arraysize(resources)); 61 RegisterStrings(localized_strings, resources, arraysize(resources));
62 RegisterTitle(localized_strings, "fontSettingsPage", 62 RegisterTitle(localized_strings, "fontSettingsPage",
63 IDS_FONT_LANGUAGE_SETTING_FONT_TAB_TITLE); 63 IDS_FONT_LANGUAGE_SETTING_FONT_TAB_TITLE);
64 localized_strings->SetString("fontSettingsPlaceholder", 64 localized_strings->SetString("fontSettingsPlaceholder",
65 l10n_util::GetStringUTF16( 65 l10n_util::GetStringUTF16(
66 IDS_FONT_LANGUAGE_SETTING_PLACEHOLDER)); 66 IDS_FONT_LANGUAGE_SETTING_PLACEHOLDER));
67 } 67 }
68 68
69 void FontSettingsHandler::Initialize() { 69 void FontSettingsHandler::Initialize() {
70 DCHECK(web_ui_); 70 DCHECK(web_ui_);
71 SetupSerifFontSample(); 71 SetupStandardFontSample();
72 SetupMinimumFontSample(); 72 SetupMinimumFontSample();
73 SetupFixedFontSample(); 73 SetupFixedFontSample();
74 } 74 }
75 75
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 = web_ui_->GetProfile()->GetPrefs(); 82 PrefService* pref_service = web_ui_->GetProfile()->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 serif_font_.Init(prefs::kWebKitSerifFontFamily, pref_service, this); 86 standard_font_.Init(prefs::kWebKitStandardFontFamily, pref_service, this);
87 fixed_font_.Init(prefs::kWebKitFixedFontFamily, pref_service, this); 87 fixed_font_.Init(prefs::kWebKitFixedFontFamily, pref_service, this);
88 font_encoding_.Init(prefs::kDefaultCharset, pref_service, this); 88 font_encoding_.Init(prefs::kDefaultCharset, pref_service, this);
89 default_font_size_.Init(prefs::kWebKitDefaultFontSize, pref_service, this); 89 default_font_size_.Init(prefs::kWebKitDefaultFontSize, pref_service, this);
90 default_fixed_font_size_.Init(prefs::kWebKitDefaultFixedFontSize, 90 default_fixed_font_size_.Init(prefs::kWebKitDefaultFixedFontSize,
91 pref_service, this); 91 pref_service, this);
92 minimum_font_size_.Init(prefs::kWebKitMinimumFontSize, pref_service, this); 92 minimum_font_size_.Init(prefs::kWebKitMinimumFontSize, pref_service, this);
93 93
94 // Return result from the superclass. 94 // Return result from the superclass.
95 return handler; 95 return handler;
96 } 96 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 option->Append(Value::CreateStringValue(name)); 130 option->Append(Value::CreateStringValue(name));
131 } else { 131 } else {
132 // Add empty name/value to indicate a separator item. 132 // Add empty name/value to indicate a separator item.
133 option->Append(Value::CreateStringValue("")); 133 option->Append(Value::CreateStringValue(""));
134 option->Append(Value::CreateStringValue("")); 134 option->Append(Value::CreateStringValue(""));
135 } 135 }
136 encoding_list.Append(option); 136 encoding_list.Append(option);
137 } 137 }
138 138
139 ListValue selected_values; 139 ListValue selected_values;
140 selected_values.Append(Value::CreateStringValue(serif_font_.GetValue())); 140 selected_values.Append(Value::CreateStringValue(standard_font_.GetValue()));
141 selected_values.Append(Value::CreateStringValue(fixed_font_.GetValue())); 141 selected_values.Append(Value::CreateStringValue(fixed_font_.GetValue()));
142 selected_values.Append(Value::CreateStringValue(font_encoding_.GetValue())); 142 selected_values.Append(Value::CreateStringValue(font_encoding_.GetValue()));
143 143
144 web_ui_->CallJavascriptFunction(L"FontSettings.setFontsData", 144 web_ui_->CallJavascriptFunction(L"FontSettings.setFontsData",
145 *fonts_list, encoding_list, selected_values); 145 *fonts_list, encoding_list, selected_values);
146 } 146 }
147 147
148 void FontSettingsHandler::Observe(NotificationType type, 148 void FontSettingsHandler::Observe(NotificationType type,
149 const NotificationSource& source, 149 const NotificationSource& source,
150 const NotificationDetails& details) { 150 const NotificationDetails& details) {
151 if (type == NotificationType::PREF_CHANGED) { 151 if (type == NotificationType::PREF_CHANGED) {
152 std::string* pref_name = Details<std::string>(details).ptr(); 152 std::string* pref_name = Details<std::string>(details).ptr();
153 if (*pref_name == prefs::kWebKitSerifFontFamily || 153 if (*pref_name == prefs::kWebKitStandardFontFamily ||
154 *pref_name == prefs::kWebKitDefaultFontSize) { 154 *pref_name == prefs::kWebKitDefaultFontSize) {
155 SetupSerifFontSample(); 155 SetupStandardFontSample();
156 } else if (*pref_name == prefs::kWebKitFixedFontFamily || 156 } else if (*pref_name == prefs::kWebKitFixedFontFamily ||
157 *pref_name == prefs::kWebKitDefaultFixedFontSize) { 157 *pref_name == prefs::kWebKitDefaultFixedFontSize) {
158 SetupFixedFontSample(); 158 SetupFixedFontSample();
159 } else if (*pref_name == prefs::kWebKitMinimumFontSize) { 159 } else if (*pref_name == prefs::kWebKitMinimumFontSize) {
160 SetupMinimumFontSample(); 160 SetupMinimumFontSample();
161 } 161 }
162 } 162 }
163 } 163 }
164 164
165 void FontSettingsHandler::SetupSerifFontSample() { 165 void FontSettingsHandler::SetupStandardFontSample() {
166 StringValue font_value(serif_font_.GetValue()); 166 StringValue font_value(standard_font_.GetValue());
167 FundamentalValue size_value(default_font_size_.GetValue()); 167 FundamentalValue size_value(default_font_size_.GetValue());
168 web_ui_->CallJavascriptFunction( 168 web_ui_->CallJavascriptFunction(
169 L"FontSettings.setupSerifFontSample", font_value, size_value); 169 L"FontSettings.setupStandardFontSample", font_value, size_value);
170 } 170 }
171 171
172 void FontSettingsHandler::SetupFixedFontSample() { 172 void FontSettingsHandler::SetupFixedFontSample() {
173 StringValue font_value(fixed_font_.GetValue()); 173 StringValue font_value(fixed_font_.GetValue());
174 FundamentalValue size_value(default_fixed_font_size_.GetValue()); 174 FundamentalValue size_value(default_fixed_font_size_.GetValue());
175 web_ui_->CallJavascriptFunction( 175 web_ui_->CallJavascriptFunction(
176 L"FontSettings.setupFixedFontSample", font_value, size_value); 176 L"FontSettings.setupFixedFontSample", font_value, size_value);
177 } 177 }
178 178
179 void FontSettingsHandler::SetupMinimumFontSample() { 179 void FontSettingsHandler::SetupMinimumFontSample() {
180 FundamentalValue size_value(minimum_font_size_.GetValue()); 180 FundamentalValue size_value(minimum_font_size_.GetValue());
181 web_ui_->CallJavascriptFunction( 181 web_ui_->CallJavascriptFunction(
182 L"FontSettings.setupMinimumFontSample", size_value); 182 L"FontSettings.setupMinimumFontSample", size_value);
183 } 183 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/font_settings_handler.h ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698