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

Unified Diff: chrome/browser/extensions/api/notifications/notifications_api.cc

Issue 18662006: Support creating progress bar notification for Windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix per feedbacks Created 7 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 | « no previous file | chrome/browser/extensions/api/notifications/notifications_apitest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/notifications/notifications_api.cc
diff --git a/chrome/browser/extensions/api/notifications/notifications_api.cc b/chrome/browser/extensions/api/notifications/notifications_api.cc
index d0a580015a5fb38d683e805d8cb83d275e2a7c79..8dd419765b5e2aee079583e30ae42cba78062ba3 100644
--- a/chrome/browser/extensions/api/notifications/notifications_api.cc
+++ b/chrome/browser/extensions/api/notifications/notifications_api.cc
@@ -34,6 +34,10 @@ namespace extensions {
namespace {
const char kResultKey[] = "result";
+const char kUnexpectedProgressValueForNonProgressType[] =
+ "The progress value should not be specified for non-progress notification";
+const char kInvalidProgressValue[] =
+ "The progress value should range from 0 to 100";
// Converts an object with width, height, and data in RGBA format into an
// gfx::Image (in ARGB format).
@@ -276,6 +280,20 @@ bool NotificationsApiFunction::CreateNotification(
if (has_list_items != (type == message_center::NOTIFICATION_TYPE_MULTIPLE))
return false;
+ if (options->progress.get() != NULL) {
+ // We should have progress if and only if the type is a progress type.
+ if (type != message_center::NOTIFICATION_TYPE_PROGRESS) {
+ SetError(kUnexpectedProgressValueForNonProgressType);
+ return false;
+ }
+ optional_fields.progress = *options->progress;
+ // Progress value should range from 0 to 100.
+ if (optional_fields.progress < 0 || optional_fields.progress > 100) {
+ SetError(kInvalidProgressValue);
+ return false;
+ }
+ }
+
if (has_list_items) {
using api::notifications::NotificationItem;
std::vector<linked_ptr<NotificationItem> >::iterator i;
@@ -333,6 +351,8 @@ NotificationsApiFunction::MapApiTemplateTypeToType(
return message_center::NOTIFICATION_TYPE_IMAGE;
case api::notifications::TEMPLATE_TYPE_LIST:
return message_center::NOTIFICATION_TYPE_MULTIPLE;
+ case api::notifications::TEMPLATE_TYPE_PROGRESS:
+ return message_center::NOTIFICATION_TYPE_PROGRESS;
default:
// Gracefully handle newer application code that is running on an older
// runtime that doesn't recognize the requested template.
« no previous file with comments | « no previous file | chrome/browser/extensions/api/notifications/notifications_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698