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

Unified Diff: chrome/browser/ui/webui/ntp/app_launcher_handler.cc

Issue 7187023: Adding an experimental app notification API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: make linkText required if linkUrl is passed Created 9 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
« no previous file with comments | « chrome/browser/ui/webui/ntp/app_launcher_handler.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/ntp/app_launcher_handler.cc
diff --git a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
index 633faf7d6ca8aff3c54b44a91aa41b7f0e8b84fe..dcab901a801daf52bec1ad08c4a966703c3cc112 100644
--- a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
+++ b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
@@ -75,6 +75,7 @@ AppLauncherHandler::~AppLauncherHandler() {}
// static
void AppLauncherHandler::CreateAppInfo(const Extension* extension,
+ const AppNotificationList* notifications,
ExtensionPrefs* prefs,
DictionaryValue* value) {
bool enabled =
@@ -109,6 +110,16 @@ void AppLauncherHandler::CreateAppInfo(const Extension* extension,
value->SetBoolean("is_component",
extension->location() == Extension::COMPONENT);
+ if (notifications && !notifications->empty()) {
+ AppNotification* n = (*notifications->rbegin()).get();
Evan Stade 2011/06/22 19:36:23 is this not the same as notifications->rbegin()->g
asargent_no_longer_on_chrome 2011/06/23 22:36:24 Yes, good point. (I reworked the code - this moved
+ value->SetString("title", n->title);
+ value->SetString("body", n->body);
+ if (!n->linkUrl.is_empty()) {
+ value->SetString("linkUrl", n->linkUrl.spec());
+ value->SetString("linkText", n->linkText);
+ }
+ }
+
int app_launch_index = prefs->GetAppLaunchIndex(extension->id());
if (app_launch_index == -1) {
// Make sure every app has a launch index (some predate the launch index).
@@ -198,6 +209,7 @@ void AppLauncherHandler::Observe(NotificationType type,
return;
switch (type.value) {
+ case NotificationType::APP_NOTIFICATION_STATE_CHANGED:
Evan Stade 2011/06/22 19:36:23 I don't think you want to nuke the entirety of the
asargent_no_longer_on_chrome 2011/06/23 22:36:24 Good catch - I had thrown this in there as a quick
case NotificationType::EXTENSION_LOADED:
case NotificationType::EXTENSION_UNLOADED:
case NotificationType::EXTENSION_LAUNCHER_REORDERED:
@@ -228,10 +240,16 @@ void AppLauncherHandler::FillAppDictionary(DictionaryValue* dictionary) {
for (it = extensions->begin(); it != extensions->end(); ++it) {
// Don't include the WebStore.
// The WebStore launcher gets special treatment in ntp/apps.js.
- if ((*it)->is_app() &&
- (*it)->id() != extension_misc::kWebStoreAppId) {
+ const Extension* extension = *it;
+ if (extension->is_app() &&
+ extension->id() != extension_misc::kWebStoreAppId) {
DictionaryValue* app_info = new DictionaryValue();
- CreateAppInfo(*it, extensions_service_->extension_prefs(), app_info);
+ AppNotificationManager* notification_manager =
+ extensions_service_->app_notification_manager();
+ CreateAppInfo(extension,
+ notification_manager->GetAll(extension->id()),
+ extensions_service_->extension_prefs(),
+ app_info);
list->Append(app_info);
}
}
@@ -241,7 +259,10 @@ void AppLauncherHandler::FillAppDictionary(DictionaryValue* dictionary) {
if ((*it)->is_app() &&
(*it)->id() != extension_misc::kWebStoreAppId) {
DictionaryValue* app_info = new DictionaryValue();
- CreateAppInfo(*it, extensions_service_->extension_prefs(), app_info);
+ CreateAppInfo(*it,
+ NULL,
+ extensions_service_->extension_prefs(),
+ app_info);
list->Append(app_info);
}
}
@@ -314,6 +335,8 @@ void AppLauncherHandler::HandleGetApps(const ListValue* args) {
// First time we get here we set up the observer so that we can tell update
// the apps as they change.
if (registrar_.IsEmpty()) {
+ registrar_.Add(this, NotificationType::APP_NOTIFICATION_STATE_CHANGED,
+ NotificationService::AllSources());
registrar_.Add(this, NotificationType::EXTENSION_LOADED,
NotificationService::AllSources());
registrar_.Add(this, NotificationType::EXTENSION_UNLOADED,
« no previous file with comments | « chrome/browser/ui/webui/ntp/app_launcher_handler.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698