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

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

Issue 406063002: Hook up runtime API to implement ExtensionRegistryObserver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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 | « extensions/browser/api/runtime/runtime_api.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/api/runtime/runtime_api.cc
diff --git a/extensions/browser/api/runtime/runtime_api.cc b/extensions/browser/api/runtime/runtime_api.cc
index fcd68014dede89b02ea7bb6adc0c105e0087b70e..21d6fd35e334a1c6b6fae5b3930427f05cdc3253 100644
--- a/extensions/browser/api/runtime/runtime_api.cc
+++ b/extensions/browser/api/runtime/runtime_api.cc
@@ -137,19 +137,13 @@ BrowserContextKeyedAPIFactory<RuntimeAPI>* RuntimeAPI::GetFactoryInstance() {
}
RuntimeAPI::RuntimeAPI(content::BrowserContext* context)
- : browser_context_(context), dispatch_chrome_updated_event_(false) {
+ : browser_context_(context),
+ extension_registry_observer_(this),
+ dispatch_chrome_updated_event_(false) {
registrar_.Add(this,
chrome::NOTIFICATION_EXTENSIONS_READY,
content::Source<BrowserContext>(context));
- registrar_.Add(this,
- chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED,
- content::Source<BrowserContext>(context));
- registrar_.Add(this,
- chrome::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED,
- content::Source<BrowserContext>(context));
- registrar_.Add(this,
- chrome::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED,
- content::Source<BrowserContext>(context));
+ extension_registry_observer_.Add(ExtensionRegistry::Get(browser_context_));
delegate_ = ExtensionsBrowserClient::Get()->CreateRuntimeAPIDelegate(
browser_context_);
@@ -172,30 +166,33 @@ void RuntimeAPI::Observe(int type,
OnExtensionsReady();
break;
}
- case chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: {
- const Extension* extension =
- content::Details<const Extension>(details).ptr();
- OnExtensionLoaded(extension);
- break;
- }
- case chrome::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED: {
- const Extension* extension =
- content::Details<const InstalledExtensionInfo>(details)->extension;
- OnExtensionInstalled(extension);
- break;
- }
- case chrome::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED: {
- const Extension* extension =
- content::Details<const Extension>(details).ptr();
- OnExtensionUninstalled(extension);
- break;
- }
default:
NOTREACHED();
break;
}
}
+void RuntimeAPI::OnExtensionLoaded(content::BrowserContext* browser_context,
+ const Extension* extension) {
+ OnExtensionLoaded(extension);
Devlin 2014/07/22 00:26:59 Let's put the OnExtensionLoaded method body in her
rpaquay 2014/07/22 16:34:21 Done.
+}
+
+void RuntimeAPI::OnExtensionWillBeInstalled(
+ content::BrowserContext* browser_context,
+ const Extension* extension,
+ bool is_update,
+ bool from_ephemeral,
+ const std::string& old_name) {
+ OnExtensionInstalled(extension);
+}
+
+void RuntimeAPI::OnExtensionUninstalled(
+ content::BrowserContext* browser_context,
+ const Extension* extension,
+ UninstallReason reason) {
+ OnExtensionUninstalled(extension, reason);
+}
+
void RuntimeAPI::OnExtensionsReady() {
// We're done restarting Chrome after an update.
dispatch_chrome_updated_event_ = false;
@@ -244,13 +241,15 @@ void RuntimeAPI::OnExtensionInstalled(const Extension* extension) {
false));
}
-void RuntimeAPI::OnExtensionUninstalled(const Extension* extension) {
+void RuntimeAPI::OnExtensionUninstalled(const Extension* extension,
+ UninstallReason reason) {
// Ephemeral apps are not considered to be installed, so the uninstall URL
// is not invoked when they are removed.
if (util::IsEphemeralApp(extension->id(), browser_context_))
return;
- RuntimeEventRouter::OnExtensionUninstalled(browser_context_, extension->id());
+ RuntimeEventRouter::OnExtensionUninstalled(
+ browser_context_, extension->id(), reason);
}
void RuntimeAPI::Shutdown() {
@@ -412,7 +411,13 @@ void RuntimeEventRouter::DispatchOnRestartRequiredEvent(
// static
void RuntimeEventRouter::OnExtensionUninstalled(
content::BrowserContext* context,
- const std::string& extension_id) {
+ const std::string& extension_id,
+ UninstallReason reason) {
+ bool open_uninstall_url = (reason == UNINSTALL_REASON_USER_INITIATED) ||
+ (reason == UNINSTALL_REASON_MANAGEMENT_API);
Devlin 2014/07/22 00:26:59 I think it's readable enough to inline this in the
rpaquay 2014/07/22 16:34:21 Done.
+ if (!open_uninstall_url)
+ return;
+
GURL uninstall_url(
GetUninstallURL(ExtensionPrefs::Get(context), extension_id));
« no previous file with comments | « extensions/browser/api/runtime/runtime_api.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698