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 #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_H_
6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_H_
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/strings/string16.h"
13 #include "base/values.h"
14 #include "chrome/browser/notifications/notification_delegate.h"
15 #include "third_party/WebKit/public/web/WebTextDirection.h"
16 #include "ui/message_center/notification.h"
17 #include "ui/message_center/notification_types.h"
24 // Representation of a notification to be shown to the user.
25 // On non-Ash platforms these are rendered as HTML, sometimes described by a
26 // data url converted from text + icon data. On Ash they are rendered as
27 // formated text and icon data.
28 class Notification : public message_center::Notification {
30 // Initializes a notification with text content. On non-ash platforms, this
31 // creates an HTML representation using a data: URL for display.
32 Notification(const GURL& origin_url,
34 const base::string16& title,
35 const base::string16& body,
36 blink::WebTextDirection dir,
37 const base::string16& display_source,
38 const base::string16& replace_id,
39 NotificationDelegate* delegate);
42 message_center::NotificationType type,
43 const GURL& origin_url,
44 const base::string16& title,
45 const base::string16& body,
46 const gfx::Image& icon,
47 blink::WebTextDirection dir,
48 const message_center::NotifierId& notifier_id,
49 const base::string16& display_source,
50 const base::string16& replace_id,
51 const message_center::RichNotificationData& rich_notification_data,
52 NotificationDelegate* delegate);
54 Notification(const Notification& notification);
55 virtual ~Notification();
56 Notification& operator=(const Notification& notification);
58 // The origin URL of the script which requested the notification.
59 const GURL& origin_url() const { return origin_url_; }
61 // A url for the icon to be shown (optional).
62 const GURL& icon_url() const { return icon_url_; }
64 // A unique identifier used to update (replace) or remove a notification.
65 const base::string16& replace_id() const { return replace_id_; }
67 // A url for the button icons to be shown (optional).
68 const GURL& button_one_icon_url() const { return button_one_icon_url_; }
69 const GURL& button_two_icon_url() const { return button_two_icon_url_; }
71 // A url for the image to be shown (optional).
72 const GURL& image_url() const { return image_url_; }
74 // Id of the delegate embedded inside this instance.
75 std::string delegate_id() const { return delegate()->id(); }
77 NotificationDelegate* delegate() const { return delegate_.get(); }
80 // The Origin of the page/worker which created this notification.
83 // URL for the icon associated with the notification. Requires delegate_
84 // to have a non NULL RenderViewHost.
87 // The URLs of the button images for a rich notification.
88 GURL button_one_icon_url_;
89 GURL button_two_icon_url_;
91 // The URL of a large image to be displayed for a a rich notification.
94 // The user-supplied replace ID for the notification.
95 base::string16 replace_id_;
97 // A proxy object that allows access back to the JavaScript object that
98 // represents the notification, for firing events.
99 scoped_refptr<NotificationDelegate> delegate_;
102 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_H_