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

Unified Diff: chrome/browser/extensions/api/runtime/runtime_api.cc

Issue 212603020: Break extensions ProcessManager dependency on Runtime API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase (pm-observer) Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/api/runtime/runtime_api.h ('k') | extensions/browser/process_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/runtime/runtime_api.cc
diff --git a/chrome/browser/extensions/api/runtime/runtime_api.cc b/chrome/browser/extensions/api/runtime/runtime_api.cc
index 3545291a3ab7e1d64d05a1aa102b0a567e2d8acf..3b050d9bdefd0c9395d1395ce4b1f947da1c6351 100644
--- a/chrome/browser/extensions/api/runtime/runtime_api.cc
+++ b/chrome/browser/extensions/api/runtime/runtime_api.cc
@@ -211,8 +211,16 @@ void RuntimeAPI::OnExtensionsReady() {
registered_for_updates_ = true;
- ExtensionSystem::Get(browser_context_)->extension_service()->
- AddUpdateObserver(this);
+ ExtensionSystem* extension_system = ExtensionSystem::Get(browser_context_);
+ extension_system->extension_service()->AddUpdateObserver(this);
+
+ // RuntimeAPI is redirected in incognito, so |browser_context_| is never
+ // incognito. We don't observe incognito ProcessManagers but that is OK
+ // because we don't send onStartup events to incognito browser contexts.
+ DCHECK(!browser_context_->IsOffTheRecord());
+ // Some tests use partially constructed Profiles without a process manager.
+ if (extension_system->process_manager())
+ extension_system->process_manager()->AddObserver(this);
}
void RuntimeAPI::OnExtensionLoaded(const Extension* extension) {
@@ -264,6 +272,16 @@ void RuntimeAPI::OnExtensionUninstalled(const Extension* extension) {
RuntimeEventRouter::OnExtensionUninstalled(profile, extension->id());
}
+void RuntimeAPI::Shutdown() {
+ // ExtensionSystem deletes its ProcessManager during the Shutdown() phase, so
+ // the observer must be removed here and not in the RuntimeAPI destructor.
+ ProcessManager* process_manager =
+ ExtensionSystem::Get(browser_context_)->process_manager();
+ // Some tests use partially constructed Profiles without a process manager.
+ if (process_manager)
+ process_manager->RemoveObserver(this);
+}
+
void RuntimeAPI::OnAppUpdateAvailable(const Extension* extension) {
Profile* profile = Profile::FromBrowserContext(browser_context_);
RuntimeEventRouter::DispatchOnUpdateAvailableEvent(
@@ -275,6 +293,10 @@ void RuntimeAPI::OnChromeUpdateAvailable() {
RuntimeEventRouter::DispatchOnBrowserUpdateAvailableEvent(profile);
}
+void RuntimeAPI::OnBackgroundHostStartup(const Extension* extension) {
+ RuntimeEventRouter::DispatchOnStartupEvent(browser_context_, extension->id());
+}
+
///////////////////////////////////////////////////////////////////////////////
// static
« no previous file with comments | « chrome/browser/extensions/api/runtime/runtime_api.h ('k') | extensions/browser/process_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698