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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 #include "extensions/browser/event_router.h" | 74 #include "extensions/browser/event_router.h" |
75 #include "extensions/browser/extension_registry.h" | 75 #include "extensions/browser/extension_registry.h" |
76 #include "extensions/browser/extension_system.h" | 76 #include "extensions/browser/extension_system.h" |
77 #include "extensions/browser/extensions_browser_client.h" | 77 #include "extensions/browser/extensions_browser_client.h" |
78 #include "extensions/browser/external_provider_interface.h" | 78 #include "extensions/browser/external_provider_interface.h" |
79 #include "extensions/browser/management_policy.h" | 79 #include "extensions/browser/management_policy.h" |
80 #include "extensions/browser/pref_names.h" | 80 #include "extensions/browser/pref_names.h" |
81 #include "extensions/browser/process_manager.h" | 81 #include "extensions/browser/process_manager.h" |
82 #include "extensions/browser/process_map.h" | 82 #include "extensions/browser/process_map.h" |
83 #include "extensions/browser/runtime_data.h" | 83 #include "extensions/browser/runtime_data.h" |
| 84 #include "extensions/browser/service_worker_manager.h" |
84 #include "extensions/browser/update_observer.h" | 85 #include "extensions/browser/update_observer.h" |
85 #include "extensions/common/constants.h" | 86 #include "extensions/common/constants.h" |
86 #include "extensions/common/error_utils.h" | 87 #include "extensions/common/error_utils.h" |
87 #include "extensions/common/extension.h" | 88 #include "extensions/common/extension.h" |
88 #include "extensions/common/extension_messages.h" | 89 #include "extensions/common/extension_messages.h" |
89 #include "extensions/common/extensions_client.h" | 90 #include "extensions/common/extensions_client.h" |
90 #include "extensions/common/feature_switch.h" | 91 #include "extensions/common/feature_switch.h" |
91 #include "extensions/common/manifest.h" | 92 #include "extensions/common/manifest.h" |
92 #include "extensions/common/manifest_constants.h" | 93 #include "extensions/common/manifest_constants.h" |
93 #include "extensions/common/manifest_handlers/background_info.h" | 94 #include "extensions/common/manifest_handlers/background_info.h" |
(...skipping 10 matching lines...) Expand all Loading... |
104 | 105 |
105 #if defined(OS_CHROMEOS) | 106 #if defined(OS_CHROMEOS) |
106 #include "chrome/browser/chromeos/extensions/install_limiter.h" | 107 #include "chrome/browser/chromeos/extensions/install_limiter.h" |
107 #include "webkit/browser/fileapi/file_system_backend.h" | 108 #include "webkit/browser/fileapi/file_system_backend.h" |
108 #include "webkit/browser/fileapi/file_system_context.h" | 109 #include "webkit/browser/fileapi/file_system_context.h" |
109 #endif | 110 #endif |
110 | 111 |
111 using content::BrowserContext; | 112 using content::BrowserContext; |
112 using content::BrowserThread; | 113 using content::BrowserThread; |
113 using content::DevToolsAgentHost; | 114 using content::DevToolsAgentHost; |
| 115 using extensions::BackgroundInfo; |
114 using extensions::CrxInstaller; | 116 using extensions::CrxInstaller; |
115 using extensions::Extension; | 117 using extensions::Extension; |
116 using extensions::ExtensionIdSet; | 118 using extensions::ExtensionIdSet; |
117 using extensions::ExtensionInfo; | 119 using extensions::ExtensionInfo; |
118 using extensions::ExtensionRegistry; | 120 using extensions::ExtensionRegistry; |
119 using extensions::ExtensionSet; | 121 using extensions::ExtensionSet; |
120 using extensions::FeatureSwitch; | 122 using extensions::FeatureSwitch; |
121 using extensions::InstallVerifier; | 123 using extensions::InstallVerifier; |
122 using extensions::ManagementPolicy; | 124 using extensions::ManagementPolicy; |
123 using extensions::Manifest; | 125 using extensions::Manifest; |
124 using extensions::PermissionMessage; | 126 using extensions::PermissionMessage; |
125 using extensions::PermissionMessages; | 127 using extensions::PermissionMessages; |
126 using extensions::PermissionSet; | 128 using extensions::PermissionSet; |
| 129 using extensions::ServiceWorkerManager; |
127 using extensions::SharedModuleInfo; | 130 using extensions::SharedModuleInfo; |
128 using extensions::UnloadedExtensionInfo; | 131 using extensions::UnloadedExtensionInfo; |
129 | 132 |
130 namespace errors = extensions::manifest_errors; | 133 namespace errors = extensions::manifest_errors; |
131 | 134 |
132 namespace { | 135 namespace { |
133 | 136 |
134 // Histogram values for logging events related to externally installed | 137 // Histogram values for logging events related to externally installed |
135 // extensions. | 138 // extensions. |
136 enum ExternalExtensionEvent { | 139 enum ExternalExtensionEvent { |
(...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1028 if (!extension) | 1031 if (!extension) |
1029 return; | 1032 return; |
1030 | 1033 |
1031 // The extension is either enabled or terminated. | 1034 // The extension is either enabled or terminated. |
1032 DCHECK(registry_->enabled_extensions().Contains(extension->id()) || | 1035 DCHECK(registry_->enabled_extensions().Contains(extension->id()) || |
1033 registry_->terminated_extensions().Contains(extension->id())); | 1036 registry_->terminated_extensions().Contains(extension->id())); |
1034 | 1037 |
1035 // Move it over to the disabled list. Don't send a second unload notification | 1038 // Move it over to the disabled list. Don't send a second unload notification |
1036 // for terminated extensions being disabled. | 1039 // for terminated extensions being disabled. |
1037 registry_->AddDisabled(make_scoped_refptr(extension)); | 1040 registry_->AddDisabled(make_scoped_refptr(extension)); |
| 1041 |
| 1042 if (BackgroundInfo::HasServiceWorker(extension)) |
| 1043 ServiceWorkerManager::Get(profile_)->UnregisterExtension(extension); |
| 1044 |
1038 if (registry_->enabled_extensions().Contains(extension->id())) { | 1045 if (registry_->enabled_extensions().Contains(extension->id())) { |
1039 registry_->RemoveEnabled(extension->id()); | 1046 registry_->RemoveEnabled(extension->id()); |
1040 NotifyExtensionUnloaded(extension, UnloadedExtensionInfo::REASON_DISABLE); | 1047 NotifyExtensionUnloaded(extension, UnloadedExtensionInfo::REASON_DISABLE); |
1041 } else { | 1048 } else { |
1042 registry_->RemoveTerminated(extension->id()); | 1049 registry_->RemoveTerminated(extension->id()); |
1043 } | 1050 } |
1044 | 1051 |
1045 if (extension_sync_service_) | 1052 if (extension_sync_service_) |
1046 extension_sync_service_->SyncDisableExtension(*extension); | 1053 extension_sync_service_->SyncDisableExtension(*extension); |
1047 } | 1054 } |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1139 if (host_profile->GetOriginalProfile() == | 1146 if (host_profile->GetOriginalProfile() == |
1140 profile_->GetOriginalProfile()) { | 1147 profile_->GetOriginalProfile()) { |
1141 std::vector<ExtensionMsg_Loaded_Params> loaded_extensions( | 1148 std::vector<ExtensionMsg_Loaded_Params> loaded_extensions( |
1142 1, ExtensionMsg_Loaded_Params(extension)); | 1149 1, ExtensionMsg_Loaded_Params(extension)); |
1143 host->Send( | 1150 host->Send( |
1144 new ExtensionMsg_Loaded(loaded_extensions)); | 1151 new ExtensionMsg_Loaded(loaded_extensions)); |
1145 } | 1152 } |
1146 } | 1153 } |
1147 } | 1154 } |
1148 | 1155 |
| 1156 if (BackgroundInfo::HasServiceWorker(extension)) |
| 1157 ServiceWorkerManager::Get(profile_)->RegisterExtension(extension); |
| 1158 |
1149 // Tell subsystems that use the EXTENSION_LOADED notification about the new | 1159 // Tell subsystems that use the EXTENSION_LOADED notification about the new |
1150 // extension. | 1160 // extension. |
1151 // | 1161 // |
1152 // NOTE: It is important that this happen after notifying the renderers about | 1162 // NOTE: It is important that this happen after notifying the renderers about |
1153 // the new extensions so that if we navigate to an extension URL in | 1163 // the new extensions so that if we navigate to an extension URL in |
1154 // NOTIFICATION_EXTENSION_LOADED, the renderer is guaranteed to know about it. | 1164 // NOTIFICATION_EXTENSION_LOADED, the renderer is guaranteed to know about it. |
1155 content::NotificationService::current()->Notify( | 1165 content::NotificationService::current()->Notify( |
1156 chrome::NOTIFICATION_EXTENSION_LOADED, | 1166 chrome::NOTIFICATION_EXTENSION_LOADED, |
1157 content::Source<Profile>(profile_), | 1167 content::Source<Profile>(profile_), |
1158 content::Details<const Extension>(extension)); | 1168 content::Details<const Extension>(extension)); |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1617 registry_->RemoveDisabled(extension->id()); | 1627 registry_->RemoveDisabled(extension->id()); |
1618 // Make sure the profile cleans up its RequestContexts when an already | 1628 // Make sure the profile cleans up its RequestContexts when an already |
1619 // disabled extension is unloaded (since they are also tracking the disabled | 1629 // disabled extension is unloaded (since they are also tracking the disabled |
1620 // extensions). | 1630 // extensions). |
1621 system_->UnregisterExtensionWithRequestContexts(extension_id, reason); | 1631 system_->UnregisterExtensionWithRequestContexts(extension_id, reason); |
1622 // Don't send the unloaded notification. It was sent when the extension | 1632 // Don't send the unloaded notification. It was sent when the extension |
1623 // was disabled. | 1633 // was disabled. |
1624 } else { | 1634 } else { |
1625 // Remove the extension from the enabled list. | 1635 // Remove the extension from the enabled list. |
1626 registry_->RemoveEnabled(extension->id()); | 1636 registry_->RemoveEnabled(extension->id()); |
| 1637 |
| 1638 if (BackgroundInfo::HasServiceWorker(extension)) { |
| 1639 switch (reason) { |
| 1640 case UnloadedExtensionInfo::REASON_DISABLE: |
| 1641 case UnloadedExtensionInfo::REASON_UNINSTALL: |
| 1642 case UnloadedExtensionInfo::REASON_BLACKLIST: |
| 1643 ServiceWorkerManager::Get(profile_)->UnregisterExtension(extension); |
| 1644 break; |
| 1645 case UnloadedExtensionInfo::REASON_UPDATE: |
| 1646 case UnloadedExtensionInfo::REASON_TERMINATE: |
| 1647 break; |
| 1648 } |
| 1649 } |
1627 NotifyExtensionUnloaded(extension.get(), reason); | 1650 NotifyExtensionUnloaded(extension.get(), reason); |
1628 } | 1651 } |
1629 | 1652 |
1630 content::NotificationService::current()->Notify( | 1653 content::NotificationService::current()->Notify( |
1631 chrome::NOTIFICATION_EXTENSION_REMOVED, | 1654 chrome::NOTIFICATION_EXTENSION_REMOVED, |
1632 content::Source<Profile>(profile_), | 1655 content::Source<Profile>(profile_), |
1633 content::Details<const Extension>(extension.get())); | 1656 content::Details<const Extension>(extension.get())); |
1634 } | 1657 } |
1635 | 1658 |
1636 void ExtensionService::RemoveComponentExtension( | 1659 void ExtensionService::RemoveComponentExtension( |
(...skipping 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2837 void ExtensionService::UnloadAllExtensionsInternal() { | 2860 void ExtensionService::UnloadAllExtensionsInternal() { |
2838 profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions(); | 2861 profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions(); |
2839 | 2862 |
2840 registry_->ClearAll(); | 2863 registry_->ClearAll(); |
2841 system_->runtime_data()->ClearAll(); | 2864 system_->runtime_data()->ClearAll(); |
2842 | 2865 |
2843 // TODO(erikkay) should there be a notification for this? We can't use | 2866 // TODO(erikkay) should there be a notification for this? We can't use |
2844 // EXTENSION_UNLOADED since that implies that the extension has been disabled | 2867 // EXTENSION_UNLOADED since that implies that the extension has been disabled |
2845 // or uninstalled. | 2868 // or uninstalled. |
2846 } | 2869 } |
OLD | NEW |