summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordewittj@chromium.org <dewittj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-19 16:44:01 +0000
committerdewittj@chromium.org <dewittj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-19 16:44:01 +0000
commit1dbbf1651b07c57ee9dfce78aa1b76753283b381 (patch)
treeb6ceb46734224b921466075a2d6f6974fb52bcad
parentfc1b01cae5e0aa6cd1301891cd71ba2c50612893 (diff)
downloadchromium_src-1dbbf1651b07c57ee9dfce78aa1b76753283b381.zip
chromium_src-1dbbf1651b07c57ee9dfce78aa1b76753283b381.tar.gz
chromium_src-1dbbf1651b07c57ee9dfce78aa1b76753283b381.tar.bz2
Adds a hint to the notifications API that a notification is clickable.
The former behavior was that all notifications would be shown as if they were clickable if the app had any onClick handler installed. This patch changes the behavior - if isClickable is false, then the notification body will not appear clickable even if there is an onClick handler installed. Also fixes a bug where buttons don't appear to have the clickable cursor. BUG=304923 Review URL: https://codereview.chromium.org/27569003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@229585 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/extensions/api/notifications/notifications_api.cc11
-rw-r--r--chrome/common/extensions/api/notifications.idl4
-rw-r--r--ui/message_center/notification.cc6
-rw-r--r--ui/message_center/notification.h8
-rw-r--r--ui/message_center/views/notification_view.cc5
-rw-r--r--ui/message_center/views/notification_view.h3
6 files changed, 32 insertions, 5 deletions
diff --git a/chrome/browser/extensions/api/notifications/notifications_api.cc b/chrome/browser/extensions/api/notifications/notifications_api.cc
index 3fa8c76..1625432 100644
--- a/chrome/browser/extensions/api/notifications/notifications_api.cc
+++ b/chrome/browser/extensions/api/notifications/notifications_api.cc
@@ -323,6 +323,9 @@ bool NotificationsApiFunction::CreateNotification(
}
}
+ if (options->is_clickable.get())
+ optional_fields.clickable = *options->is_clickable;
+
NotificationsApiDelegate* api_delegate(new NotificationsApiDelegate(
this,
profile(),
@@ -435,6 +438,10 @@ bool NotificationsApiFunction::UpdateNotification(
}
}
+ // Then override if it's already set.
+ if (options->is_clickable.get())
+ notification->set_clickable(*options->is_clickable);
+
g_browser_process->notification_ui_manager()->Update(
*notification, profile());
return true;
@@ -531,11 +538,13 @@ bool NotificationsUpdateFunction::RunNotificationsApi() {
return true;
}
+ // Copy the existing notification to get a writable version of it.
+ Notification notification = *matched_notification;
+
// If we have trouble updating the notification (could be improper use of API
// or some other reason), mark the function as failed, calling the callback
// with false.
// TODO(dewittj): Add more human-readable error strings if this fails.
- Notification notification = *matched_notification;
bool could_update_notification = UpdateNotification(
params_->notification_id, &params_->options, &notification);
SetResult(new base::FundamentalValue(could_update_notification));
diff --git a/chrome/common/extensions/api/notifications.idl b/chrome/common/extensions/api/notifications.idl
index 504cda9..85ae00a 100644
--- a/chrome/common/extensions/api/notifications.idl
+++ b/chrome/common/extensions/api/notifications.idl
@@ -79,6 +79,10 @@ namespace notifications {
// Current progress ranges from 0 to 100.
long? progress;
+
+ // Whether to show UI indicating that the app will visibly respond to
+ // clicks on the body of a notification.
+ boolean? isClickable;
};
callback CreateCallback = void (DOMString notificationId);
diff --git a/ui/message_center/notification.cc b/ui/message_center/notification.cc
index e17667c..c7b2f98 100644
--- a/ui/message_center/notification.cc
+++ b/ui/message_center/notification.cc
@@ -29,7 +29,8 @@ RichNotificationData::RichNotificationData()
never_timeout(false),
timestamp(base::Time::Now()),
progress(0),
- should_make_spoken_feedback_for_popup_updates(true) {}
+ should_make_spoken_feedback_for_popup_updates(true),
+ clickable(true) {}
RichNotificationData::RichNotificationData(const RichNotificationData& other)
: priority(other.priority),
@@ -42,7 +43,8 @@ RichNotificationData::RichNotificationData(const RichNotificationData& other)
progress(other.progress),
buttons(other.buttons),
should_make_spoken_feedback_for_popup_updates(
- other.should_make_spoken_feedback_for_popup_updates) {}
+ other.should_make_spoken_feedback_for_popup_updates),
+ clickable(other.clickable) {}
RichNotificationData::~RichNotificationData() {}
diff --git a/ui/message_center/notification.h b/ui/message_center/notification.h
index f61d6d6..99cd39d 100644
--- a/ui/message_center/notification.h
+++ b/ui/message_center/notification.h
@@ -49,6 +49,7 @@ class MESSAGE_CENTER_EXPORT RichNotificationData {
int progress;
std::vector<ButtonInfo> buttons;
bool should_make_spoken_feedback_for_popup_updates;
+ bool clickable;
};
class MESSAGE_CENTER_EXPORT Notification {
@@ -158,7 +159,14 @@ class MESSAGE_CENTER_EXPORT Notification {
}
bool never_timeout() const { return optional_fields_.never_timeout; }
+
+ bool clickable() const { return optional_fields_.clickable; }
+ void set_clickable(bool clickable) {
+ optional_fields_.clickable = clickable;
+ }
+
NotificationDelegate* delegate() const { return delegate_.get(); }
+
const RichNotificationData& rich_notification_data() const {
return optional_fields_;
}
diff --git a/ui/message_center/views/notification_view.cc b/ui/message_center/views/notification_view.cc
index 11b3474..a362505 100644
--- a/ui/message_center/views/notification_view.cc
+++ b/ui/message_center/views/notification_view.cc
@@ -455,7 +455,8 @@ NotificationView::NotificationView(const Notification& notification,
MessageCenter* message_center,
MessageCenterTray* tray,
bool expanded)
- : MessageView(notification, message_center, tray, expanded) {
+ : MessageView(notification, message_center, tray, expanded),
+ clickable_(notification.clickable()){
std::vector<string16> accessible_lines;
// Create the opaque background that's above the view's shadow.
@@ -712,7 +713,7 @@ views::View* NotificationView::GetEventHandlerForPoint(
}
gfx::NativeCursor NotificationView::GetCursor(const ui::MouseEvent& event) {
- if (!message_center()->HasClickedListener(notification_id()))
+ if (!clickable_ || !message_center()->HasClickedListener(notification_id()))
return views::View::GetCursor(event);
#if defined(USE_AURA)
diff --git a/ui/message_center/views/notification_view.h b/ui/message_center/views/notification_view.h
index 5479939..e130a30 100644
--- a/ui/message_center/views/notification_view.h
+++ b/ui/message_center/views/notification_view.h
@@ -66,6 +66,9 @@ class MESSAGE_CENTER_EXPORT NotificationView : public MessageView {
int GetMessageLines(int width, int limit);
int GetMessageHeight(int width, int limit);
+ // Describes whether the view should display a hand pointer or not.
+ bool clickable_;
+
// Weak references to NotificationView descendants owned by their parents.
views::View* background_view_;
views::View* top_view_;