1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/notifications/notification.h"
7 #include "base/strings/string_util.h"
8 #include "chrome/browser/notifications/desktop_notification_service.h"
9 #include "ui/base/webui/web_ui_util.h"
11 Notification::Notification(const GURL
& origin_url
,
13 const base::string16
& title
,
14 const base::string16
& body
,
15 blink::WebTextDirection dir
,
16 const base::string16
& display_source
,
17 const base::string16
& replace_id
,
18 NotificationDelegate
* delegate
)
19 : message_center::Notification(message_center::NOTIFICATION_TYPE_SIMPLE
,
25 message_center::NotifierId(origin_url
),
26 message_center::RichNotificationData(),
28 origin_url_(origin_url
),
30 replace_id_(replace_id
),
32 // "Upconvert" the string parameters to a data: URL.
33 content_url_
= GURL(DesktopNotificationService::CreateDataUrl(
34 icon_url
, title
, body
, dir
));
37 Notification::Notification(
38 message_center::NotificationType type
,
39 const GURL
& origin_url
,
40 const base::string16
& title
,
41 const base::string16
& body
,
42 const gfx::Image
& icon
,
43 blink::WebTextDirection dir
,
44 const message_center::NotifierId
& notifier_id
,
45 const base::string16
& display_source
,
46 const base::string16
& replace_id
,
47 const message_center::RichNotificationData
& rich_notification_data
,
48 NotificationDelegate
* delegate
)
49 : message_center::Notification(type
,
56 rich_notification_data
,
58 origin_url_(origin_url
),
59 replace_id_(replace_id
),
61 // It's important to leave |icon_url_| empty with rich notifications enabled,
62 // to prevent "Downloading" the data url and overwriting the existing |icon|.
65 Notification::Notification(const GURL
& origin_url
,
66 const gfx::Image
& icon
,
67 const base::string16
& title
,
68 const base::string16
& body
,
69 blink::WebTextDirection dir
,
70 const base::string16
& display_source
,
71 const base::string16
& replace_id
,
72 NotificationDelegate
* delegate
)
73 : message_center::Notification(message_center::NOTIFICATION_TYPE_SIMPLE
,
79 message_center::NotifierId(origin_url
),
80 message_center::RichNotificationData(),
82 origin_url_(origin_url
),
83 replace_id_(replace_id
),
84 delegate_(delegate
) {}
86 Notification::Notification(const Notification
& notification
)
87 : message_center::Notification(notification
),
88 origin_url_(notification
.origin_url()),
89 icon_url_(notification
.icon_url()),
90 content_url_(notification
.content_url()),
91 button_one_icon_url_(notification
.button_one_icon_url()),
92 button_two_icon_url_(notification
.button_two_icon_url()),
93 image_url_(notification
.image_url()),
94 replace_id_(notification
.replace_id()),
95 delegate_(notification
.delegate()) {}
97 Notification::~Notification() {}
99 Notification
& Notification::operator=(const Notification
& notification
) {
100 message_center::Notification::operator=(notification
);
101 origin_url_
= notification
.origin_url();
102 icon_url_
= notification
.icon_url();
103 content_url_
= notification
.content_url();
104 button_one_icon_url_
= notification
.button_one_icon_url();
105 button_two_icon_url_
= notification
.button_two_icon_url();
106 image_url_
= notification
.image_url();
107 replace_id_
= notification
.replace_id();
108 delegate_
= notification
.delegate();