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

Unified Diff: ui/message_center/notification.h

Issue 1292003004: Elide origins displayed on web notifications. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move origin_url to message_center::Notification Created 5 years, 4 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 | « ui/message_center/message_center_tray_unittest.cc ('k') | ui/message_center/notification.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/message_center/notification.h
diff --git a/ui/message_center/notification.h b/ui/message_center/notification.h
index 122cd6760629823e67d51cc789869a27269cad54..6bfa769610e160786e8bb974f408436921b9fe84 100644
--- a/ui/message_center/notification.h
+++ b/ui/message_center/notification.h
@@ -16,6 +16,7 @@
#include "ui/message_center/notification_delegate.h"
#include "ui/message_center/notification_types.h"
#include "ui/message_center/notifier_settings.h"
+#include "url/gurl.h"
namespace message_center {
@@ -33,6 +34,13 @@ struct MESSAGE_CENTER_EXPORT ButtonInfo {
ButtonInfo(const base::string16& title);
};
+struct MESSAGE_CENTER_EXPORT ContextMessage {
+ ContextMessage(base::string16 msg, bool use_origin)
+ : message(msg), use_origin_as_context(use_origin) {}
+ base::string16 message;
+ bool use_origin_as_context;
Jun Mukai 2015/08/18 18:28:48 I really want to eliminate this flag (and the stru
Miguel Garcia 2015/08/19 15:02:59 Following our chat yesterday I implemented the cha
+};
+
class MESSAGE_CENTER_EXPORT RichNotificationData {
public:
RichNotificationData();
@@ -42,7 +50,7 @@ class MESSAGE_CENTER_EXPORT RichNotificationData {
int priority;
bool never_timeout;
base::Time timestamp;
- base::string16 context_message;
+ ContextMessage context_message;
gfx::Image image;
gfx::Image small_image;
std::vector<NotificationItem> items;
@@ -62,6 +70,7 @@ class MESSAGE_CENTER_EXPORT Notification {
const base::string16& message,
const gfx::Image& icon,
const base::string16& display_source,
+ const GURL& origin_url,
const NotifierId& notifier_id,
const RichNotificationData& optional_fields,
NotificationDelegate* delegate);
@@ -92,6 +101,11 @@ class MESSAGE_CENTER_EXPORT Notification {
const base::string16& message() const { return message_; }
void set_message(const base::string16& message) { message_ = message; }
+ // The origin URL of the script which requested the notification.
+ // Can be empty if the notification is requested by an extension or
+ // Chrome app.
+ const GURL& origin_url() const { return origin_url_; }
+
// A display string for the source of the notification.
const base::string16& display_source() const { return display_source_; }
@@ -123,11 +137,15 @@ class MESSAGE_CENTER_EXPORT Notification {
optional_fields_.timestamp = timestamp;
}
- const base::string16& context_message() const {
+ const ContextMessage context_message() const {
return optional_fields_.context_message;
}
- void set_context_message(const base::string16& context_message) {
- optional_fields_.context_message = context_message;
+
+ void set_context_message(const base::string16& context_message,
+ bool use_origin_as_context) {
+ optional_fields_.context_message.message = context_message;
+ optional_fields_.context_message.use_origin_as_context =
+ use_origin_as_context;
}
const std::vector<NotificationItem>& items() const {
@@ -233,6 +251,10 @@ class MESSAGE_CENTER_EXPORT Notification {
base::string16 display_source_;
private:
+ // The origin URL of the script which requested the notification.
+ // Can be empty if requested through a chrome app or extension or if
+ // it's a system notification.
+ GURL origin_url_;
NotifierId notifier_id_;
unsigned serial_number_;
RichNotificationData optional_fields_;
« no previous file with comments | « ui/message_center/message_center_tray_unittest.cc ('k') | ui/message_center/notification.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698