OLD | NEW |
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 Loading... |
860 | 860 |
861 NotifyExtensionLoaded(extension); | 861 NotifyExtensionLoaded(extension); |
862 | 862 |
863 // Notify listeners that the extension was enabled. | 863 // Notify listeners that the extension was enabled. |
864 content::NotificationService::current()->Notify( | 864 content::NotificationService::current()->Notify( |
865 extensions::NOTIFICATION_EXTENSION_ENABLED, | 865 extensions::NOTIFICATION_EXTENSION_ENABLED, |
866 content::Source<Profile>(profile_), | 866 content::Source<Profile>(profile_), |
867 content::Details<const Extension>(extension)); | 867 content::Details<const Extension>(extension)); |
868 | 868 |
869 if (extension_sync_service_) | 869 if (extension_sync_service_) |
870 extension_sync_service_->SyncEnableExtension(*extension); | 870 extension_sync_service_->SyncExtensionChangeIfNeeded(*extension); |
871 } | 871 } |
872 | 872 |
873 void ExtensionService::DisableExtension(const std::string& extension_id, | 873 void ExtensionService::DisableExtension(const std::string& extension_id, |
874 int disable_reasons) { | 874 int disable_reasons) { |
875 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 875 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
876 | 876 |
877 // The extension may have been disabled already. Just add a disable reason. | 877 // The extension may have been disabled already. Just add a disable reason. |
878 if (!IsExtensionEnabled(extension_id)) { | 878 if (!IsExtensionEnabled(extension_id)) { |
879 extension_prefs_->AddDisableReasons(extension_id, disable_reasons); | 879 extension_prefs_->AddDisableReasons(extension_id, disable_reasons); |
880 return; | 880 return; |
(...skipping 30 matching lines...) Expand all Loading... |
911 // for terminated extensions being disabled. | 911 // for terminated extensions being disabled. |
912 registry_->AddDisabled(make_scoped_refptr(extension)); | 912 registry_->AddDisabled(make_scoped_refptr(extension)); |
913 if (registry_->enabled_extensions().Contains(extension->id())) { | 913 if (registry_->enabled_extensions().Contains(extension->id())) { |
914 registry_->RemoveEnabled(extension->id()); | 914 registry_->RemoveEnabled(extension->id()); |
915 NotifyExtensionUnloaded(extension, UnloadedExtensionInfo::REASON_DISABLE); | 915 NotifyExtensionUnloaded(extension, UnloadedExtensionInfo::REASON_DISABLE); |
916 } else { | 916 } else { |
917 registry_->RemoveTerminated(extension->id()); | 917 registry_->RemoveTerminated(extension->id()); |
918 } | 918 } |
919 | 919 |
920 if (extension_sync_service_) | 920 if (extension_sync_service_) |
921 extension_sync_service_->SyncDisableExtension(*extension); | 921 extension_sync_service_->SyncExtensionChangeIfNeeded(*extension); |
922 } | 922 } |
923 | 923 |
924 void ExtensionService::DisableUserExtensions( | 924 void ExtensionService::DisableUserExtensions( |
925 const std::vector<std::string>& except_ids) { | 925 const std::vector<std::string>& except_ids) { |
926 extensions::ManagementPolicy* management_policy = | 926 extensions::ManagementPolicy* management_policy = |
927 system_->management_policy(); | 927 system_->management_policy(); |
928 extensions::ExtensionList to_disable; | 928 extensions::ExtensionList to_disable; |
929 | 929 |
930 const ExtensionSet& enabled_set = registry_->enabled_extensions(); | 930 const ExtensionSet& enabled_set = registry_->enabled_extensions(); |
931 for (ExtensionSet::const_iterator extension = enabled_set.begin(); | 931 for (ExtensionSet::const_iterator extension = enabled_set.begin(); |
(...skipping 1646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2578 } | 2578 } |
2579 | 2579 |
2580 void ExtensionService::OnProfileDestructionStarted() { | 2580 void ExtensionService::OnProfileDestructionStarted() { |
2581 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); | 2581 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); |
2582 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); | 2582 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); |
2583 it != ids_to_unload.end(); | 2583 it != ids_to_unload.end(); |
2584 ++it) { | 2584 ++it) { |
2585 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); | 2585 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); |
2586 } | 2586 } |
2587 } | 2587 } |
OLD | NEW |