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

Unified Diff: chrome/browser/notifications/notification.cc

Issue 14631005: Enable users of NotificationUIManager to specify binary images. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix extension_id handling. Created 7 years, 7 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
Index: chrome/browser/notifications/notification.cc
diff --git a/chrome/browser/notifications/notification.cc b/chrome/browser/notifications/notification.cc
index 3e24b23e2d353f65a2e006e74c50e750bacd42ec..e15ac0a228ff471cc70da8494b4f9903f3901f00 100644
--- a/chrome/browser/notifications/notification.cc
+++ b/chrome/browser/notifications/notification.cc
@@ -4,18 +4,28 @@
#include "chrome/browser/notifications/notification.h"
+#include "base/string_util.h"
#include "chrome/browser/notifications/desktop_notification_service.h"
+#include "ui/message_center/message_center_util.h"
+#include "ui/webui/web_ui_util.h"
Notification::Notification(const GURL& origin_url,
const GURL& content_url,
const string16& display_source,
const string16& replace_id,
NotificationDelegate* delegate)
- : type_(message_center::NOTIFICATION_TYPE_SIMPLE),
+ : message_center::Notification(message_center::NOTIFICATION_TYPE_SIMPLE,
+ delegate->id(),
+ EmptyString16(),
+ EmptyString16(),
+ gfx::Image(),
+ display_source,
+ origin_url.spec(),
+ NULL,
+ delegate),
origin_url_(origin_url),
is_html_(true),
content_url_(content_url),
- display_source_(display_source),
replace_id_(replace_id),
delegate_(delegate) {}
@@ -27,13 +37,18 @@ Notification::Notification(const GURL& origin_url,
const string16& display_source,
const string16& replace_id,
NotificationDelegate* delegate)
- : type_(message_center::NOTIFICATION_TYPE_SIMPLE),
+ : message_center::Notification(message_center::NOTIFICATION_TYPE_SIMPLE,
+ delegate->id(),
+ title,
+ body,
+ gfx::Image(),
+ display_source,
+ origin_url.spec(),
+ NULL,
+ delegate),
origin_url_(origin_url),
icon_url_(icon_url),
is_html_(false),
- title_(title),
- body_(body),
- display_source_(display_source),
replace_id_(replace_id),
delegate_(delegate) {
// "Upconvert" the string parameters to a data: URL.
@@ -51,13 +66,18 @@ Notification::Notification(message_center::NotificationType type,
const string16& replace_id,
const DictionaryValue* optional_fields,
NotificationDelegate* delegate)
- : type_(type),
+ : message_center::Notification(type,
+ delegate->id(),
+ title,
+ body,
+ gfx::Image(),
+ display_source,
+ origin_url.spec(),
+ optional_fields,
+ delegate),
origin_url_(origin_url),
icon_url_(icon_url),
is_html_(false),
- title_(title),
- body_(body),
- display_source_(display_source),
replace_id_(replace_id),
optional_fields_(NULL),
delegate_(delegate) {
@@ -69,6 +89,41 @@ Notification::Notification(message_center::NotificationType type,
icon_url, title, body, dir));
}
+Notification::Notification(
+ message_center::NotificationType type,
+ const GURL& origin_url,
+ const string16& title,
+ const string16& body,
+ const gfx::Image& icon,
+ WebKit::WebTextDirection dir,
+ const string16& display_source,
+ const string16& replace_id,
+ const message_center::RichNotificationData& rich_notification_data,
+ NotificationDelegate* delegate)
+ : message_center::Notification(type,
+ delegate->id(),
+ title,
+ body,
+ icon,
+ display_source,
+ origin_url.spec(),
+ rich_notification_data,
+ delegate),
+ origin_url_(origin_url),
+ is_html_(false),
+ replace_id_(replace_id),
+ delegate_(delegate) {
+ if (!message_center::IsRichNotificationEnabled()) {
+ // "Upconvert" the string parameters to a data: URL. Some balloon views
+ // require content URL to render anything, so this serves as a backup.
+ GURL icon_url;
+ if (!icon.IsEmpty())
+ icon_url_ = GURL(webui::GetBitmapDataUrl(*icon.ToSkBitmap()));
+ content_url_ = GURL(
+ DesktopNotificationService::CreateDataUrl(icon_url, title, body, dir));
+ }
+}
+
Notification::Notification(const GURL& origin_url,
const gfx::Image& icon,
const string16& title,
@@ -77,26 +132,26 @@ Notification::Notification(const GURL& origin_url,
const string16& display_source,
const string16& replace_id,
NotificationDelegate* delegate)
- : type_(message_center::NOTIFICATION_TYPE_SIMPLE),
+ : message_center::Notification(message_center::NOTIFICATION_TYPE_SIMPLE,
+ delegate->id(),
+ title,
+ body,
+ icon,
+ display_source,
+ origin_url.spec(),
+ NULL,
+ delegate),
origin_url_(origin_url),
- icon_(icon),
is_html_(false),
- title_(title),
- body_(body),
- display_source_(display_source),
replace_id_(replace_id),
delegate_(delegate) {}
Notification::Notification(const Notification& notification)
- : type_(notification.type()),
+ : message_center::Notification(notification),
origin_url_(notification.origin_url()),
- icon_(notification.icon()),
icon_url_(notification.icon_url()),
is_html_(notification.is_html()),
content_url_(notification.content_url()),
- title_(notification.title()),
- body_(notification.body()),
- display_source_(notification.display_source()),
replace_id_(notification.replace_id()),
delegate_(notification.delegate()) {
if (notification.optional_fields())
@@ -106,15 +161,11 @@ Notification::Notification(const Notification& notification)
Notification::~Notification() {}
Notification& Notification::operator=(const Notification& notification) {
- type_ = notification.type();
+ message_center::Notification::operator=(notification);
origin_url_ = notification.origin_url();
- icon_ = notification.icon_;
icon_url_ = notification.icon_url();
is_html_ = notification.is_html();
content_url_ = notification.content_url();
- title_ = notification.title();
- body_ = notification.body();
- display_source_ = notification.display_source();
replace_id_ = notification.replace_id();
if (notification.optional_fields())
optional_fields_.reset(notification.optional_fields()->DeepCopy());
@@ -123,9 +174,3 @@ Notification& Notification::operator=(const Notification& notification) {
delegate_ = notification.delegate();
return *this;
}
-
-void Notification::DisableTimeout() {
- if (!optional_fields_.get())
- optional_fields_.reset(new base::DictionaryValue());
- optional_fields_->SetBoolean(message_center::kPrivateNeverTimeoutKey, true);
-}

Powered by Google App Engine
This is Rietveld 408576698