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 "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 params->details.script); | 296 params->details.script); |
297 | 297 |
298 // Ensure |pref_path| really is for a registered font pref. | 298 // Ensure |pref_path| really is for a registered font pref. |
299 EXTENSION_FUNCTION_VALIDATE( | 299 EXTENSION_FUNCTION_VALIDATE( |
300 profile_->GetPrefs()->FindPreference(pref_path.c_str())); | 300 profile_->GetPrefs()->FindPreference(pref_path.c_str())); |
301 | 301 |
302 PreferenceAPI::Get(profile_)->SetExtensionControlledPref( | 302 PreferenceAPI::Get(profile_)->SetExtensionControlledPref( |
303 extension_id(), | 303 extension_id(), |
304 pref_path.c_str(), | 304 pref_path.c_str(), |
305 kExtensionPrefsScopeRegular, | 305 kExtensionPrefsScopeRegular, |
306 Value::CreateStringValue(params->details.font_id)); | 306 new base::StringValue(params->details.font_id)); |
307 return true; | 307 return true; |
308 } | 308 } |
309 | 309 |
310 bool FontSettingsGetFontListFunction::RunImpl() { | 310 bool FontSettingsGetFontListFunction::RunImpl() { |
311 content::GetFontListAsync( | 311 content::GetFontListAsync( |
312 Bind(&FontSettingsGetFontListFunction::FontListHasLoaded, this)); | 312 Bind(&FontSettingsGetFontListFunction::FontListHasLoaded, this)); |
313 return true; | 313 return true; |
314 } | 314 } |
315 | 315 |
316 void FontSettingsGetFontListFunction::FontListHasLoaded( | 316 void FontSettingsGetFontListFunction::FontListHasLoaded( |
(...skipping 19 matching lines...) Expand all Loading... |
336 return false; | 336 return false; |
337 } | 337 } |
338 | 338 |
339 std::string localized_name; | 339 std::string localized_name; |
340 if (!font_list_value->GetString(1, &localized_name)) { | 340 if (!font_list_value->GetString(1, &localized_name)) { |
341 NOTREACHED(); | 341 NOTREACHED(); |
342 return false; | 342 return false; |
343 } | 343 } |
344 | 344 |
345 base::DictionaryValue* font_name = new base::DictionaryValue(); | 345 base::DictionaryValue* font_name = new base::DictionaryValue(); |
346 font_name->Set(kFontIdKey, Value::CreateStringValue(name)); | 346 font_name->Set(kFontIdKey, new base::StringValue(name)); |
347 font_name->Set(kDisplayNameKey, Value::CreateStringValue(localized_name)); | 347 font_name->Set(kDisplayNameKey, new base::StringValue(localized_name)); |
348 result->Append(font_name); | 348 result->Append(font_name); |
349 } | 349 } |
350 | 350 |
351 SetResult(result.release()); | 351 SetResult(result.release()); |
352 return true; | 352 return true; |
353 } | 353 } |
354 | 354 |
355 bool ClearFontPrefExtensionFunction::RunImpl() { | 355 bool ClearFontPrefExtensionFunction::RunImpl() { |
356 if (profile_->IsOffTheRecord()) { | 356 if (profile_->IsOffTheRecord()) { |
357 error_ = kSetFromIncognitoError; | 357 error_ = kSetFromIncognitoError; |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 | 459 |
460 const char* FontSettingsSetMinimumFontSizeFunction::GetPrefName() { | 460 const char* FontSettingsSetMinimumFontSizeFunction::GetPrefName() { |
461 return prefs::kWebKitMinimumFontSize; | 461 return prefs::kWebKitMinimumFontSize; |
462 } | 462 } |
463 | 463 |
464 const char* FontSettingsSetMinimumFontSizeFunction::GetKey() { | 464 const char* FontSettingsSetMinimumFontSizeFunction::GetKey() { |
465 return kPixelSizeKey; | 465 return kPixelSizeKey; |
466 } | 466 } |
467 | 467 |
468 } // namespace extensions | 468 } // namespace extensions |
OLD | NEW |