Update mojo surfaces bindings and mojo/cc/ glue
[chromium-blink-merge.git] / chrome / browser / notifications / notification.h
blobd2a9d4aef8e87316a2a2fc024375e650899c5864
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_
8 #include <string>
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/gfx/image/image.h"
17 #include "ui/message_center/notification.h"
18 #include "ui/message_center/notification_types.h"
19 #include "url/gurl.h"
21 // Representation of a notification to be shown to the user.
22 // On non-Ash platforms these are rendered as HTML, sometimes described by a
23 // data url converted from text + icon data. On Ash they are rendered as
24 // formated text and icon data.
25 class Notification : public message_center::Notification {
26 public:
27 // Initializes a notification with text content. On non-ash platforms, this
28 // creates an HTML representation using a data: URL for display.
29 Notification(const GURL& origin_url,
30 const GURL& icon_url,
31 const base::string16& title,
32 const base::string16& body,
33 blink::WebTextDirection dir,
34 const base::string16& display_source,
35 const base::string16& replace_id,
36 NotificationDelegate* delegate);
38 // Initializes a notification with text content and an icon image. Currently
39 // only used on Ash. Does not generate content_url_.
40 Notification(const GURL& origin_url,
41 const gfx::Image& icon,
42 const base::string16& title,
43 const base::string16& body,
44 blink::WebTextDirection dir,
45 const base::string16& display_source,
46 const base::string16& replace_id,
47 NotificationDelegate* delegate);
49 Notification(
50 message_center::NotificationType type,
51 const GURL& origin_url,
52 const base::string16& title,
53 const base::string16& body,
54 const gfx::Image& icon,
55 blink::WebTextDirection dir,
56 const message_center::NotifierId& notifier_id,
57 const base::string16& display_source,
58 const base::string16& replace_id,
59 const message_center::RichNotificationData& rich_notification_data,
60 NotificationDelegate* delegate);
62 Notification(const Notification& notification);
63 virtual ~Notification();
64 Notification& operator=(const Notification& notification);
66 // The URL (may be data:) containing the contents for the notification.
67 const GURL& content_url() const { return content_url_; }
69 // The origin URL of the script which requested the notification.
70 const GURL& origin_url() const { return origin_url_; }
72 // A url for the icon to be shown (optional).
73 const GURL& icon_url() const { return icon_url_; }
75 // A unique identifier used to update (replace) or remove a notification.
76 const base::string16& replace_id() const { return replace_id_; }
78 // A url for the button icons to be shown (optional).
79 const GURL& button_one_icon_url() const { return button_one_icon_url_; }
80 const GURL& button_two_icon_url() const { return button_two_icon_url_; }
82 // A url for the image to be shown (optional).
83 const GURL& image_url() const { return image_url_; }
85 // Id of the delegate embedded inside this instance.
86 std::string delegate_id() const { return delegate()->id(); }
87 int process_id() const { return delegate()->process_id(); }
89 content::WebContents* GetWebContents() const {
90 return delegate()->GetWebContents();
92 void DoneRendering() { delegate()->ReleaseRenderViewHost(); }
94 NotificationDelegate* delegate() const { return delegate_.get(); }
96 private:
97 // The Origin of the page/worker which created this notification.
98 GURL origin_url_;
100 // URL for the icon associated with the notification. Requires delegate_
101 // to have a non NULL RenderViewHost.
102 GURL icon_url_;
104 // The URL of the HTML content of the toast (may be a data: URL for simple
105 // string-based notifications).
106 GURL content_url_;
108 // The URLs of the button images for a rich notification.
109 GURL button_one_icon_url_;
110 GURL button_two_icon_url_;
112 // The URL of a large image to be displayed for a a rich notification.
113 GURL image_url_;
115 // The URL of a small image to be displayed for a a rich notification.
116 GURL small_image_url_;
118 // The user-supplied replace ID for the notification.
119 base::string16 replace_id_;
121 // A proxy object that allows access back to the JavaScript object that
122 // represents the notification, for firing events.
123 scoped_refptr<NotificationDelegate> delegate_;
126 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_H_