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

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

Issue 317993003: Send an onInstalled event for shared module update (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 6 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
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 74222cd98f5c9714ab03b37ab5326c78460f9a33..733ea1f8daa069c8628cdf4752ccc4d3cf7b417a 100644
--- a/extensions/browser/api/runtime/runtime_api.cc
+++ b/extensions/browser/api/runtime/runtime_api.cc
@@ -32,6 +32,7 @@
#include "extensions/common/error_utils.h"
#include "extensions/common/extension.h"
#include "extensions/common/manifest_handlers/background_info.h"
+#include "extensions/common/manifest_handlers/shared_module_info.h"
#include "url/gurl.h"
#include "webkit/browser/fileapi/isolated_context.h"
@@ -45,10 +46,12 @@ namespace {
const char kNoBackgroundPageError[] = "You do not have a background page.";
const char kPageLoadError[] = "Background page failed to load.";
+const char kInstallId[] = "id";
const char kInstallReason[] = "reason";
const char kInstallReasonChromeUpdate[] = "chrome_update";
const char kInstallReasonUpdate[] = "update";
const char kInstallReasonInstall[] = "install";
+const char kInstallReasonSharedModuleUpdate[] = "shared_module_update";
const char kInstallPreviousVersion[] = "previousVersion";
const char kInvalidUrlError[] = "Invalid URL.";
const char kPlatformInfoUnavailable[] = "Platform information unavailable.";
@@ -334,6 +337,30 @@ void RuntimeEventRouter::DispatchOnInstalledEvent(
new Event(runtime::OnInstalled::kEventName, event_args.Pass()));
system->event_router()->DispatchEventWithLazyListener(extension_id,
event.Pass());
+
+ if (old_version.IsValid()) {
+ const Extension* extension =
+ ExtensionRegistry::Get(context)->enabled_extensions().GetByID(
+ extension_id);
+ if (extension && SharedModuleInfo::IsSharedModule(extension)) {
+ scoped_ptr<ExtensionSet> dependents =
+ system->GetDependentExtensions(extension);
+ for (ExtensionSet::const_iterator i = dependents->begin();
+ i != dependents->end();
+ i++) {
+ scoped_ptr<base::ListValue> sm_event_args(new base::ListValue());
+ base::DictionaryValue* sm_info = new base::DictionaryValue();
+ sm_event_args->Append(sm_info);
+ sm_info->SetString(kInstallReason, kInstallReasonSharedModuleUpdate);
+ sm_info->SetString(kInstallPreviousVersion, old_version.GetString());
+ sm_info->SetString(kInstallId, extension_id);
+ scoped_ptr<Event> sm_event(
+ new Event(runtime::OnInstalled::kEventName, sm_event_args.Pass()));
+ system->event_router()->DispatchEventWithLazyListener((*i)->id(),
+ sm_event.Pass());
+ }
+ }
+ }
}
// static
« no previous file with comments | « chrome/test/data/extensions/api_test/shared_module/import_pass/check.js ('k') | extensions/browser/extension_system.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698