summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhshi@chromium.org <hshi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-26 00:41:08 +0000
committerhshi@chromium.org <hshi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-26 00:41:08 +0000
commit92dd8d9098630afb9768bb4f8d2f14596919641b (patch)
tree33b48f9aef57f6bdcfc0e72ec5619539a1a2325c
parent39af20a68318ad297d6a889ecb7dae67080cd89f (diff)
downloadchromium_src-92dd8d9098630afb9768bb4f8d2f14596919641b.zip
chromium_src-92dd8d9098630afb9768bb4f8d2f14596919641b.tar.gz
chromium_src-92dd8d9098630afb9768bb4f8d2f14596919641b.tar.bz2
Add runtime.onBrowserUpdateAvailable event.
BUG=177029 TEST=manually verified on device that event is received when a new image is available on my dev update server. Review URL: https://chromiumcodereview.appspot.com/12316006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@184531 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/extensions/api/runtime/runtime_api.cc16
-rw-r--r--chrome/browser/extensions/api/runtime/runtime_api.h3
-rw-r--r--chrome/browser/extensions/extension_service.cc8
-rw-r--r--chrome/common/extensions/api/runtime.json6
4 files changed, 33 insertions, 0 deletions
diff --git a/chrome/browser/extensions/api/runtime/runtime_api.cc b/chrome/browser/extensions/api/runtime/runtime_api.cc
index 4629804..328ef22 100644
--- a/chrome/browser/extensions/api/runtime/runtime_api.cc
+++ b/chrome/browser/extensions/api/runtime/runtime_api.cc
@@ -24,6 +24,8 @@ namespace {
const char kOnStartupEvent[] = "runtime.onStartup";
const char kOnInstalledEvent[] = "runtime.onInstalled";
const char kOnUpdateAvailableEvent[] = "runtime.onUpdateAvailable";
+const char kOnBrowserUpdateAvailableEvent[] =
+ "runtime.onBrowserUpdateAvailable";
const char kNoBackgroundPageError[] = "You do not have a background page.";
const char kPageLoadError[] = "Background page failed to load.";
const char kInstallReason[] = "reason";
@@ -131,6 +133,20 @@ void RuntimeEventRouter::DispatchOnUpdateAvailableEvent(
system->event_router()->DispatchEventToExtension(extension_id, event.Pass());
}
+// static
+void RuntimeEventRouter::DispatchOnBrowserUpdateAvailableEvent(
+ Profile* profile) {
+ ExtensionSystem* system = ExtensionSystem::Get(profile);
+ if (!system)
+ return;
+
+ scoped_ptr<ListValue> args(new ListValue);
+ DCHECK(system->event_router());
+ scoped_ptr<Event> event(new Event(kOnBrowserUpdateAvailableEvent,
+ args.Pass()));
+ system->event_router()->BroadcastEvent(event.Pass());
+}
+
bool RuntimeGetBackgroundPageFunction::RunImpl() {
ExtensionSystem* system = ExtensionSystem::Get(profile());
ExtensionHost* host = system->process_manager()->
diff --git a/chrome/browser/extensions/api/runtime/runtime_api.h b/chrome/browser/extensions/api/runtime/runtime_api.h
index 23b3b2f..d118386 100644
--- a/chrome/browser/extensions/api/runtime/runtime_api.h
+++ b/chrome/browser/extensions/api/runtime/runtime_api.h
@@ -31,6 +31,9 @@ class RuntimeEventRouter {
Profile* profile,
const std::string& extension_id,
const base::DictionaryValue* manifest);
+
+ // Dispatches the onBrowserUpdateAvailable event to all extensions.
+ static void DispatchOnBrowserUpdateAvailableEvent(Profile* profile);
};
class RuntimeGetBackgroundPageFunction : public AsyncExtensionFunction {
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index f4f7997..9b52fc3 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -379,6 +379,8 @@ ExtensionService::ExtensionService(Profile* profile,
content::NotificationService::AllBrowserContextsAndSources());
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED,
content::NotificationService::AllBrowserContextsAndSources());
+ registrar_.Add(this, chrome::NOTIFICATION_UPGRADE_RECOMMENDED,
+ content::NotificationService::AllBrowserContextsAndSources());
pref_change_registrar_.Init(profile->GetPrefs());
base::Closure callback =
base::Bind(&ExtensionService::OnExtensionInstallPrefChanged,
@@ -2748,6 +2750,12 @@ void ExtensionService::Observe(int type,
}
break;
}
+ case chrome::NOTIFICATION_UPGRADE_RECOMMENDED: {
+ // Notify extensions that chrome update is available.
+ extensions::RuntimeEventRouter::DispatchOnBrowserUpdateAvailableEvent(
+ profile_);
+ break;
+ }
default:
NOTREACHED() << "Unexpected notification type.";
diff --git a/chrome/common/extensions/api/runtime.json b/chrome/common/extensions/api/runtime.json
index a35ed1e..6608dc6 100644
--- a/chrome/common/extensions/api/runtime.json
+++ b/chrome/common/extensions/api/runtime.json
@@ -307,6 +307,12 @@
]
},
{
+ "name": "onBrowserUpdateAvailable",
+ "type": "function",
+ "description": "Fired when a Chrome update is available, but isn't installed immediately because a browser restart is required.",
+ "parameters": []
+ },
+ {
"name": "onConnect",
"type": "function",
"unprivileged": true,