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

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

Issue 425303002: Move extension notifications to extensions/browser/notification_types.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: (extension-notifications) rebase Created 6 years, 4 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 | Annotate | Revision Log
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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 shared_module_service_(new extensions::SharedModuleService(profile_)) { 262 shared_module_service_(new extensions::SharedModuleService(profile_)) {
263 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 263 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
264 264
265 // Figure out if extension installation should be enabled. 265 // Figure out if extension installation should be enabled.
266 if (extensions::ExtensionsBrowserClient::Get()->AreExtensionsDisabled( 266 if (extensions::ExtensionsBrowserClient::Get()->AreExtensionsDisabled(
267 *command_line, profile)) 267 *command_line, profile))
268 extensions_enabled_ = false; 268 extensions_enabled_ = false;
269 269
270 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING, 270 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING,
271 content::NotificationService::AllBrowserContextsAndSources()); 271 content::NotificationService::AllBrowserContextsAndSources());
272 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, 272 registrar_.Add(this,
273 extensions::NOTIFICATION_EXTENSION_PROCESS_TERMINATED,
273 content::NotificationService::AllBrowserContextsAndSources()); 274 content::NotificationService::AllBrowserContextsAndSources());
274 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, 275 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
275 content::NotificationService::AllBrowserContextsAndSources()); 276 content::NotificationService::AllBrowserContextsAndSources());
276 registrar_.Add(this, chrome::NOTIFICATION_UPGRADE_RECOMMENDED, 277 registrar_.Add(this, chrome::NOTIFICATION_UPGRADE_RECOMMENDED,
277 content::NotificationService::AllBrowserContextsAndSources()); 278 content::NotificationService::AllBrowserContextsAndSources());
278 registrar_.Add(this, 279 registrar_.Add(this,
279 chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, 280 chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED,
280 content::Source<Profile>(profile_)); 281 content::Source<Profile>(profile_));
281 pref_change_registrar_.Init(profile->GetPrefs()); 282 pref_change_registrar_.Init(profile->GetPrefs());
282 base::Closure callback = 283 base::Closure callback =
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 bool external_uninstall = 701 bool external_uninstall =
701 (reason == extensions::UNINSTALL_REASON_INTERNAL_MANAGEMENT) || 702 (reason == extensions::UNINSTALL_REASON_INTERNAL_MANAGEMENT) ||
702 (reason == extensions::UNINSTALL_REASON_ORPHANED_EXTERNAL_EXTENSION) || 703 (reason == extensions::UNINSTALL_REASON_ORPHANED_EXTERNAL_EXTENSION) ||
703 (reason == extensions::UNINSTALL_REASON_ORPHANED_SHARED_MODULE) || 704 (reason == extensions::UNINSTALL_REASON_ORPHANED_SHARED_MODULE) ||
704 (reason == extensions::UNINSTALL_REASON_SYNC && 705 (reason == extensions::UNINSTALL_REASON_SYNC &&
705 extension->was_installed_by_custodian()); 706 extension->was_installed_by_custodian());
706 if (!external_uninstall && 707 if (!external_uninstall &&
707 !system_->management_policy()->UserMayModifySettings( 708 !system_->management_policy()->UserMayModifySettings(
708 extension.get(), error)) { 709 extension.get(), error)) {
709 content::NotificationService::current()->Notify( 710 content::NotificationService::current()->Notify(
710 chrome::NOTIFICATION_EXTENSION_UNINSTALL_NOT_ALLOWED, 711 extensions::NOTIFICATION_EXTENSION_UNINSTALL_NOT_ALLOWED,
711 content::Source<Profile>(profile_), 712 content::Source<Profile>(profile_),
712 content::Details<const Extension>(extension.get())); 713 content::Details<const Extension>(extension.get()));
713 return false; 714 return false;
714 } 715 }
715 716
716 syncer::SyncChange sync_change; 717 syncer::SyncChange sync_change;
717 if (extension_sync_service_) { 718 if (extension_sync_service_) {
718 sync_change = extension_sync_service_->PrepareToSyncUninstallExtension( 719 sync_change = extension_sync_service_->PrepareToSyncUninstallExtension(
719 extension.get(), is_ready()); 720 extension.get(), is_ready());
720 } 721 }
(...skipping 21 matching lines...) Expand all
742 NOTREACHED(); 743 NOTREACHED();
743 } 744 }
744 745
745 extensions::DataDeleter::StartDeleting( 746 extensions::DataDeleter::StartDeleting(
746 profile_, extension.get(), deletion_done_callback); 747 profile_, extension.get(), deletion_done_callback);
747 748
748 UntrackTerminatedExtension(extension->id()); 749 UntrackTerminatedExtension(extension->id());
749 750
750 // Notify interested parties that we've uninstalled this extension. 751 // Notify interested parties that we've uninstalled this extension.
751 content::NotificationService::current()->Notify( 752 content::NotificationService::current()->Notify(
752 chrome::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED, 753 extensions::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED,
753 content::Source<Profile>(profile_), 754 content::Source<Profile>(profile_),
754 content::Details<const Extension>(extension.get())); 755 content::Details<const Extension>(extension.get()));
755 ExtensionRegistry::Get(profile_) 756 ExtensionRegistry::Get(profile_)
756 ->TriggerOnUninstalled(extension.get(), reason); 757 ->TriggerOnUninstalled(extension.get(), reason);
757 758
758 if (extension_sync_service_) { 759 if (extension_sync_service_) {
759 extension_sync_service_->ProcessSyncUninstallExtension(extension->id(), 760 extension_sync_service_->ProcessSyncUninstallExtension(extension->id(),
760 sync_change); 761 sync_change);
761 } 762 }
762 763
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 return; 825 return;
825 826
826 // Move it over to the enabled list. 827 // Move it over to the enabled list.
827 registry_->AddEnabled(make_scoped_refptr(extension)); 828 registry_->AddEnabled(make_scoped_refptr(extension));
828 registry_->RemoveDisabled(extension->id()); 829 registry_->RemoveDisabled(extension->id());
829 830
830 NotifyExtensionLoaded(extension); 831 NotifyExtensionLoaded(extension);
831 832
832 // Notify listeners that the extension was enabled. 833 // Notify listeners that the extension was enabled.
833 content::NotificationService::current()->Notify( 834 content::NotificationService::current()->Notify(
834 chrome::NOTIFICATION_EXTENSION_ENABLED, 835 extensions::NOTIFICATION_EXTENSION_ENABLED,
835 content::Source<Profile>(profile_), 836 content::Source<Profile>(profile_),
836 content::Details<const Extension>(extension)); 837 content::Details<const Extension>(extension));
837 838
838 if (extension_sync_service_) 839 if (extension_sync_service_)
839 extension_sync_service_->SyncEnableExtension(*extension); 840 extension_sync_service_->SyncEnableExtension(*extension);
840 } 841 }
841 842
842 void ExtensionService::DisableExtension( 843 void ExtensionService::DisableExtension(
843 const std::string& extension_id, 844 const std::string& extension_id,
844 Extension::DisableReason disable_reason) { 845 Extension::DisableReason disable_reason) {
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 // extension. 991 // extension.
991 // 992 //
992 // NOTE: It is important that this happen after notifying the renderers about 993 // NOTE: It is important that this happen after notifying the renderers about
993 // the new extensions so that if we navigate to an extension URL in 994 // the new extensions so that if we navigate to an extension URL in
994 // ExtensionRegistryObserver::OnLoaded or 995 // ExtensionRegistryObserver::OnLoaded or
995 // NOTIFICATION_EXTENSION_LOADED_DEPRECATED, the 996 // NOTIFICATION_EXTENSION_LOADED_DEPRECATED, the
996 // renderer is guaranteed to know about it. 997 // renderer is guaranteed to know about it.
997 registry_->TriggerOnLoaded(extension); 998 registry_->TriggerOnLoaded(extension);
998 999
999 content::NotificationService::current()->Notify( 1000 content::NotificationService::current()->Notify(
1000 chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, 1001 extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED,
1001 content::Source<Profile>(profile_), 1002 content::Source<Profile>(profile_),
1002 content::Details<const Extension>(extension)); 1003 content::Details<const Extension>(extension));
1003 1004
1004 // TODO(kalman): Convert ExtensionSpecialStoragePolicy to a 1005 // TODO(kalman): Convert ExtensionSpecialStoragePolicy to a
1005 // BrowserContextKeyedService and use ExtensionRegistryObserver. 1006 // BrowserContextKeyedService and use ExtensionRegistryObserver.
1006 profile_->GetExtensionSpecialStoragePolicy()-> 1007 profile_->GetExtensionSpecialStoragePolicy()->
1007 GrantRightsForExtension(extension); 1008 GrantRightsForExtension(extension);
1008 1009
1009 // TODO(kalman): This is broken. The crash reporter is process-wide so doesn't 1010 // TODO(kalman): This is broken. The crash reporter is process-wide so doesn't
1010 // work properly multi-profile. Besides which, it should be using 1011 // work properly multi-profile. Besides which, it should be using
(...skipping 29 matching lines...) Expand all
1040 } 1041 }
1041 1042
1042 void ExtensionService::NotifyExtensionUnloaded( 1043 void ExtensionService::NotifyExtensionUnloaded(
1043 const Extension* extension, 1044 const Extension* extension,
1044 UnloadedExtensionInfo::Reason reason) { 1045 UnloadedExtensionInfo::Reason reason) {
1045 UnloadedExtensionInfo details(extension, reason); 1046 UnloadedExtensionInfo details(extension, reason);
1046 1047
1047 registry_->TriggerOnUnloaded(extension, reason); 1048 registry_->TriggerOnUnloaded(extension, reason);
1048 1049
1049 content::NotificationService::current()->Notify( 1050 content::NotificationService::current()->Notify(
1050 chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, 1051 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
1051 content::Source<Profile>(profile_), 1052 content::Source<Profile>(profile_),
1052 content::Details<UnloadedExtensionInfo>(&details)); 1053 content::Details<UnloadedExtensionInfo>(&details));
1053 1054
1054 for (content::RenderProcessHost::iterator i( 1055 for (content::RenderProcessHost::iterator i(
1055 content::RenderProcessHost::AllHostsIterator()); 1056 content::RenderProcessHost::AllHostsIterator());
1056 !i.IsAtEnd(); i.Advance()) { 1057 !i.IsAtEnd(); i.Advance()) {
1057 content::RenderProcessHost* host = i.GetCurrentValue(); 1058 content::RenderProcessHost* host = i.GetCurrentValue();
1058 Profile* host_profile = 1059 Profile* host_profile =
1059 Profile::FromBrowserContext(host->GetBrowserContext()); 1060 Profile::FromBrowserContext(host->GetBrowserContext());
1060 if (host_profile->GetOriginalProfile() == profile_->GetOriginalProfile()) 1061 if (host_profile->GetOriginalProfile() == profile_->GetOriginalProfile())
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1273 system_->UnregisterExtensionWithRequestContexts(extension_id, reason); 1274 system_->UnregisterExtensionWithRequestContexts(extension_id, reason);
1274 // Don't send the unloaded notification. It was sent when the extension 1275 // Don't send the unloaded notification. It was sent when the extension
1275 // was disabled. 1276 // was disabled.
1276 } else { 1277 } else {
1277 // Remove the extension from the enabled list. 1278 // Remove the extension from the enabled list.
1278 registry_->RemoveEnabled(extension->id()); 1279 registry_->RemoveEnabled(extension->id());
1279 NotifyExtensionUnloaded(extension.get(), reason); 1280 NotifyExtensionUnloaded(extension.get(), reason);
1280 } 1281 }
1281 1282
1282 content::NotificationService::current()->Notify( 1283 content::NotificationService::current()->Notify(
1283 chrome::NOTIFICATION_EXTENSION_REMOVED, 1284 extensions::NOTIFICATION_EXTENSION_REMOVED,
1284 content::Source<Profile>(profile_), 1285 content::Source<Profile>(profile_),
1285 content::Details<const Extension>(extension.get())); 1286 content::Details<const Extension>(extension.get()));
1286 } 1287 }
1287 1288
1288 void ExtensionService::RemoveComponentExtension( 1289 void ExtensionService::RemoveComponentExtension(
1289 const std::string& extension_id) { 1290 const std::string& extension_id) {
1290 scoped_refptr<const Extension> extension( 1291 scoped_refptr<const Extension> extension(
1291 GetExtensionById(extension_id, false)); 1292 GetExtensionById(extension_id, false));
1292 UnloadExtension(extension_id, UnloadedExtensionInfo::REASON_UNINSTALL); 1293 UnloadExtension(extension_id, UnloadedExtensionInfo::REASON_UNINSTALL);
1293 if (extension.get()) { 1294 if (extension.get()) {
1294 content::NotificationService::current()->Notify( 1295 content::NotificationService::current()->Notify(
1295 chrome::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED, 1296 extensions::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED,
1296 content::Source<Profile>(profile_), 1297 content::Source<Profile>(profile_),
1297 content::Details<const Extension>(extension.get())); 1298 content::Details<const Extension>(extension.get()));
1298 ExtensionRegistry::Get(profile_)->TriggerOnUninstalled( 1299 ExtensionRegistry::Get(profile_)->TriggerOnUninstalled(
1299 extension.get(), extensions::UNINSTALL_REASON_INTERNAL_MANAGEMENT); 1300 extension.get(), extensions::UNINSTALL_REASON_INTERNAL_MANAGEMENT);
1300 } 1301 }
1301 } 1302 }
1302 1303
1303 void ExtensionService::UnloadAllExtensionsForTest() { 1304 void ExtensionService::UnloadAllExtensionsForTest() {
1304 UnloadAllExtensionsInternal(); 1305 UnloadAllExtensionsInternal();
1305 } 1306 }
1306 1307
1307 void ExtensionService::ReloadExtensionsForTest() { 1308 void ExtensionService::ReloadExtensionsForTest() {
1308 // Calling UnloadAllExtensionsForTest here triggers a false-positive presubmit 1309 // Calling UnloadAllExtensionsForTest here triggers a false-positive presubmit
1309 // warning about calling test code in production. 1310 // warning about calling test code in production.
1310 UnloadAllExtensionsInternal(); 1311 UnloadAllExtensionsInternal();
1311 component_loader_->LoadAll(); 1312 component_loader_->LoadAll();
1312 extensions::InstalledLoader(this).LoadAllExtensions(); 1313 extensions::InstalledLoader(this).LoadAllExtensions();
1313 // Don't call SetReadyAndNotifyListeners() since tests call this multiple 1314 // Don't call SetReadyAndNotifyListeners() since tests call this multiple
1314 // times. 1315 // times.
1315 } 1316 }
1316 1317
1317 void ExtensionService::SetReadyAndNotifyListeners() { 1318 void ExtensionService::SetReadyAndNotifyListeners() {
1318 ready_->Signal(); 1319 ready_->Signal();
1319 content::NotificationService::current()->Notify( 1320 content::NotificationService::current()->Notify(
1320 chrome::NOTIFICATION_EXTENSIONS_READY, 1321 extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED,
1321 content::Source<Profile>(profile_), 1322 content::Source<Profile>(profile_),
1322 content::NotificationService::NoDetails()); 1323 content::NotificationService::NoDetails());
1323 } 1324 }
1324 1325
1325 void ExtensionService::OnLoadedInstalledExtensions() { 1326 void ExtensionService::OnLoadedInstalledExtensions() {
1326 #if defined(ENABLE_EXTENSIONS) 1327 #if defined(ENABLE_EXTENSIONS)
1327 if (updater_) 1328 if (updater_)
1328 updater_->Start(); 1329 updater_->Start();
1329 1330
1330 OnBlacklistUpdated(); 1331 OnBlacklistUpdated();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1381 // blacklist before calling into here, e.g. CrxInstaller checks before 1382 // blacklist before calling into here, e.g. CrxInstaller checks before
1382 // installation then threads through the install and pending install flow 1383 // installation then threads through the install and pending install flow
1383 // of this class, and we check when loading installed extensions. 1384 // of this class, and we check when loading installed extensions.
1384 registry_->AddBlacklisted(extension); 1385 registry_->AddBlacklisted(extension);
1385 } else if (!reloading && 1386 } else if (!reloading &&
1386 extension_prefs_->IsExtensionDisabled(extension->id())) { 1387 extension_prefs_->IsExtensionDisabled(extension->id())) {
1387 registry_->AddDisabled(extension); 1388 registry_->AddDisabled(extension);
1388 if (extension_sync_service_) 1389 if (extension_sync_service_)
1389 extension_sync_service_->SyncExtensionChangeIfNeeded(*extension); 1390 extension_sync_service_->SyncExtensionChangeIfNeeded(*extension);
1390 content::NotificationService::current()->Notify( 1391 content::NotificationService::current()->Notify(
1391 chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, 1392 extensions::NOTIFICATION_EXTENSION_UPDATE_DISABLED,
1392 content::Source<Profile>(profile_), 1393 content::Source<Profile>(profile_),
1393 content::Details<const Extension>(extension)); 1394 content::Details<const Extension>(extension));
1394 1395
1395 // Show the extension disabled error if a permissions increase or a remote 1396 // Show the extension disabled error if a permissions increase or a remote
1396 // installation is the reason it was disabled, and no other reasons exist. 1397 // installation is the reason it was disabled, and no other reasons exist.
1397 int reasons = extension_prefs_->GetDisableReasons(extension->id()); 1398 int reasons = extension_prefs_->GetDisableReasons(extension->id());
1398 const int kReasonMask = Extension::DISABLE_PERMISSIONS_INCREASE | 1399 const int kReasonMask = Extension::DISABLE_PERMISSIONS_INCREASE |
1399 Extension::DISABLE_REMOTE_INSTALL; 1400 Extension::DISABLE_REMOTE_INSTALL;
1400 if (reasons & kReasonMask && !(reasons & ~kReasonMask)) { 1401 if (reasons & kReasonMask && !(reasons & ~kReasonMask)) {
1401 extensions::AddExtensionDisabledError( 1402 extensions::AddExtensionDisabledError(
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
1785 std::string old_name; 1786 std::string old_name;
1786 if (existing_extension) { 1787 if (existing_extension) {
1787 is_update = true; 1788 is_update = true;
1788 old_name = existing_extension->name(); 1789 old_name = existing_extension->name();
1789 } 1790 }
1790 bool from_ephemeral = 1791 bool from_ephemeral =
1791 was_ephemeral && !extension_prefs_->IsEphemeralApp(extension->id()); 1792 was_ephemeral && !extension_prefs_->IsEphemeralApp(extension->id());
1792 extensions::InstalledExtensionInfo details( 1793 extensions::InstalledExtensionInfo details(
1793 extension, is_update, from_ephemeral, old_name); 1794 extension, is_update, from_ephemeral, old_name);
1794 content::NotificationService::current()->Notify( 1795 content::NotificationService::current()->Notify(
1795 chrome::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED, 1796 extensions::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED,
1796 content::Source<Profile>(profile_), 1797 content::Source<Profile>(profile_),
1797 content::Details<const extensions::InstalledExtensionInfo>(&details)); 1798 content::Details<const extensions::InstalledExtensionInfo>(&details));
1798 1799
1799 registry_->TriggerOnWillBeInstalled( 1800 registry_->TriggerOnWillBeInstalled(
1800 extension, is_update, from_ephemeral, old_name); 1801 extension, is_update, from_ephemeral, old_name);
1801 1802
1802 // Unpacked extensions default to allowing file access, but if that has been 1803 // Unpacked extensions default to allowing file access, but if that has been
1803 // overridden, don't reset the value. 1804 // overridden, don't reset the value.
1804 if (Manifest::ShouldAlwaysAllowFileAccess(extension->location()) && 1805 if (Manifest::ShouldAlwaysAllowFileAccess(extension->location()) &&
1805 !extension_prefs_->HasAllowFileAccessSetting(extension->id())) { 1806 !extension_prefs_->HasAllowFileAccessSetting(extension->id())) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1847 extension_prefs_->OnEphemeralAppPromoted(extension->id()); 1848 extension_prefs_->OnEphemeralAppPromoted(extension->id());
1848 1849
1849 // Fire install-related events to allow observers to handle the promotion 1850 // Fire install-related events to allow observers to handle the promotion
1850 // of the ephemeral app. 1851 // of the ephemeral app.
1851 extensions::InstalledExtensionInfo details( 1852 extensions::InstalledExtensionInfo details(
1852 extension, 1853 extension,
1853 true /* is update */, 1854 true /* is update */,
1854 true /* from ephemeral */, 1855 true /* from ephemeral */,
1855 extension->name() /* old name */); 1856 extension->name() /* old name */);
1856 content::NotificationService::current()->Notify( 1857 content::NotificationService::current()->Notify(
1857 chrome::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED, 1858 extensions::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED,
1858 content::Source<Profile>(profile_), 1859 content::Source<Profile>(profile_),
1859 content::Details<const extensions::InstalledExtensionInfo>(&details)); 1860 content::Details<const extensions::InstalledExtensionInfo>(&details));
1860 1861
1861 registry_->TriggerOnWillBeInstalled( 1862 registry_->TriggerOnWillBeInstalled(
1862 extension, 1863 extension,
1863 true /* is update */, 1864 true /* is update */,
1864 true /* from ephemeral */, 1865 true /* from ephemeral */,
1865 extension->name() /* old name */); 1866 extension->name() /* old name */);
1866 1867
1867 if (registry_->enabled_extensions().Contains(extension->id())) { 1868 if (registry_->enabled_extensions().Contains(extension->id())) {
1868 content::NotificationService::current()->Notify( 1869 content::NotificationService::current()->Notify(
1869 chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, 1870 extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED,
1870 content::Source<Profile>(profile_), 1871 content::Source<Profile>(profile_),
1871 content::Details<const Extension>(extension)); 1872 content::Details<const Extension>(extension));
1872 1873
1873 registry_->TriggerOnLoaded(extension); 1874 registry_->TriggerOnLoaded(extension);
1874 } 1875 }
1875 1876
1876 registry_->TriggerOnInstalled(extension, true); 1877 registry_->TriggerOnInstalled(extension, true);
1877 1878
1878 if (!is_from_sync && extension_sync_service_) 1879 if (!is_from_sync && extension_sync_service_)
1879 extension_sync_service_->SyncExtensionChangeIfNeeded(*extension); 1880 extension_sync_service_->SyncExtensionChangeIfNeeded(*extension);
(...skipping 16 matching lines...) Expand all
1896 TrackTerminatedExtension(extension); 1897 TrackTerminatedExtension(extension);
1897 } 1898 }
1898 1899
1899 void ExtensionService::UntrackTerminatedExtension(const std::string& id) { 1900 void ExtensionService::UntrackTerminatedExtension(const std::string& id) {
1900 std::string lowercase_id = StringToLowerASCII(id); 1901 std::string lowercase_id = StringToLowerASCII(id);
1901 const Extension* extension = 1902 const Extension* extension =
1902 registry_->terminated_extensions().GetByID(lowercase_id); 1903 registry_->terminated_extensions().GetByID(lowercase_id);
1903 registry_->RemoveTerminated(lowercase_id); 1904 registry_->RemoveTerminated(lowercase_id);
1904 if (extension) { 1905 if (extension) {
1905 content::NotificationService::current()->Notify( 1906 content::NotificationService::current()->Notify(
1906 chrome::NOTIFICATION_EXTENSION_REMOVED, 1907 extensions::NOTIFICATION_EXTENSION_REMOVED,
1907 content::Source<Profile>(profile_), 1908 content::Source<Profile>(profile_),
1908 content::Details<const Extension>(extension)); 1909 content::Details<const Extension>(extension));
1909 } 1910 }
1910 } 1911 }
1911 1912
1912 const Extension* ExtensionService::GetInstalledExtension( 1913 const Extension* ExtensionService::GetInstalledExtension(
1913 const std::string& id) const { 1914 const std::string& id) const {
1914 return registry_->GetExtensionById(id, ExtensionRegistry::EVERYTHING); 1915 return registry_->GetExtensionById(id, ExtensionRegistry::EVERYTHING);
1915 } 1916 }
1916 1917
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
2005 void ExtensionService::Observe(int type, 2006 void ExtensionService::Observe(int type,
2006 const content::NotificationSource& source, 2007 const content::NotificationSource& source,
2007 const content::NotificationDetails& details) { 2008 const content::NotificationDetails& details) {
2008 switch (type) { 2009 switch (type) {
2009 case chrome::NOTIFICATION_APP_TERMINATING: 2010 case chrome::NOTIFICATION_APP_TERMINATING:
2010 // Shutdown has started. Don't start any more extension installs. 2011 // Shutdown has started. Don't start any more extension installs.
2011 // (We cannot use ExtensionService::Shutdown() for this because it 2012 // (We cannot use ExtensionService::Shutdown() for this because it
2012 // happens too late in browser teardown.) 2013 // happens too late in browser teardown.)
2013 browser_terminating_ = true; 2014 browser_terminating_ = true;
2014 break; 2015 break;
2015 case chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED: { 2016 case extensions::NOTIFICATION_EXTENSION_PROCESS_TERMINATED: {
2016 if (profile_ != 2017 if (profile_ !=
2017 content::Source<Profile>(source).ptr()->GetOriginalProfile()) { 2018 content::Source<Profile>(source).ptr()->GetOriginalProfile()) {
2018 break; 2019 break;
2019 } 2020 }
2020 2021
2021 extensions::ExtensionHost* host = 2022 extensions::ExtensionHost* host =
2022 content::Details<extensions::ExtensionHost>(details).ptr(); 2023 content::Details<extensions::ExtensionHost>(details).ptr();
2023 2024
2024 // If the extension is already being terminated, there is nothing left to 2025 // If the extension is already being terminated, there is nothing left to
2025 // do. 2026 // do.
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
2332 } 2333 }
2333 2334
2334 void ExtensionService::OnProfileDestructionStarted() { 2335 void ExtensionService::OnProfileDestructionStarted() {
2335 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); 2336 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs();
2336 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); 2337 for (ExtensionIdSet::iterator it = ids_to_unload.begin();
2337 it != ids_to_unload.end(); 2338 it != ids_to_unload.end();
2338 ++it) { 2339 ++it) {
2339 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); 2340 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN);
2340 } 2341 }
2341 } 2342 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_notification_observer.cc ('k') | chrome/browser/extensions/extension_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698