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 // Font Settings Extension API implementation. | 5 // Font Settings Extension API implementation. |
6 | 6 |
7 #include "chrome/browser/extensions/api/font_settings/font_settings_api.h" | 7 #include "chrome/browser/extensions/api/font_settings/font_settings_api.h" |
8 | 8 |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 | 10 |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 EXTENSION_FUNCTION_VALIDATE(params.get()); | 271 EXTENSION_FUNCTION_VALIDATE(params.get()); |
272 | 272 |
273 std::string pref_path = GetFontNamePrefPath(params->details.generic_family, | 273 std::string pref_path = GetFontNamePrefPath(params->details.generic_family, |
274 params->details.script); | 274 params->details.script); |
275 | 275 |
276 // Ensure |pref_path| really is for a registered font pref. | 276 // Ensure |pref_path| really is for a registered font pref. |
277 EXTENSION_FUNCTION_VALIDATE(profile->GetPrefs()->FindPreference(pref_path)); | 277 EXTENSION_FUNCTION_VALIDATE(profile->GetPrefs()->FindPreference(pref_path)); |
278 | 278 |
279 PreferenceAPI::Get(profile)->SetExtensionControlledPref( | 279 PreferenceAPI::Get(profile)->SetExtensionControlledPref( |
280 extension_id(), pref_path, kExtensionPrefsScopeRegular, | 280 extension_id(), pref_path, kExtensionPrefsScopeRegular, |
281 new base::StringValue(params->details.font_id)); | 281 new base::Value(params->details.font_id)); |
282 return RespondNow(NoArguments()); | 282 return RespondNow(NoArguments()); |
283 } | 283 } |
284 | 284 |
285 bool FontSettingsGetFontListFunction::RunAsync() { | 285 bool FontSettingsGetFontListFunction::RunAsync() { |
286 content::GetFontListAsync( | 286 content::GetFontListAsync( |
287 Bind(&FontSettingsGetFontListFunction::FontListHasLoaded, this)); | 287 Bind(&FontSettingsGetFontListFunction::FontListHasLoaded, this)); |
288 return true; | 288 return true; |
289 } | 289 } |
290 | 290 |
291 void FontSettingsGetFontListFunction::FontListHasLoaded( | 291 void FontSettingsGetFontListFunction::FontListHasLoaded( |
(...skipping 20 matching lines...) Expand all Loading... |
312 } | 312 } |
313 | 313 |
314 std::string localized_name; | 314 std::string localized_name; |
315 if (!font_list_value->GetString(1, &localized_name)) { | 315 if (!font_list_value->GetString(1, &localized_name)) { |
316 NOTREACHED(); | 316 NOTREACHED(); |
317 return false; | 317 return false; |
318 } | 318 } |
319 | 319 |
320 std::unique_ptr<base::DictionaryValue> font_name( | 320 std::unique_ptr<base::DictionaryValue> font_name( |
321 new base::DictionaryValue()); | 321 new base::DictionaryValue()); |
322 font_name->Set(kFontIdKey, new base::StringValue(name)); | 322 font_name->Set(kFontIdKey, new base::Value(name)); |
323 font_name->Set(kDisplayNameKey, new base::StringValue(localized_name)); | 323 font_name->Set(kDisplayNameKey, new base::Value(localized_name)); |
324 result->Append(std::move(font_name)); | 324 result->Append(std::move(font_name)); |
325 } | 325 } |
326 | 326 |
327 SetResult(std::move(result)); | 327 SetResult(std::move(result)); |
328 return true; | 328 return true; |
329 } | 329 } |
330 | 330 |
331 ExtensionFunction::ResponseAction ClearFontPrefExtensionFunction::Run() { | 331 ExtensionFunction::ResponseAction ClearFontPrefExtensionFunction::Run() { |
332 Profile* profile = Profile::FromBrowserContext(browser_context()); | 332 Profile* profile = Profile::FromBrowserContext(browser_context()); |
333 if (profile->IsOffTheRecord()) | 333 if (profile->IsOffTheRecord()) |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 | 429 |
430 const char* FontSettingsSetMinimumFontSizeFunction::GetPrefName() { | 430 const char* FontSettingsSetMinimumFontSizeFunction::GetPrefName() { |
431 return prefs::kWebKitMinimumFontSize; | 431 return prefs::kWebKitMinimumFontSize; |
432 } | 432 } |
433 | 433 |
434 const char* FontSettingsSetMinimumFontSizeFunction::GetKey() { | 434 const char* FontSettingsSetMinimumFontSizeFunction::GetKey() { |
435 return kPixelSizeKey; | 435 return kPixelSizeKey; |
436 } | 436 } |
437 | 437 |
438 } // namespace extensions | 438 } // namespace extensions |
OLD | NEW |