| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 #include "extensions/browser/extension_registry.h" | 77 #include "extensions/browser/extension_registry.h" |
| 78 #include "extensions/browser/extension_system.h" | 78 #include "extensions/browser/extension_system.h" |
| 79 #include "extensions/browser/extensions_browser_client.h" | 79 #include "extensions/browser/extensions_browser_client.h" |
| 80 #include "extensions/browser/external_provider_interface.h" | 80 #include "extensions/browser/external_provider_interface.h" |
| 81 #include "extensions/browser/management_policy.h" | 81 #include "extensions/browser/management_policy.h" |
| 82 #include "extensions/browser/pending_extension_manager.h" | 82 #include "extensions/browser/pending_extension_manager.h" |
| 83 #include "extensions/browser/pref_names.h" | 83 #include "extensions/browser/pref_names.h" |
| 84 #include "extensions/browser/process_manager.h" | 84 #include "extensions/browser/process_manager.h" |
| 85 #include "extensions/browser/process_map.h" | 85 #include "extensions/browser/process_map.h" |
| 86 #include "extensions/browser/runtime_data.h" | 86 #include "extensions/browser/runtime_data.h" |
| 87 #include "extensions/browser/service_worker_manager.h" |
| 87 #include "extensions/browser/update_observer.h" | 88 #include "extensions/browser/update_observer.h" |
| 88 #include "extensions/common/constants.h" | 89 #include "extensions/common/constants.h" |
| 89 #include "extensions/common/error_utils.h" | 90 #include "extensions/common/error_utils.h" |
| 90 #include "extensions/common/extension.h" | 91 #include "extensions/common/extension.h" |
| 91 #include "extensions/common/extensions_client.h" | 92 #include "extensions/common/extensions_client.h" |
| 92 #include "extensions/common/feature_switch.h" | 93 #include "extensions/common/feature_switch.h" |
| 93 #include "extensions/common/manifest.h" | 94 #include "extensions/common/manifest.h" |
| 94 #include "extensions/common/manifest_constants.h" | 95 #include "extensions/common/manifest_constants.h" |
| 95 #include "extensions/common/manifest_handlers/background_info.h" | 96 #include "extensions/common/manifest_handlers/background_info.h" |
| 96 #include "extensions/common/manifest_handlers/incognito_info.h" | 97 #include "extensions/common/manifest_handlers/incognito_info.h" |
| 97 #include "extensions/common/manifest_handlers/shared_module_info.h" | 98 #include "extensions/common/manifest_handlers/shared_module_info.h" |
| 98 #include "extensions/common/permissions/permission_message_provider.h" | 99 #include "extensions/common/permissions/permission_message_provider.h" |
| 99 #include "extensions/common/permissions/permissions_data.h" | 100 #include "extensions/common/permissions/permissions_data.h" |
| 100 #include "grit/generated_resources.h" | 101 #include "grit/generated_resources.h" |
| 101 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 102 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 102 #include "ui/base/webui/web_ui_util.h" | 103 #include "ui/base/webui/web_ui_util.h" |
| 103 #include "url/gurl.h" | 104 #include "url/gurl.h" |
| 104 #include "webkit/browser/database/database_tracker.h" | 105 #include "webkit/browser/database/database_tracker.h" |
| 105 #include "webkit/browser/database/database_util.h" | 106 #include "webkit/browser/database/database_util.h" |
| 106 | 107 |
| 107 #if defined(OS_CHROMEOS) | 108 #if defined(OS_CHROMEOS) |
| 108 #include "chrome/browser/chromeos/extensions/install_limiter.h" | 109 #include "chrome/browser/chromeos/extensions/install_limiter.h" |
| 109 #include "webkit/browser/fileapi/file_system_backend.h" | 110 #include "webkit/browser/fileapi/file_system_backend.h" |
| 110 #include "webkit/browser/fileapi/file_system_context.h" | 111 #include "webkit/browser/fileapi/file_system_context.h" |
| 111 #endif | 112 #endif |
| 112 | 113 |
| 113 using content::BrowserContext; | 114 using content::BrowserContext; |
| 114 using content::BrowserThread; | 115 using content::BrowserThread; |
| 115 using content::DevToolsAgentHost; | 116 using content::DevToolsAgentHost; |
| 117 using extensions::BackgroundInfo; |
| 116 using extensions::CrxInstaller; | 118 using extensions::CrxInstaller; |
| 117 using extensions::Extension; | 119 using extensions::Extension; |
| 118 using extensions::ExtensionIdSet; | 120 using extensions::ExtensionIdSet; |
| 119 using extensions::ExtensionInfo; | 121 using extensions::ExtensionInfo; |
| 120 using extensions::ExtensionRegistry; | 122 using extensions::ExtensionRegistry; |
| 121 using extensions::ExtensionSet; | 123 using extensions::ExtensionSet; |
| 122 using extensions::FeatureSwitch; | 124 using extensions::FeatureSwitch; |
| 123 using extensions::InstallVerifier; | 125 using extensions::InstallVerifier; |
| 124 using extensions::ManagementPolicy; | 126 using extensions::ManagementPolicy; |
| 125 using extensions::Manifest; | 127 using extensions::Manifest; |
| 126 using extensions::PermissionMessage; | 128 using extensions::PermissionMessage; |
| 127 using extensions::PermissionMessages; | 129 using extensions::PermissionMessages; |
| 128 using extensions::PermissionSet; | 130 using extensions::PermissionSet; |
| 131 using extensions::ServiceWorkerManager; |
| 129 using extensions::SharedModuleInfo; | 132 using extensions::SharedModuleInfo; |
| 130 using extensions::UnloadedExtensionInfo; | 133 using extensions::UnloadedExtensionInfo; |
| 131 | 134 |
| 132 namespace errors = extensions::manifest_errors; | 135 namespace errors = extensions::manifest_errors; |
| 133 | 136 |
| 134 namespace { | 137 namespace { |
| 135 | 138 |
| 136 // Histogram values for logging events related to externally installed | 139 // Histogram values for logging events related to externally installed |
| 137 // extensions. | 140 // extensions. |
| 138 enum ExternalExtensionEvent { | 141 enum ExternalExtensionEvent { |
| (...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1042 if (!extension) | 1045 if (!extension) |
| 1043 return; | 1046 return; |
| 1044 | 1047 |
| 1045 // The extension is either enabled or terminated. | 1048 // The extension is either enabled or terminated. |
| 1046 DCHECK(registry_->enabled_extensions().Contains(extension->id()) || | 1049 DCHECK(registry_->enabled_extensions().Contains(extension->id()) || |
| 1047 registry_->terminated_extensions().Contains(extension->id())); | 1050 registry_->terminated_extensions().Contains(extension->id())); |
| 1048 | 1051 |
| 1049 // Move it over to the disabled list. Don't send a second unload notification | 1052 // Move it over to the disabled list. Don't send a second unload notification |
| 1050 // for terminated extensions being disabled. | 1053 // for terminated extensions being disabled. |
| 1051 registry_->AddDisabled(make_scoped_refptr(extension)); | 1054 registry_->AddDisabled(make_scoped_refptr(extension)); |
| 1055 |
| 1056 if (BackgroundInfo::HasServiceWorker(extension)) |
| 1057 ServiceWorkerManager::Get(profile_)->UnregisterExtension(extension); |
| 1058 |
| 1052 if (registry_->enabled_extensions().Contains(extension->id())) { | 1059 if (registry_->enabled_extensions().Contains(extension->id())) { |
| 1053 registry_->RemoveEnabled(extension->id()); | 1060 registry_->RemoveEnabled(extension->id()); |
| 1054 NotifyExtensionUnloaded(extension, UnloadedExtensionInfo::REASON_DISABLE); | 1061 NotifyExtensionUnloaded(extension, UnloadedExtensionInfo::REASON_DISABLE); |
| 1055 } else { | 1062 } else { |
| 1056 registry_->RemoveTerminated(extension->id()); | 1063 registry_->RemoveTerminated(extension->id()); |
| 1057 } | 1064 } |
| 1058 | 1065 |
| 1059 if (extension_sync_service_) | 1066 if (extension_sync_service_) |
| 1060 extension_sync_service_->SyncDisableExtension(*extension); | 1067 extension_sync_service_->SyncDisableExtension(*extension); |
| 1061 } | 1068 } |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1150 if (host_profile->GetOriginalProfile() == | 1157 if (host_profile->GetOriginalProfile() == |
| 1151 profile_->GetOriginalProfile()) { | 1158 profile_->GetOriginalProfile()) { |
| 1152 std::vector<ExtensionMsg_Loaded_Params> loaded_extensions( | 1159 std::vector<ExtensionMsg_Loaded_Params> loaded_extensions( |
| 1153 1, ExtensionMsg_Loaded_Params(extension)); | 1160 1, ExtensionMsg_Loaded_Params(extension)); |
| 1154 host->Send( | 1161 host->Send( |
| 1155 new ExtensionMsg_Loaded(loaded_extensions)); | 1162 new ExtensionMsg_Loaded(loaded_extensions)); |
| 1156 } | 1163 } |
| 1157 } | 1164 } |
| 1158 } | 1165 } |
| 1159 | 1166 |
| 1167 if (BackgroundInfo::HasServiceWorker(extension)) |
| 1168 ServiceWorkerManager::Get(profile_)->RegisterExtension(extension); |
| 1169 |
| 1160 // Tell subsystems that use the EXTENSION_LOADED notification about the new | 1170 // Tell subsystems that use the EXTENSION_LOADED notification about the new |
| 1161 // extension. | 1171 // extension. |
| 1162 // | 1172 // |
| 1163 // NOTE: It is important that this happen after notifying the renderers about | 1173 // NOTE: It is important that this happen after notifying the renderers about |
| 1164 // the new extensions so that if we navigate to an extension URL in | 1174 // the new extensions so that if we navigate to an extension URL in |
| 1165 // NOTIFICATION_EXTENSION_LOADED, the renderer is guaranteed to know about it. | 1175 // NOTIFICATION_EXTENSION_LOADED, the renderer is guaranteed to know about it. |
| 1166 content::NotificationService::current()->Notify( | 1176 content::NotificationService::current()->Notify( |
| 1167 chrome::NOTIFICATION_EXTENSION_LOADED, | 1177 chrome::NOTIFICATION_EXTENSION_LOADED, |
| 1168 content::Source<Profile>(profile_), | 1178 content::Source<Profile>(profile_), |
| 1169 content::Details<const Extension>(extension)); | 1179 content::Details<const Extension>(extension)); |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1647 registry_->RemoveDisabled(extension->id()); | 1657 registry_->RemoveDisabled(extension->id()); |
| 1648 // Make sure the profile cleans up its RequestContexts when an already | 1658 // Make sure the profile cleans up its RequestContexts when an already |
| 1649 // disabled extension is unloaded (since they are also tracking the disabled | 1659 // disabled extension is unloaded (since they are also tracking the disabled |
| 1650 // extensions). | 1660 // extensions). |
| 1651 system_->UnregisterExtensionWithRequestContexts(extension_id, reason); | 1661 system_->UnregisterExtensionWithRequestContexts(extension_id, reason); |
| 1652 // Don't send the unloaded notification. It was sent when the extension | 1662 // Don't send the unloaded notification. It was sent when the extension |
| 1653 // was disabled. | 1663 // was disabled. |
| 1654 } else { | 1664 } else { |
| 1655 // Remove the extension from the enabled list. | 1665 // Remove the extension from the enabled list. |
| 1656 registry_->RemoveEnabled(extension->id()); | 1666 registry_->RemoveEnabled(extension->id()); |
| 1667 |
| 1668 if (BackgroundInfo::HasServiceWorker(extension)) { |
| 1669 switch (reason) { |
| 1670 case UnloadedExtensionInfo::REASON_DISABLE: |
| 1671 case UnloadedExtensionInfo::REASON_UNINSTALL: |
| 1672 case UnloadedExtensionInfo::REASON_BLACKLIST: |
| 1673 ServiceWorkerManager::Get(profile_)->UnregisterExtension(extension); |
| 1674 break; |
| 1675 case UnloadedExtensionInfo::REASON_UPDATE: |
| 1676 case UnloadedExtensionInfo::REASON_TERMINATE: |
| 1677 break; |
| 1678 } |
| 1679 } |
| 1657 NotifyExtensionUnloaded(extension.get(), reason); | 1680 NotifyExtensionUnloaded(extension.get(), reason); |
| 1658 } | 1681 } |
| 1659 | 1682 |
| 1660 content::NotificationService::current()->Notify( | 1683 content::NotificationService::current()->Notify( |
| 1661 chrome::NOTIFICATION_EXTENSION_REMOVED, | 1684 chrome::NOTIFICATION_EXTENSION_REMOVED, |
| 1662 content::Source<Profile>(profile_), | 1685 content::Source<Profile>(profile_), |
| 1663 content::Details<const Extension>(extension.get())); | 1686 content::Details<const Extension>(extension.get())); |
| 1664 } | 1687 } |
| 1665 | 1688 |
| 1666 void ExtensionService::RemoveComponentExtension( | 1689 void ExtensionService::RemoveComponentExtension( |
| (...skipping 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2887 void ExtensionService::UnloadAllExtensionsInternal() { | 2910 void ExtensionService::UnloadAllExtensionsInternal() { |
| 2888 profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions(); | 2911 profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions(); |
| 2889 | 2912 |
| 2890 registry_->ClearAll(); | 2913 registry_->ClearAll(); |
| 2891 system_->runtime_data()->ClearAll(); | 2914 system_->runtime_data()->ClearAll(); |
| 2892 | 2915 |
| 2893 // TODO(erikkay) should there be a notification for this? We can't use | 2916 // TODO(erikkay) should there be a notification for this? We can't use |
| 2894 // EXTENSION_UNLOADED since that implies that the extension has been disabled | 2917 // EXTENSION_UNLOADED since that implies that the extension has been disabled |
| 2895 // or uninstalled. | 2918 // or uninstalled. |
| 2896 } | 2919 } |
| OLD | NEW |