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

Side by Side Diff: chrome/browser/extensions/api/font_settings/font_settings_api.cc

Issue 11365181: Remove GetExtensionService from Profile. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: replace missing extension_system include Created 8 years 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
OLDNEW
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"
11 #include "base/json/json_writer.h" 11 #include "base/json/json_writer.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "base/stringprintf.h" 13 #include "base/stringprintf.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "chrome/browser/extensions/api/preference/preference_helpers.h" 15 #include "chrome/browser/extensions/api/preference/preference_helpers.h"
16 #include "chrome/browser/extensions/extension_service.h" 16 #include "chrome/browser/extensions/extension_service.h"
17 #include "chrome/browser/extensions/extension_system.h"
17 #include "chrome/browser/prefs/pref_service.h" 18 #include "chrome/browser/prefs/pref_service.h"
18 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/common/chrome_notification_types.h" 20 #include "chrome/common/chrome_notification_types.h"
20 #include "chrome/common/extensions/api/font_settings.h" 21 #include "chrome/common/extensions/api/font_settings.h"
21 #include "chrome/common/pref_names.h" 22 #include "chrome/common/pref_names.h"
22 #include "chrome/common/pref_names_util.h" 23 #include "chrome/common/pref_names_util.h"
23 #include "content/public/browser/font_list_async.h" 24 #include "content/public/browser/font_list_async.h"
24 #include "content/public/browser/notification_details.h" 25 #include "content/public/browser/notification_details.h"
25 #include "content/public/browser/notification_source.h" 26 #include "content/public/browser/notification_source.h"
26 #include "extensions/common/error_utils.h" 27 #include "extensions/common/error_utils.h"
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 fonts::ClearFont::Params::Create(*args_)); 220 fonts::ClearFont::Params::Create(*args_));
220 EXTENSION_FUNCTION_VALIDATE(params.get()); 221 EXTENSION_FUNCTION_VALIDATE(params.get());
221 222
222 std::string pref_path = GetFontNamePrefPath(params->details.generic_family, 223 std::string pref_path = GetFontNamePrefPath(params->details.generic_family,
223 params->details.script); 224 params->details.script);
224 225
225 // Ensure |pref_path| really is for a registered per-script font pref. 226 // Ensure |pref_path| really is for a registered per-script font pref.
226 EXTENSION_FUNCTION_VALIDATE( 227 EXTENSION_FUNCTION_VALIDATE(
227 profile_->GetPrefs()->FindPreference(pref_path.c_str())); 228 profile_->GetPrefs()->FindPreference(pref_path.c_str()));
228 229
229 ExtensionPrefs* prefs = profile_->GetExtensionService()->extension_prefs(); 230 ExtensionPrefs* prefs = extensions::ExtensionSystem::Get(profile_)->
231 extension_service()->extension_prefs();
230 prefs->RemoveExtensionControlledPref(extension_id(), 232 prefs->RemoveExtensionControlledPref(extension_id(),
231 pref_path.c_str(), 233 pref_path.c_str(),
232 kExtensionPrefsScopeRegular); 234 kExtensionPrefsScopeRegular);
233 return true; 235 return true;
234 } 236 }
235 237
236 bool GetFontFunction::RunImpl() { 238 bool GetFontFunction::RunImpl() {
237 scoped_ptr<fonts::GetFont::Params> params( 239 scoped_ptr<fonts::GetFont::Params> params(
238 fonts::GetFont::Params::Create(*args_)); 240 fonts::GetFont::Params::Create(*args_));
239 EXTENSION_FUNCTION_VALIDATE(params.get()); 241 EXTENSION_FUNCTION_VALIDATE(params.get());
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 fonts::SetFont::Params::Create(*args_)); 278 fonts::SetFont::Params::Create(*args_));
277 EXTENSION_FUNCTION_VALIDATE(params.get()); 279 EXTENSION_FUNCTION_VALIDATE(params.get());
278 280
279 std::string pref_path = GetFontNamePrefPath(params->details.generic_family, 281 std::string pref_path = GetFontNamePrefPath(params->details.generic_family,
280 params->details.script); 282 params->details.script);
281 283
282 // Ensure |pref_path| really is for a registered font pref. 284 // Ensure |pref_path| really is for a registered font pref.
283 EXTENSION_FUNCTION_VALIDATE( 285 EXTENSION_FUNCTION_VALIDATE(
284 profile_->GetPrefs()->FindPreference(pref_path.c_str())); 286 profile_->GetPrefs()->FindPreference(pref_path.c_str()));
285 287
286 ExtensionPrefs* prefs = profile_->GetExtensionService()->extension_prefs(); 288 ExtensionPrefs* prefs = extensions::ExtensionSystem::Get(profile_)->
289 extension_service()->extension_prefs();
287 prefs->SetExtensionControlledPref( 290 prefs->SetExtensionControlledPref(
288 extension_id(), 291 extension_id(),
289 pref_path.c_str(), 292 pref_path.c_str(),
290 kExtensionPrefsScopeRegular, 293 kExtensionPrefsScopeRegular,
291 Value::CreateStringValue(params->details.font_id)); 294 Value::CreateStringValue(params->details.font_id));
292 return true; 295 return true;
293 } 296 }
294 297
295 bool GetFontListFunction::RunImpl() { 298 bool GetFontListFunction::RunImpl() {
296 content::GetFontListAsync( 299 content::GetFontListAsync(
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 SetResult(result.release()); 336 SetResult(result.release());
334 return true; 337 return true;
335 } 338 }
336 339
337 bool ClearFontPrefExtensionFunction::RunImpl() { 340 bool ClearFontPrefExtensionFunction::RunImpl() {
338 if (profile_->IsOffTheRecord()) { 341 if (profile_->IsOffTheRecord()) {
339 error_ = kSetFromIncognitoError; 342 error_ = kSetFromIncognitoError;
340 return false; 343 return false;
341 } 344 }
342 345
343 ExtensionPrefs* prefs = profile_->GetExtensionService()->extension_prefs(); 346 ExtensionPrefs* prefs = extensions::ExtensionSystem::Get(profile_)->
347 extension_service()->extension_prefs();
344 prefs->RemoveExtensionControlledPref(extension_id(), 348 prefs->RemoveExtensionControlledPref(extension_id(),
345 GetPrefName(), 349 GetPrefName(),
346 kExtensionPrefsScopeRegular); 350 kExtensionPrefsScopeRegular);
347 return true; 351 return true;
348 } 352 }
349 353
350 bool GetFontPrefExtensionFunction::RunImpl() { 354 bool GetFontPrefExtensionFunction::RunImpl() {
351 PrefService* prefs = profile_->GetPrefs(); 355 PrefService* prefs = profile_->GetPrefs();
352 const PrefService::Preference* pref = prefs->FindPreference(GetPrefName()); 356 const PrefService::Preference* pref = prefs->FindPreference(GetPrefName());
353 EXTENSION_FUNCTION_VALIDATE(pref); 357 EXTENSION_FUNCTION_VALIDATE(pref);
(...skipping 20 matching lines...) Expand all
374 error_ = kSetFromIncognitoError; 378 error_ = kSetFromIncognitoError;
375 return false; 379 return false;
376 } 380 }
377 381
378 DictionaryValue* details = NULL; 382 DictionaryValue* details = NULL;
379 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &details)); 383 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &details));
380 384
381 Value* value; 385 Value* value;
382 EXTENSION_FUNCTION_VALIDATE(details->Get(GetKey(), &value)); 386 EXTENSION_FUNCTION_VALIDATE(details->Get(GetKey(), &value));
383 387
384 ExtensionPrefs* prefs = profile_->GetExtensionService()->extension_prefs(); 388 ExtensionPrefs* prefs = extensions::ExtensionSystem::Get(profile_)->
389 extension_service()->extension_prefs();
385 prefs->SetExtensionControlledPref(extension_id(), 390 prefs->SetExtensionControlledPref(extension_id(),
386 GetPrefName(), 391 GetPrefName(),
387 kExtensionPrefsScopeRegular, 392 kExtensionPrefsScopeRegular,
388 value->DeepCopy()); 393 value->DeepCopy());
389 return true; 394 return true;
390 } 395 }
391 396
392 const char* ClearDefaultFontSizeFunction::GetPrefName() { 397 const char* ClearDefaultFontSizeFunction::GetPrefName() {
393 return prefs::kWebKitDefaultFontSize; 398 return prefs::kWebKitDefaultFontSize;
394 } 399 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 448
444 const char* SetMinimumFontSizeFunction::GetPrefName() { 449 const char* SetMinimumFontSizeFunction::GetPrefName() {
445 return prefs::kWebKitMinimumFontSize; 450 return prefs::kWebKitMinimumFontSize;
446 } 451 }
447 452
448 const char* SetMinimumFontSizeFunction::GetKey() { 453 const char* SetMinimumFontSizeFunction::GetKey() {
449 return kPixelSizeKey; 454 return kPixelSizeKey;
450 } 455 }
451 456
452 } // namespace extensions 457 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698