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

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

Issue 2211213002: Revert of [Extensions] Ensure ordering of extension [un]loaded, activated messages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 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
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <iterator> 10 #include <iterator>
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 #include "content/public/browser/render_process_host.h" 67 #include "content/public/browser/render_process_host.h"
68 #include "content/public/browser/storage_partition.h" 68 #include "content/public/browser/storage_partition.h"
69 #include "extensions/browser/app_sorting.h" 69 #include "extensions/browser/app_sorting.h"
70 #include "extensions/browser/event_router.h" 70 #include "extensions/browser/event_router.h"
71 #include "extensions/browser/extension_host.h" 71 #include "extensions/browser/extension_host.h"
72 #include "extensions/browser/extension_registry.h" 72 #include "extensions/browser/extension_registry.h"
73 #include "extensions/browser/extension_system.h" 73 #include "extensions/browser/extension_system.h"
74 #include "extensions/browser/extensions_browser_client.h" 74 #include "extensions/browser/extensions_browser_client.h"
75 #include "extensions/browser/external_install_info.h" 75 #include "extensions/browser/external_install_info.h"
76 #include "extensions/browser/install_flag.h" 76 #include "extensions/browser/install_flag.h"
77 #include "extensions/browser/renderer_startup_helper.h"
78 #include "extensions/browser/runtime_data.h" 77 #include "extensions/browser/runtime_data.h"
79 #include "extensions/browser/uninstall_reason.h" 78 #include "extensions/browser/uninstall_reason.h"
80 #include "extensions/browser/update_observer.h" 79 #include "extensions/browser/update_observer.h"
81 #include "extensions/browser/updater/extension_cache.h" 80 #include "extensions/browser/updater/extension_cache.h"
82 #include "extensions/browser/updater/extension_downloader.h" 81 #include "extensions/browser/updater/extension_downloader.h"
83 #include "extensions/common/extension_messages.h" 82 #include "extensions/common/extension_messages.h"
84 #include "extensions/common/extension_urls.h" 83 #include "extensions/common/extension_urls.h"
85 #include "extensions/common/feature_switch.h" 84 #include "extensions/common/feature_switch.h"
86 #include "extensions/common/file_util.h" 85 #include "extensions/common/file_util.h"
87 #include "extensions/common/manifest_constants.h" 86 #include "extensions/common/manifest_constants.h"
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 profile_(profile), 302 profile_(profile),
304 system_(extensions::ExtensionSystem::Get(profile)), 303 system_(extensions::ExtensionSystem::Get(profile)),
305 extension_prefs_(extension_prefs), 304 extension_prefs_(extension_prefs),
306 blacklist_(blacklist), 305 blacklist_(blacklist),
307 registry_(extensions::ExtensionRegistry::Get(profile)), 306 registry_(extensions::ExtensionRegistry::Get(profile)),
308 pending_extension_manager_(profile), 307 pending_extension_manager_(profile),
309 install_directory_(install_directory), 308 install_directory_(install_directory),
310 extensions_enabled_(extensions_enabled), 309 extensions_enabled_(extensions_enabled),
311 ready_(ready), 310 ready_(ready),
312 shared_module_service_(new extensions::SharedModuleService(profile_)), 311 shared_module_service_(new extensions::SharedModuleService(profile_)),
313 renderer_helper_(
314 extensions::RendererStartupHelperFactory::GetForBrowserContext(
315 profile_)),
316 app_data_migrator_(new extensions::AppDataMigrator(profile_, registry_)) { 312 app_data_migrator_(new extensions::AppDataMigrator(profile_, registry_)) {
317 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 313 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
318 TRACE_EVENT0("browser,startup", "ExtensionService::ExtensionService::ctor"); 314 TRACE_EVENT0("browser,startup", "ExtensionService::ExtensionService::ctor");
319 315
320 // Figure out if extension installation should be enabled. 316 // Figure out if extension installation should be enabled.
321 if (extensions::ExtensionsBrowserClient::Get()->AreExtensionsDisabled( 317 if (extensions::ExtensionsBrowserClient::Get()->AreExtensionsDisabled(
322 *command_line, profile)) 318 *command_line, profile))
323 extensions_enabled_ = false; 319 extensions_enabled_ = false;
324 320
325 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING, 321 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING,
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 // was loaded, otherwise a race can arise where a renderer that is created 1023 // was loaded, otherwise a race can arise where a renderer that is created
1028 // for the extension may try to load an extension URL with an extension id 1024 // for the extension may try to load an extension URL with an extension id
1029 // that the request context doesn't yet know about. The profile is responsible 1025 // that the request context doesn't yet know about. The profile is responsible
1030 // for ensuring its URLRequestContexts appropriately discover the loaded 1026 // for ensuring its URLRequestContexts appropriately discover the loaded
1031 // extension. 1027 // extension.
1032 system_->RegisterExtensionWithRequestContexts( 1028 system_->RegisterExtensionWithRequestContexts(
1033 extension, 1029 extension,
1034 base::Bind(&ExtensionService::OnExtensionRegisteredWithRequestContexts, 1030 base::Bind(&ExtensionService::OnExtensionRegisteredWithRequestContexts,
1035 AsWeakPtr(), make_scoped_refptr(extension))); 1031 AsWeakPtr(), make_scoped_refptr(extension)));
1036 1032
1037 renderer_helper_->OnExtensionLoaded(*extension); 1033 // Tell renderers about the new extension, unless it's a theme (renderers
1034 // don't need to know about themes).
1035 if (!extension->is_theme()) {
1036 for (content::RenderProcessHost::iterator i(
1037 content::RenderProcessHost::AllHostsIterator());
1038 !i.IsAtEnd(); i.Advance()) {
1039 content::RenderProcessHost* host = i.GetCurrentValue();
1040 Profile* host_profile =
1041 Profile::FromBrowserContext(host->GetBrowserContext());
1042 if (host_profile->GetOriginalProfile() ==
1043 profile_->GetOriginalProfile()) {
1044 // We don't need to include tab permisisons here, since the extension
1045 // was just loaded.
1046 std::vector<ExtensionMsg_Loaded_Params> loaded_extensions(
1047 1, ExtensionMsg_Loaded_Params(extension,
1048 false /* no tab permissions */));
1049 host->Send(
1050 new ExtensionMsg_Loaded(loaded_extensions));
1051 }
1052 }
1053 }
1038 1054
1039 // Tell subsystems that use the EXTENSION_LOADED notification about the new 1055 // Tell subsystems that use the EXTENSION_LOADED notification about the new
1040 // extension. 1056 // extension.
1041 // 1057 //
1042 // NOTE: It is important that this happen after notifying the renderers about 1058 // NOTE: It is important that this happen after notifying the renderers about
1043 // the new extensions so that if we navigate to an extension URL in 1059 // the new extensions so that if we navigate to an extension URL in
1044 // ExtensionRegistryObserver::OnLoaded or 1060 // ExtensionRegistryObserver::OnLoaded or
1045 // NOTIFICATION_EXTENSION_LOADED_DEPRECATED, the 1061 // NOTIFICATION_EXTENSION_LOADED_DEPRECATED, the
1046 // renderer is guaranteed to know about it. 1062 // renderer is guaranteed to know about it.
1047 registry_->TriggerOnLoaded(extension); 1063 registry_->TriggerOnLoaded(extension);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1099 UnloadedExtensionInfo::Reason reason) { 1115 UnloadedExtensionInfo::Reason reason) {
1100 UnloadedExtensionInfo details(extension, reason); 1116 UnloadedExtensionInfo details(extension, reason);
1101 1117
1102 registry_->TriggerOnUnloaded(extension, reason); 1118 registry_->TriggerOnUnloaded(extension, reason);
1103 1119
1104 content::NotificationService::current()->Notify( 1120 content::NotificationService::current()->Notify(
1105 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, 1121 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
1106 content::Source<Profile>(profile_), 1122 content::Source<Profile>(profile_),
1107 content::Details<UnloadedExtensionInfo>(&details)); 1123 content::Details<UnloadedExtensionInfo>(&details));
1108 1124
1109 renderer_helper_->OnExtensionUnloaded(extension->id()); 1125 for (content::RenderProcessHost::iterator i(
1126 content::RenderProcessHost::AllHostsIterator());
1127 !i.IsAtEnd(); i.Advance()) {
1128 content::RenderProcessHost* host = i.GetCurrentValue();
1129 Profile* host_profile =
1130 Profile::FromBrowserContext(host->GetBrowserContext());
1131 if (host_profile->GetOriginalProfile() == profile_->GetOriginalProfile())
1132 host->Send(new ExtensionMsg_Unloaded(extension->id()));
1133 }
1110 1134
1111 system_->UnregisterExtensionWithRequestContexts(extension->id(), reason); 1135 system_->UnregisterExtensionWithRequestContexts(extension->id(), reason);
1112 1136
1113 // TODO(kalman): Convert ExtensionSpecialStoragePolicy to a 1137 // TODO(kalman): Convert ExtensionSpecialStoragePolicy to a
1114 // BrowserContextKeyedService and use ExtensionRegistryObserver. 1138 // BrowserContextKeyedService and use ExtensionRegistryObserver.
1115 profile_->GetExtensionSpecialStoragePolicy()-> 1139 profile_->GetExtensionSpecialStoragePolicy()->
1116 RevokeRightsForExtension(extension); 1140 RevokeRightsForExtension(extension);
1117 1141
1118 #if defined(OS_CHROMEOS) 1142 #if defined(OS_CHROMEOS)
1119 // Revoke external file access for the extension from its file system context. 1143 // Revoke external file access for the extension from its file system context.
(...skipping 1323 matching lines...) Expand 10 before | Expand all | Expand 10 after
2443 } 2467 }
2444 2468
2445 void ExtensionService::OnProfileDestructionStarted() { 2469 void ExtensionService::OnProfileDestructionStarted() {
2446 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); 2470 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs();
2447 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); 2471 for (ExtensionIdSet::iterator it = ids_to_unload.begin();
2448 it != ids_to_unload.end(); 2472 it != ids_to_unload.end();
2449 ++it) { 2473 ++it) {
2450 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); 2474 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN);
2451 } 2475 }
2452 } 2476 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service.h ('k') | chrome/browser/extensions/renderer_initialization_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698