| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 selected_values.AppendString( | 201 selected_values.AppendString( |
| 202 FontSettingsUtilities::MaybeGetLocalizedFontName(fixed_font_.GetValue())); | 202 FontSettingsUtilities::MaybeGetLocalizedFontName(fixed_font_.GetValue())); |
| 203 | 203 |
| 204 web_ui()->CallJavascriptFunctionUnsafe( | 204 web_ui()->CallJavascriptFunctionUnsafe( |
| 205 "FontSettings.setFontsData", *list.get(), selected_values); | 205 "FontSettings.setFontsData", *list.get(), selected_values); |
| 206 } | 206 } |
| 207 | 207 |
| 208 void FontSettingsHandler::SetUpStandardFontSample() { | 208 void FontSettingsHandler::SetUpStandardFontSample() { |
| 209 base::StringValue font_value( | 209 base::StringValue font_value( |
| 210 FontSettingsUtilities::ResolveFontList(standard_font_.GetValue())); | 210 FontSettingsUtilities::ResolveFontList(standard_font_.GetValue())); |
| 211 base::FundamentalValue size_value(default_font_size_.GetValue()); | 211 base::Value size_value(default_font_size_.GetValue()); |
| 212 web_ui()->CallJavascriptFunctionUnsafe("FontSettings.setUpStandardFontSample", | 212 web_ui()->CallJavascriptFunctionUnsafe("FontSettings.setUpStandardFontSample", |
| 213 font_value, size_value); | 213 font_value, size_value); |
| 214 } | 214 } |
| 215 | 215 |
| 216 void FontSettingsHandler::SetUpSerifFontSample() { | 216 void FontSettingsHandler::SetUpSerifFontSample() { |
| 217 base::StringValue font_value( | 217 base::StringValue font_value( |
| 218 FontSettingsUtilities::ResolveFontList(serif_font_.GetValue())); | 218 FontSettingsUtilities::ResolveFontList(serif_font_.GetValue())); |
| 219 base::FundamentalValue size_value(default_font_size_.GetValue()); | 219 base::Value size_value(default_font_size_.GetValue()); |
| 220 web_ui()->CallJavascriptFunctionUnsafe("FontSettings.setUpSerifFontSample", | 220 web_ui()->CallJavascriptFunctionUnsafe("FontSettings.setUpSerifFontSample", |
| 221 font_value, size_value); | 221 font_value, size_value); |
| 222 } | 222 } |
| 223 | 223 |
| 224 void FontSettingsHandler::SetUpSansSerifFontSample() { | 224 void FontSettingsHandler::SetUpSansSerifFontSample() { |
| 225 base::StringValue font_value( | 225 base::StringValue font_value( |
| 226 FontSettingsUtilities::ResolveFontList(sans_serif_font_.GetValue())); | 226 FontSettingsUtilities::ResolveFontList(sans_serif_font_.GetValue())); |
| 227 base::FundamentalValue size_value(default_font_size_.GetValue()); | 227 base::Value size_value(default_font_size_.GetValue()); |
| 228 web_ui()->CallJavascriptFunctionUnsafe( | 228 web_ui()->CallJavascriptFunctionUnsafe( |
| 229 "FontSettings.setUpSansSerifFontSample", font_value, size_value); | 229 "FontSettings.setUpSansSerifFontSample", font_value, size_value); |
| 230 } | 230 } |
| 231 | 231 |
| 232 void FontSettingsHandler::SetUpFixedFontSample() { | 232 void FontSettingsHandler::SetUpFixedFontSample() { |
| 233 base::StringValue font_value( | 233 base::StringValue font_value( |
| 234 FontSettingsUtilities::ResolveFontList(fixed_font_.GetValue())); | 234 FontSettingsUtilities::ResolveFontList(fixed_font_.GetValue())); |
| 235 base::FundamentalValue size_value(default_fixed_font_size_.GetValue()); | 235 base::Value size_value(default_fixed_font_size_.GetValue()); |
| 236 web_ui()->CallJavascriptFunctionUnsafe("FontSettings.setUpFixedFontSample", | 236 web_ui()->CallJavascriptFunctionUnsafe("FontSettings.setUpFixedFontSample", |
| 237 font_value, size_value); | 237 font_value, size_value); |
| 238 } | 238 } |
| 239 | 239 |
| 240 void FontSettingsHandler::SetUpMinimumFontSample() { | 240 void FontSettingsHandler::SetUpMinimumFontSample() { |
| 241 base::FundamentalValue size_value(minimum_font_size_.GetValue()); | 241 base::Value size_value(minimum_font_size_.GetValue()); |
| 242 web_ui()->CallJavascriptFunctionUnsafe("FontSettings.setUpMinimumFontSample", | 242 web_ui()->CallJavascriptFunctionUnsafe("FontSettings.setUpMinimumFontSample", |
| 243 size_value); | 243 size_value); |
| 244 } | 244 } |
| 245 | 245 |
| 246 const extensions::Extension* | 246 const extensions::Extension* |
| 247 FontSettingsHandler::GetAdvancedFontSettingsExtension() { | 247 FontSettingsHandler::GetAdvancedFontSettingsExtension() { |
| 248 Profile* profile = Profile::FromWebUI(web_ui()); | 248 Profile* profile = Profile::FromWebUI(web_ui()); |
| 249 ExtensionService* service = | 249 ExtensionService* service = |
| 250 extensions::ExtensionSystem::Get(profile)->extension_service(); | 250 extensions::ExtensionSystem::Get(profile)->extension_service(); |
| 251 if (!service->IsExtensionEnabled(kAdvancedFontSettingsExtensionId)) | 251 if (!service->IsExtensionEnabled(kAdvancedFontSettingsExtensionId)) |
| 252 return NULL; | 252 return NULL; |
| 253 return service->GetInstalledExtension(kAdvancedFontSettingsExtensionId); | 253 return service->GetInstalledExtension(kAdvancedFontSettingsExtensionId); |
| 254 } | 254 } |
| 255 | 255 |
| 256 void FontSettingsHandler::NotifyAdvancedFontSettingsAvailability() { | 256 void FontSettingsHandler::NotifyAdvancedFontSettingsAvailability() { |
| 257 web_ui()->CallJavascriptFunctionUnsafe( | 257 web_ui()->CallJavascriptFunctionUnsafe( |
| 258 "FontSettings.notifyAdvancedFontSettingsAvailability", | 258 "FontSettings.notifyAdvancedFontSettingsAvailability", |
| 259 base::FundamentalValue(GetAdvancedFontSettingsExtension() != NULL)); | 259 base::Value(GetAdvancedFontSettingsExtension() != NULL)); |
| 260 } | 260 } |
| 261 | 261 |
| 262 void FontSettingsHandler::HandleOpenAdvancedFontSettingsOptions( | 262 void FontSettingsHandler::HandleOpenAdvancedFontSettingsOptions( |
| 263 const base::ListValue* args) { | 263 const base::ListValue* args) { |
| 264 const extensions::Extension* extension = GetAdvancedFontSettingsExtension(); | 264 const extensions::Extension* extension = GetAdvancedFontSettingsExtension(); |
| 265 if (!extension) | 265 if (!extension) |
| 266 return; | 266 return; |
| 267 extensions::ExtensionTabUtil::OpenOptionsPage(extension, | 267 extensions::ExtensionTabUtil::OpenOptionsPage(extension, |
| 268 chrome::FindBrowserWithWebContents(web_ui()->GetWebContents())); | 268 chrome::FindBrowserWithWebContents(web_ui()->GetWebContents())); |
| 269 } | 269 } |
| 270 | 270 |
| 271 void FontSettingsHandler::OnWebKitDefaultFontSizeChanged() { | 271 void FontSettingsHandler::OnWebKitDefaultFontSizeChanged() { |
| 272 SetUpStandardFontSample(); | 272 SetUpStandardFontSample(); |
| 273 SetUpSerifFontSample(); | 273 SetUpSerifFontSample(); |
| 274 SetUpSansSerifFontSample(); | 274 SetUpSansSerifFontSample(); |
| 275 } | 275 } |
| 276 | 276 |
| 277 } // namespace options | 277 } // namespace options |
| OLD | NEW |