Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / notifications / notification.h
blob1d13c4034eb5ba33f13d5d134812b99565995e21
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 HTML content.
28 Notification(const GURL& origin_url,
29 const GURL& content_url,
30 const base::string16& display_source,
31 const base::string16& replace_id,
32 NotificationDelegate* delegate);
34 // Initializes a notification with text content. On non-ash platforms, this
35 // creates an HTML representation using a data: URL for display.
36 Notification(const GURL& origin_url,
37 const GURL& icon_url,
38 const base::string16& title,
39 const base::string16& body,
40 blink::WebTextDirection dir,
41 const base::string16& display_source,
42 const base::string16& replace_id,
43 NotificationDelegate* delegate);
45 // Initializes a notification with text content and an icon image. Currently
46 // only used on Ash. Does not generate content_url_.
47 Notification(const GURL& origin_url,
48 const gfx::Image& icon,
49 const base::string16& title,
50 const base::string16& body,
51 blink::WebTextDirection dir,
52 const base::string16& display_source,
53 const base::string16& replace_id,
54 NotificationDelegate* delegate);
56 Notification(
57 message_center::NotificationType type,
58 const GURL& origin_url,
59 const base::string16& title,
60 const base::string16& body,
61 const gfx::Image& icon,
62 blink::WebTextDirection dir,
63 const message_center::NotifierId& notifier_id,
64 const base::string16& display_source,
65 const base::string16& replace_id,
66 const message_center::RichNotificationData& rich_notification_data,
67 NotificationDelegate* delegate);
69 Notification(const Notification& notification);
70 virtual ~Notification();
71 Notification& operator=(const Notification& notification);
73 // If this is a HTML notification.
74 bool is_html() const { return is_html_; }
76 // The URL (may be data:) containing the contents for the notification.
77 const GURL& content_url() const { return content_url_; }
79 // The origin URL of the script which requested the notification.
80 const GURL& origin_url() const { return origin_url_; }
82 // A url for the icon to be shown (optional).
83 const GURL& icon_url() const { return icon_url_; }
85 // A unique identifier used to update (replace) or remove a notification.
86 const base::string16& replace_id() const { return replace_id_; }
88 // A url for the button icons to be shown (optional).
89 const GURL& button_one_icon_url() const { return button_one_icon_url_; }
90 const GURL& button_two_icon_url() const { return button_two_icon_url_; }
92 // A url for the image to be shown (optional).
93 const GURL& image_url() const { return image_url_; }
95 std::string notification_id() const { return delegate()->id(); }
96 int process_id() const { return delegate()->process_id(); }
98 content::RenderViewHost* GetRenderViewHost() const {
99 return delegate()->GetRenderViewHost();
101 void DoneRendering() { delegate()->ReleaseRenderViewHost(); }
103 NotificationDelegate* delegate() const { return delegate_.get(); }
105 private:
106 // The Origin of the page/worker which created this notification.
107 GURL origin_url_;
109 // URL for the icon associated with the notification. Requires delegate_
110 // to have a non NULL RenderViewHost.
111 GURL icon_url_;
113 // If this is a HTML notification, the content is in |content_url_|. If
114 // false, the data is in |title_| and |message_|.
115 bool is_html_;
117 // The URL of the HTML content of the toast (may be a data: URL for simple
118 // string-based notifications).
119 GURL content_url_;
121 // The URLs of the button images for a rich notification.
122 GURL button_one_icon_url_;
123 GURL button_two_icon_url_;
125 // The URL of a large image to be displayed for a a rich notification.
126 GURL image_url_;
128 // The user-supplied replace ID for the notification.
129 base::string16 replace_id_;
131 // A proxy object that allows access back to the JavaScript object that
132 // represents the notification, for firing events.
133 scoped_refptr<NotificationDelegate> delegate_;
136 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_H_