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

Side by Side Diff: chrome/browser/extensions/extension_service.cc

Issue 1136543003: Extensions: Store disable reasons in Sync (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review Created 5 years, 7 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/extension_service.h" 5 #include "chrome/browser/extensions/extension_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <set> 9 #include <set>
10 10
(...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 // Notify listeners that the extension was enabled. 860 // Notify listeners that the extension was enabled.
861 content::NotificationService::current()->Notify( 861 content::NotificationService::current()->Notify(
862 extensions::NOTIFICATION_EXTENSION_ENABLED, 862 extensions::NOTIFICATION_EXTENSION_ENABLED,
863 content::Source<Profile>(profile_), 863 content::Source<Profile>(profile_),
864 content::Details<const Extension>(extension)); 864 content::Details<const Extension>(extension));
865 865
866 if (extension_sync_service_) 866 if (extension_sync_service_)
867 extension_sync_service_->SyncEnableExtension(*extension); 867 extension_sync_service_->SyncEnableExtension(*extension);
868 } 868 }
869 869
870 void ExtensionService::DisableExtension( 870 void ExtensionService::DisableExtension(const std::string& extension_id,
871 const std::string& extension_id, 871 int disable_reasons) {
872 Extension::DisableReason disable_reason) {
873 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 872 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
874 873
875 // The extension may have been disabled already. Just add a disable reason. 874 // The extension may have been disabled already. Just add a disable reason.
876 if (!IsExtensionEnabled(extension_id)) { 875 if (!IsExtensionEnabled(extension_id)) {
877 extension_prefs_->AddDisableReason(extension_id, disable_reason); 876 extension_prefs_->AddDisableReasons(extension_id, disable_reasons);
878 return; 877 return;
879 } 878 }
880 879
881 const Extension* extension = GetInstalledExtension(extension_id); 880 const Extension* extension = GetInstalledExtension(extension_id);
882 // |extension| can be NULL if sync disables an extension that is not 881 // |extension| can be NULL if sync disables an extension that is not
883 // installed yet. 882 // installed yet.
884 // EXTERNAL_COMPONENT extensions are not generally modifiable by users, but 883 // EXTERNAL_COMPONENT extensions are not generally modifiable by users, but
885 // can be uninstalled by the browser if the user sets extension-specific 884 // can be uninstalled by the browser if the user sets extension-specific
886 // preferences. 885 // preferences.
887 if (extension && 886 if (extension &&
888 disable_reason != Extension::DISABLE_RELOAD && 887 !(disable_reasons & Extension::DISABLE_RELOAD) &&
889 disable_reason != Extension::DISABLE_UPDATE_REQUIRED_BY_POLICY && 888 !(disable_reasons & Extension::DISABLE_UPDATE_REQUIRED_BY_POLICY) &&
890 !system_->management_policy()->UserMayModifySettings(extension, NULL) && 889 !system_->management_policy()->UserMayModifySettings(extension, NULL) &&
891 extension->location() != Manifest::EXTERNAL_COMPONENT) { 890 extension->location() != Manifest::EXTERNAL_COMPONENT) {
892 return; 891 return;
893 } 892 }
894 893
895 extension_prefs_->SetExtensionState(extension_id, Extension::DISABLED); 894 extension_prefs_->SetExtensionState(extension_id, Extension::DISABLED);
896 extension_prefs_->AddDisableReason(extension_id, disable_reason); 895 extension_prefs_->AddDisableReasons(extension_id, disable_reasons);
897 896
898 int include_mask = 897 int include_mask =
899 ExtensionRegistry::EVERYTHING & ~ExtensionRegistry::DISABLED; 898 ExtensionRegistry::EVERYTHING & ~ExtensionRegistry::DISABLED;
900 extension = registry_->GetExtensionById(extension_id, include_mask); 899 extension = registry_->GetExtensionById(extension_id, include_mask);
901 if (!extension) 900 if (!extension)
902 return; 901 return;
903 902
904 // The extension is either enabled or terminated. 903 // The extension is either enabled or terminated.
905 DCHECK(registry_->enabled_extensions().Contains(extension->id()) || 904 DCHECK(registry_->enabled_extensions().Contains(extension->id()) ||
906 registry_->terminated_extensions().Contains(extension->id())); 905 registry_->terminated_extensions().Contains(extension->id()));
(...skipping 1691 matching lines...) Expand 10 before | Expand all | Expand 10 after
2598 } 2597 }
2599 2598
2600 void ExtensionService::OnProfileDestructionStarted() { 2599 void ExtensionService::OnProfileDestructionStarted() {
2601 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); 2600 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs();
2602 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); 2601 for (ExtensionIdSet::iterator it = ids_to_unload.begin();
2603 it != ids_to_unload.end(); 2602 it != ids_to_unload.end();
2604 ++it) { 2603 ++it) {
2605 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); 2604 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN);
2606 } 2605 }
2607 } 2606 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698