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

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

Issue 10941003: Reset registered events and dispatch runtime.onInstalled to all extensions when (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ? Created 8 years, 3 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: 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 e9f0a3c7e7e257a0f592dec083384eb319ff5d02..08ae99d2802d6c9c8c96c78e9bb7edd716d946f7 100644
--- a/chrome/browser/extensions/api/runtime/runtime_api.cc
+++ b/chrome/browser/extensions/api/runtime/runtime_api.cc
@@ -25,6 +25,7 @@ const char kOnInstalledEvent[] = "runtime.onInstalled";
const char kNoBackgroundPageError[] = "You do not have a background page.";
const char kPageLoadError[] = "Background page failed to load.";
const char kInstallReason[] = "reason";
+const char kInstallReasonChromeUpdate[] = "chrome_update";
const char kInstallReasonUpdate[] = "update";
const char kInstallReasonInstall[] = "install";
const char kInstallPreviousVersion[] = "previousVersion";
@@ -78,7 +79,8 @@ void RuntimeEventRouter::DispatchOnStartupEvent(
void RuntimeEventRouter::DispatchOnInstalledEvent(
Profile* profile,
const std::string& extension_id,
- const Version& old_version) {
+ const Version& old_version,
+ bool chrome_updated) {
ExtensionSystem* system = ExtensionSystem::Get(profile);
if (!system)
return;
@@ -91,10 +93,14 @@ void RuntimeEventRouter::DispatchOnInstalledEvent(
scoped_ptr<base::ListValue> event_args(new ListValue());
base::DictionaryValue* info = new base::DictionaryValue();
event_args->Append(info);
- info->SetString(kInstallReason,
- old_version.IsValid() ? kInstallReasonUpdate : kInstallReasonInstall);
- if (old_version.IsValid())
+ if (old_version.IsValid()) {
+ info->SetString(kInstallReason, kInstallReasonUpdate);
info->SetString(kInstallPreviousVersion, old_version.GetString());
+ } else if (chrome_updated) {
+ info->SetString(kInstallReason, kInstallReasonChromeUpdate);
+ } else {
+ info->SetString(kInstallReason, kInstallReasonInstall);
+ }
system->event_router()->AddLazyEventListener(kOnInstalledEvent, extension_id);
system->event_router()->DispatchEventToExtension(
extension_id, kOnInstalledEvent, event_args.Pass(), NULL, GURL());

Powered by Google App Engine
This is Rietveld 408576698