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

Side by Side Diff: chrome/browser/extensions/api/management/management_api.cc

Issue 156843004: Remove ExtensionService::extension_prefs() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: additional cleanup Created 6 years, 10 months 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 | Annotate | Revision Log
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 #include "chrome/browser/extensions/api/management/management_api.h" 5 #include "chrome/browser/extensions/api/management/management_api.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 info->type = management::ExtensionInfo::TYPE_PACKAGED_APP; 118 info->type = management::ExtensionInfo::TYPE_PACKAGED_APP;
119 } else if (extension.is_theme()) { 119 } else if (extension.is_theme()) {
120 info->type = management::ExtensionInfo::TYPE_THEME; 120 info->type = management::ExtensionInfo::TYPE_THEME;
121 } else { 121 } else {
122 info->type = management::ExtensionInfo::TYPE_EXTENSION; 122 info->type = management::ExtensionInfo::TYPE_EXTENSION;
123 } 123 }
124 124
125 if (info->enabled) { 125 if (info->enabled) {
126 info->disabled_reason = management::ExtensionInfo::DISABLED_REASON_NONE; 126 info->disabled_reason = management::ExtensionInfo::DISABLED_REASON_NONE;
127 } else { 127 } else {
128 ExtensionPrefs* prefs = service->extension_prefs(); 128 ExtensionPrefs* prefs = ExtensionPrefs::Get(service->profile());
129 if (prefs->DidExtensionEscalatePermissions(extension.id())) { 129 if (prefs->DidExtensionEscalatePermissions(extension.id())) {
130 info->disabled_reason = 130 info->disabled_reason =
131 management::ExtensionInfo::DISABLED_REASON_PERMISSIONS_INCREASE; 131 management::ExtensionInfo::DISABLED_REASON_PERMISSIONS_INCREASE;
132 } else { 132 } else {
133 info->disabled_reason = 133 info->disabled_reason =
134 management::ExtensionInfo::DISABLED_REASON_UNKNOWN; 134 management::ExtensionInfo::DISABLED_REASON_UNKNOWN;
135 } 135 }
136 } 136 }
137 137
138 if (!ManifestURL::GetUpdateURL(&extension).is_empty()) { 138 if (!ManifestURL::GetUpdateURL(&extension).is_empty()) {
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 if (!extension->is_app()) { 432 if (!extension->is_app()) {
433 error_ = ErrorUtils::FormatErrorMessage(keys::kNotAnAppError, 433 error_ = ErrorUtils::FormatErrorMessage(keys::kNotAnAppError,
434 params->id); 434 params->id);
435 return false; 435 return false;
436 } 436 }
437 437
438 // Look at prefs to find the right launch container. 438 // Look at prefs to find the right launch container.
439 // If the user has not set a preference, the default launch value will be 439 // If the user has not set a preference, the default launch value will be
440 // returned. 440 // returned.
441 LaunchContainer launch_container = 441 LaunchContainer launch_container =
442 GetLaunchContainer(service()->extension_prefs(), extension); 442 GetLaunchContainer(ExtensionPrefs::Get(service()->profile()), extension);
James Cook 2014/02/07 00:53:02 Can you use GetProfile() here instead of service()
Ken Rockot(use gerrit already) 2014/02/10 18:53:02 Done.
443 OpenApplication(AppLaunchParams( 443 OpenApplication(AppLaunchParams(
444 GetProfile(), extension, launch_container, NEW_FOREGROUND_TAB)); 444 GetProfile(), extension, launch_container, NEW_FOREGROUND_TAB));
445 #if !defined(OS_ANDROID) 445 #if !defined(OS_ANDROID)
446 CoreAppLauncherHandler::RecordAppLaunchType( 446 CoreAppLauncherHandler::RecordAppLaunchType(
447 extension_misc::APP_LAUNCH_EXTENSION_API, 447 extension_misc::APP_LAUNCH_EXTENSION_API,
448 extension->GetType()); 448 extension->GetType());
449 #endif 449 #endif
450 450
451 return true; 451 return true;
452 } 452 }
(...skipping 24 matching lines...) Expand all
477 (!params->enabled && policy->MustRemainEnabled(extension, NULL)) || 477 (!params->enabled && policy->MustRemainEnabled(extension, NULL)) ||
478 (params->enabled && policy->MustRemainDisabled(extension, NULL, NULL))) { 478 (params->enabled && policy->MustRemainDisabled(extension, NULL, NULL))) {
479 error_ = ErrorUtils::FormatErrorMessage( 479 error_ = ErrorUtils::FormatErrorMessage(
480 keys::kUserCantModifyError, extension_id_); 480 keys::kUserCantModifyError, extension_id_);
481 return false; 481 return false;
482 } 482 }
483 483
484 bool currently_enabled = service()->IsExtensionEnabled(extension_id_); 484 bool currently_enabled = service()->IsExtensionEnabled(extension_id_);
485 485
486 if (!currently_enabled && params->enabled) { 486 if (!currently_enabled && params->enabled) {
487 ExtensionPrefs* prefs = service()->extension_prefs(); 487 ExtensionPrefs* prefs = ExtensionPrefs::Get(service()->profile());
James Cook 2014/02/07 00:53:02 ditto
Ken Rockot(use gerrit already) 2014/02/10 18:53:02 Done.
488 if (prefs->DidExtensionEscalatePermissions(extension_id_)) { 488 if (prefs->DidExtensionEscalatePermissions(extension_id_)) {
489 if (!user_gesture()) { 489 if (!user_gesture()) {
490 error_ = keys::kGestureNeededForEscalationError; 490 error_ = keys::kGestureNeededForEscalationError;
491 return false; 491 return false;
492 } 492 }
493 AddRef(); // Matched in InstallUIProceed/InstallUIAbort 493 AddRef(); // Matched in InstallUIProceed/InstallUIAbort
494 install_prompt_.reset( 494 install_prompt_.reset(
495 new ExtensionInstallPrompt(GetAssociatedWebContents())); 495 new ExtensionInstallPrompt(GetAssociatedWebContents()));
496 install_prompt_->ConfirmReEnable(this, extension); 496 install_prompt_->ConfirmReEnable(this, extension);
497 return true; 497 return true;
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 ProfileKeyedAPIFactory<ManagementAPI>* ManagementAPI::GetFactoryInstance() { 736 ProfileKeyedAPIFactory<ManagementAPI>* ManagementAPI::GetFactoryInstance() {
737 return g_factory.Pointer(); 737 return g_factory.Pointer();
738 } 738 }
739 739
740 void ManagementAPI::OnListenerAdded(const EventListenerInfo& details) { 740 void ManagementAPI::OnListenerAdded(const EventListenerInfo& details) {
741 management_event_router_.reset(new ManagementEventRouter(profile_)); 741 management_event_router_.reset(new ManagementEventRouter(profile_));
742 ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this); 742 ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this);
743 } 743 }
744 744
745 } // namespace extensions 745 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698