Chromium Code Reviews| 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 27 matching lines...) Expand all Loading... | |
| 38 #include "chrome/browser/extensions/install_verifier.h" | 38 #include "chrome/browser/extensions/install_verifier.h" |
| 39 #include "chrome/browser/extensions/installed_loader.h" | 39 #include "chrome/browser/extensions/installed_loader.h" |
| 40 #include "chrome/browser/extensions/pending_extension_manager.h" | 40 #include "chrome/browser/extensions/pending_extension_manager.h" |
| 41 #include "chrome/browser/extensions/permissions_updater.h" | 41 #include "chrome/browser/extensions/permissions_updater.h" |
| 42 #include "chrome/browser/extensions/shared_module_service.h" | 42 #include "chrome/browser/extensions/shared_module_service.h" |
| 43 #include "chrome/browser/extensions/unpacked_installer.h" | 43 #include "chrome/browser/extensions/unpacked_installer.h" |
| 44 #include "chrome/browser/extensions/updater/chrome_extension_downloader_factory. h" | 44 #include "chrome/browser/extensions/updater/chrome_extension_downloader_factory. h" |
| 45 #include "chrome/browser/extensions/updater/extension_updater.h" | 45 #include "chrome/browser/extensions/updater/extension_updater.h" |
| 46 #include "chrome/browser/google/google_brand.h" | 46 #include "chrome/browser/google/google_brand.h" |
| 47 #include "chrome/browser/profiles/profile.h" | 47 #include "chrome/browser/profiles/profile.h" |
| 48 #include "chrome/browser/themes/theme_service.h" | |
| 49 #include "chrome/browser/themes/theme_service_factory.h" | |
| 48 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" | 50 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" |
| 49 #include "chrome/browser/ui/webui/favicon_source.h" | 51 #include "chrome/browser/ui/webui/favicon_source.h" |
| 50 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" | 52 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" |
| 51 #include "chrome/browser/ui/webui/theme_source.h" | 53 #include "chrome/browser/ui/webui/theme_source.h" |
| 52 #include "chrome/common/chrome_switches.h" | 54 #include "chrome/common/chrome_switches.h" |
| 53 #include "chrome/common/crash_keys.h" | 55 #include "chrome/common/crash_keys.h" |
| 54 #include "chrome/common/extensions/extension_constants.h" | 56 #include "chrome/common/extensions/extension_constants.h" |
| 55 #include "chrome/common/extensions/features/feature_channel.h" | 57 #include "chrome/common/extensions/features/feature_channel.h" |
| 56 #include "chrome/common/url_constants.h" | 58 #include "chrome/common/url_constants.h" |
| 57 #include "components/content_settings/core/browser/host_content_settings_map.h" | 59 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| (...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1067 // ExtensionRegistryObserver::OnLoaded or | 1069 // ExtensionRegistryObserver::OnLoaded or |
| 1068 // NOTIFICATION_EXTENSION_LOADED_DEPRECATED, the | 1070 // NOTIFICATION_EXTENSION_LOADED_DEPRECATED, the |
| 1069 // renderer is guaranteed to know about it. | 1071 // renderer is guaranteed to know about it. |
| 1070 registry_->TriggerOnLoaded(extension); | 1072 registry_->TriggerOnLoaded(extension); |
| 1071 | 1073 |
| 1072 content::NotificationService::current()->Notify( | 1074 content::NotificationService::current()->Notify( |
| 1073 extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, | 1075 extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, |
| 1074 content::Source<Profile>(profile_), | 1076 content::Source<Profile>(profile_), |
| 1075 content::Details<const Extension>(extension)); | 1077 content::Details<const Extension>(extension)); |
| 1076 | 1078 |
| 1079 ThemeServiceFactory::GetForProfile(profile_) | |
|
not at google - send to devlin
2015/03/09 16:32:40
The point of Observers is so that ExtensionService
limasdf
2015/03/10 16:46:16
To make ThemeServiceFactory as ExtensionRegistryOb
not at google - send to devlin
2015/03/10 16:50:18
Seems like overkill. +thestig has a lot of experie
| |
| 1080 ->extension_observer() | |
| 1081 .OnExtensionLoaded(extension); | |
| 1082 | |
| 1077 // TODO(kalman): Convert ExtensionSpecialStoragePolicy to a | 1083 // TODO(kalman): Convert ExtensionSpecialStoragePolicy to a |
| 1078 // BrowserContextKeyedService and use ExtensionRegistryObserver. | 1084 // BrowserContextKeyedService and use ExtensionRegistryObserver. |
| 1079 profile_->GetExtensionSpecialStoragePolicy()-> | 1085 profile_->GetExtensionSpecialStoragePolicy()-> |
| 1080 GrantRightsForExtension(extension, profile_); | 1086 GrantRightsForExtension(extension, profile_); |
| 1081 | 1087 |
| 1082 // TODO(kalman): This is broken. The crash reporter is process-wide so doesn't | 1088 // TODO(kalman): This is broken. The crash reporter is process-wide so doesn't |
| 1083 // work properly multi-profile. Besides which, it should be using | 1089 // work properly multi-profile. Besides which, it should be using |
| 1084 // ExtensionRegistryObserver. See http://crbug.com/355029. | 1090 // ExtensionRegistryObserver. See http://crbug.com/355029. |
| 1085 UpdateActiveExtensionsInCrashReporter(); | 1091 UpdateActiveExtensionsInCrashReporter(); |
| 1086 | 1092 |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 1115 UnloadedExtensionInfo::Reason reason) { | 1121 UnloadedExtensionInfo::Reason reason) { |
| 1116 UnloadedExtensionInfo details(extension, reason); | 1122 UnloadedExtensionInfo details(extension, reason); |
| 1117 | 1123 |
| 1118 registry_->TriggerOnUnloaded(extension, reason); | 1124 registry_->TriggerOnUnloaded(extension, reason); |
| 1119 | 1125 |
| 1120 content::NotificationService::current()->Notify( | 1126 content::NotificationService::current()->Notify( |
| 1121 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, | 1127 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
| 1122 content::Source<Profile>(profile_), | 1128 content::Source<Profile>(profile_), |
| 1123 content::Details<UnloadedExtensionInfo>(&details)); | 1129 content::Details<UnloadedExtensionInfo>(&details)); |
| 1124 | 1130 |
| 1131 if (reason != UnloadedExtensionInfo::REASON_UPDATE && | |
| 1132 reason != UnloadedExtensionInfo::REASON_LOCK_ALL) { | |
| 1133 ThemeServiceFactory::GetForProfile(profile_) | |
| 1134 ->extension_observer() | |
| 1135 .OnExtensionUnloaded(extension); | |
| 1136 } | |
| 1137 | |
| 1125 for (content::RenderProcessHost::iterator i( | 1138 for (content::RenderProcessHost::iterator i( |
| 1126 content::RenderProcessHost::AllHostsIterator()); | 1139 content::RenderProcessHost::AllHostsIterator()); |
| 1127 !i.IsAtEnd(); i.Advance()) { | 1140 !i.IsAtEnd(); i.Advance()) { |
| 1128 content::RenderProcessHost* host = i.GetCurrentValue(); | 1141 content::RenderProcessHost* host = i.GetCurrentValue(); |
| 1129 Profile* host_profile = | 1142 Profile* host_profile = |
| 1130 Profile::FromBrowserContext(host->GetBrowserContext()); | 1143 Profile::FromBrowserContext(host->GetBrowserContext()); |
| 1131 if (host_profile->GetOriginalProfile() == profile_->GetOriginalProfile()) | 1144 if (host_profile->GetOriginalProfile() == profile_->GetOriginalProfile()) |
| 1132 host->Send(new ExtensionMsg_Unloaded(extension->id())); | 1145 host->Send(new ExtensionMsg_Unloaded(extension->id())); |
| 1133 } | 1146 } |
| 1134 | 1147 |
| (...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1975 extensions::InstalledExtensionInfo details( | 1988 extensions::InstalledExtensionInfo details( |
| 1976 extension, is_update, from_ephemeral, old_name); | 1989 extension, is_update, from_ephemeral, old_name); |
| 1977 content::NotificationService::current()->Notify( | 1990 content::NotificationService::current()->Notify( |
| 1978 extensions::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED, | 1991 extensions::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED, |
| 1979 content::Source<Profile>(profile_), | 1992 content::Source<Profile>(profile_), |
| 1980 content::Details<const extensions::InstalledExtensionInfo>(&details)); | 1993 content::Details<const extensions::InstalledExtensionInfo>(&details)); |
| 1981 | 1994 |
| 1982 registry_->TriggerOnWillBeInstalled( | 1995 registry_->TriggerOnWillBeInstalled( |
| 1983 extension, is_update, from_ephemeral, old_name); | 1996 extension, is_update, from_ephemeral, old_name); |
| 1984 | 1997 |
| 1998 ThemeServiceFactory::GetForProfile(profile_) | |
| 1999 ->extension_observer() | |
| 2000 .OnExtensionWillBeInstalled(extension); | |
| 2001 | |
| 1985 // Unpacked extensions default to allowing file access, but if that has been | 2002 // Unpacked extensions default to allowing file access, but if that has been |
| 1986 // overridden, don't reset the value. | 2003 // overridden, don't reset the value. |
| 1987 if (Manifest::ShouldAlwaysAllowFileAccess(extension->location()) && | 2004 if (Manifest::ShouldAlwaysAllowFileAccess(extension->location()) && |
| 1988 !extension_prefs_->HasAllowFileAccessSetting(extension->id())) { | 2005 !extension_prefs_->HasAllowFileAccessSetting(extension->id())) { |
| 1989 extension_prefs_->SetAllowFileAccess(extension->id(), true); | 2006 extension_prefs_->SetAllowFileAccess(extension->id(), true); |
| 1990 } | 2007 } |
| 1991 | 2008 |
| 1992 AddExtension(extension); | 2009 AddExtension(extension); |
| 1993 | 2010 |
| 1994 // Notify observers that need to know when an installation is complete. | 2011 // Notify observers that need to know when an installation is complete. |
| (...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2582 } | 2599 } |
| 2583 | 2600 |
| 2584 void ExtensionService::OnProfileDestructionStarted() { | 2601 void ExtensionService::OnProfileDestructionStarted() { |
| 2585 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); | 2602 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); |
| 2586 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); | 2603 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); |
| 2587 it != ids_to_unload.end(); | 2604 it != ids_to_unload.end(); |
| 2588 ++it) { | 2605 ++it) { |
| 2589 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); | 2606 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); |
| 2590 } | 2607 } |
| 2591 } | 2608 } |
| OLD | NEW |