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/extension_font_settings_api.h" | 7 #include "chrome/browser/extensions/extension_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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 fonts::ClearFont::Params::Create(*args_)); | 251 fonts::ClearFont::Params::Create(*args_)); |
252 EXTENSION_FUNCTION_VALIDATE(params.get()); | 252 EXTENSION_FUNCTION_VALIDATE(params.get()); |
253 | 253 |
254 std::string pref_path = GetFontNamePrefPath(params->details.generic_family, | 254 std::string pref_path = GetFontNamePrefPath(params->details.generic_family, |
255 params->details.script.get()); | 255 params->details.script.get()); |
256 | 256 |
257 // Ensure |pref_path| really is for a registered per-script font pref. | 257 // Ensure |pref_path| really is for a registered per-script font pref. |
258 EXTENSION_FUNCTION_VALIDATE( | 258 EXTENSION_FUNCTION_VALIDATE( |
259 profile_->GetPrefs()->FindPreference(pref_path.c_str())); | 259 profile_->GetPrefs()->FindPreference(pref_path.c_str())); |
260 | 260 |
261 ExtensionPrefs* prefs = profile_->GetExtensionService()->extension_prefs(); | 261 extensions::ExtensionPrefs* prefs = |
| 262 profile_->GetExtensionService()->extension_prefs(); |
262 prefs->RemoveExtensionControlledPref(extension_id(), | 263 prefs->RemoveExtensionControlledPref(extension_id(), |
263 pref_path.c_str(), | 264 pref_path.c_str(), |
264 kExtensionPrefsScopeRegular); | 265 extensions::kExtensionPrefsScopeRegular); |
265 return true; | 266 return true; |
266 } | 267 } |
267 | 268 |
268 bool GetFontFunction::RunImpl() { | 269 bool GetFontFunction::RunImpl() { |
269 scoped_ptr<fonts::GetFont::Params> params( | 270 scoped_ptr<fonts::GetFont::Params> params( |
270 fonts::GetFont::Params::Create(*args_)); | 271 fonts::GetFont::Params::Create(*args_)); |
271 EXTENSION_FUNCTION_VALIDATE(params.get()); | 272 EXTENSION_FUNCTION_VALIDATE(params.get()); |
272 | 273 |
273 std::string pref_path = GetFontNamePrefPath(params->details.generic_family, | 274 std::string pref_path = GetFontNamePrefPath(params->details.generic_family, |
274 params->details.script.get()); | 275 params->details.script.get()); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 scoped_ptr<fonts::SetFont::Params> params( | 307 scoped_ptr<fonts::SetFont::Params> params( |
307 fonts::SetFont::Params::Create(*args_)); | 308 fonts::SetFont::Params::Create(*args_)); |
308 EXTENSION_FUNCTION_VALIDATE(params.get()); | 309 EXTENSION_FUNCTION_VALIDATE(params.get()); |
309 | 310 |
310 std::string pref_path = GetFontNamePrefPath(params->details.generic_family, | 311 std::string pref_path = GetFontNamePrefPath(params->details.generic_family, |
311 params->details.script.get()); | 312 params->details.script.get()); |
312 // Ensure |pref_path| really is for a registered font pref. | 313 // Ensure |pref_path| really is for a registered font pref. |
313 EXTENSION_FUNCTION_VALIDATE( | 314 EXTENSION_FUNCTION_VALIDATE( |
314 profile_->GetPrefs()->FindPreference(pref_path.c_str())); | 315 profile_->GetPrefs()->FindPreference(pref_path.c_str())); |
315 | 316 |
316 ExtensionPrefs* prefs = profile_->GetExtensionService()->extension_prefs(); | 317 extensions::ExtensionPrefs* prefs = |
| 318 profile_->GetExtensionService()->extension_prefs(); |
317 prefs->SetExtensionControlledPref( | 319 prefs->SetExtensionControlledPref( |
318 extension_id(), | 320 extension_id(), |
319 pref_path.c_str(), | 321 pref_path.c_str(), |
320 kExtensionPrefsScopeRegular, | 322 extensions::kExtensionPrefsScopeRegular, |
321 Value::CreateStringValue(params->details.font_name)); | 323 Value::CreateStringValue(params->details.font_name)); |
322 return true; | 324 return true; |
323 } | 325 } |
324 | 326 |
325 bool GetFontListFunction::RunImpl() { | 327 bool GetFontListFunction::RunImpl() { |
326 content::GetFontListAsync( | 328 content::GetFontListAsync( |
327 Bind(&GetFontListFunction::FontListHasLoaded, this)); | 329 Bind(&GetFontListFunction::FontListHasLoaded, this)); |
328 return true; | 330 return true; |
329 } | 331 } |
330 | 332 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 result_.reset(result.release()); | 365 result_.reset(result.release()); |
364 return true; | 366 return true; |
365 } | 367 } |
366 | 368 |
367 bool ClearFontPrefExtensionFunction::RunImpl() { | 369 bool ClearFontPrefExtensionFunction::RunImpl() { |
368 if (profile_->IsOffTheRecord()) { | 370 if (profile_->IsOffTheRecord()) { |
369 error_ = kSetFromIncognitoError; | 371 error_ = kSetFromIncognitoError; |
370 return false; | 372 return false; |
371 } | 373 } |
372 | 374 |
373 ExtensionPrefs* prefs = profile_->GetExtensionService()->extension_prefs(); | 375 extensions::ExtensionPrefs* prefs = |
| 376 profile_->GetExtensionService()->extension_prefs(); |
374 prefs->RemoveExtensionControlledPref(extension_id(), | 377 prefs->RemoveExtensionControlledPref(extension_id(), |
375 GetPrefName(), | 378 GetPrefName(), |
376 kExtensionPrefsScopeRegular); | 379 extensions::kExtensionPrefsScopeRegular); |
377 return true; | 380 return true; |
378 } | 381 } |
379 | 382 |
380 bool GetFontPrefExtensionFunction::RunImpl() { | 383 bool GetFontPrefExtensionFunction::RunImpl() { |
381 PrefService* prefs = profile_->GetPrefs(); | 384 PrefService* prefs = profile_->GetPrefs(); |
382 const PrefService::Preference* pref = prefs->FindPreference(GetPrefName()); | 385 const PrefService::Preference* pref = prefs->FindPreference(GetPrefName()); |
383 EXTENSION_FUNCTION_VALIDATE(pref); | 386 EXTENSION_FUNCTION_VALIDATE(pref); |
384 | 387 |
385 // We don't support incognito-specific font prefs, so don't consider them when | 388 // We don't support incognito-specific font prefs, so don't consider them when |
386 // getting level of control. | 389 // getting level of control. |
(...skipping 17 matching lines...) Expand all Loading... |
404 error_ = kSetFromIncognitoError; | 407 error_ = kSetFromIncognitoError; |
405 return false; | 408 return false; |
406 } | 409 } |
407 | 410 |
408 DictionaryValue* details = NULL; | 411 DictionaryValue* details = NULL; |
409 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &details)); | 412 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &details)); |
410 | 413 |
411 Value* value; | 414 Value* value; |
412 EXTENSION_FUNCTION_VALIDATE(details->Get(GetKey(), &value)); | 415 EXTENSION_FUNCTION_VALIDATE(details->Get(GetKey(), &value)); |
413 | 416 |
414 ExtensionPrefs* prefs = profile_->GetExtensionService()->extension_prefs(); | 417 extensions::ExtensionPrefs* prefs = |
| 418 profile_->GetExtensionService()->extension_prefs(); |
415 prefs->SetExtensionControlledPref(extension_id(), | 419 prefs->SetExtensionControlledPref(extension_id(), |
416 GetPrefName(), | 420 GetPrefName(), |
417 kExtensionPrefsScopeRegular, | 421 extensions::kExtensionPrefsScopeRegular, |
418 value->DeepCopy()); | 422 value->DeepCopy()); |
419 return true; | 423 return true; |
420 } | 424 } |
421 | 425 |
422 const char* ClearDefaultFontSizeFunction::GetPrefName() { | 426 const char* ClearDefaultFontSizeFunction::GetPrefName() { |
423 return prefs::kWebKitDefaultFontSize; | 427 return prefs::kWebKitDefaultFontSize; |
424 } | 428 } |
425 | 429 |
426 const char* GetDefaultFontSizeFunction::GetPrefName() { | 430 const char* GetDefaultFontSizeFunction::GetPrefName() { |
427 return prefs::kWebKitDefaultFontSize; | 431 return prefs::kWebKitDefaultFontSize; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 return kPixelSizeKey; | 475 return kPixelSizeKey; |
472 } | 476 } |
473 | 477 |
474 const char* SetMinimumFontSizeFunction::GetPrefName() { | 478 const char* SetMinimumFontSizeFunction::GetPrefName() { |
475 return prefs::kWebKitMinimumFontSize; | 479 return prefs::kWebKitMinimumFontSize; |
476 } | 480 } |
477 | 481 |
478 const char* SetMinimumFontSizeFunction::GetKey() { | 482 const char* SetMinimumFontSizeFunction::GetKey() { |
479 return kPixelSizeKey; | 483 return kPixelSizeKey; |
480 } | 484 } |
OLD | NEW |