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

Side by Side Diff: chrome/browser/notifications/notification.h

Issue 554213003: Request the icon of a Web Notification in the renderer process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: include logging.h Created 6 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_H_ 5 #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_H_
6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_H_ 6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/strings/string16.h" 12 #include "base/strings/string16.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/browser/notifications/notification_delegate.h" 14 #include "chrome/browser/notifications/notification_delegate.h"
15 #include "third_party/WebKit/public/web/WebTextDirection.h" 15 #include "third_party/WebKit/public/web/WebTextDirection.h"
16 #include "ui/message_center/notification.h" 16 #include "ui/message_center/notification.h"
17 #include "ui/message_center/notification_types.h" 17 #include "ui/message_center/notification_types.h"
18 #include "url/gurl.h" 18 #include "url/gurl.h"
19 19
20 namespace gfx { 20 namespace gfx {
21 class Image; 21 class Image;
22 } 22 }
23 23
24 // Representation of a notification to be shown to the user. 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 { 25 class Notification : public message_center::Notification {
29 public: 26 public:
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, 27 Notification(const GURL& origin_url,
33 const GURL& icon_url,
34 const base::string16& title, 28 const base::string16& title,
35 const base::string16& body, 29 const base::string16& body,
36 blink::WebTextDirection dir, 30 const gfx::Image& icon,
37 const base::string16& display_source, 31 const base::string16& display_source,
38 const base::string16& replace_id, 32 const base::string16& replace_id,
39 NotificationDelegate* delegate); 33 NotificationDelegate* delegate);
40 34
41 Notification( 35 Notification(
42 message_center::NotificationType type, 36 message_center::NotificationType type,
43 const GURL& origin_url, 37 const GURL& origin_url,
44 const base::string16& title, 38 const base::string16& title,
45 const base::string16& body, 39 const base::string16& body,
46 const gfx::Image& icon, 40 const gfx::Image& icon,
47 blink::WebTextDirection dir, 41 blink::WebTextDirection dir,
48 const message_center::NotifierId& notifier_id, 42 const message_center::NotifierId& notifier_id,
49 const base::string16& display_source, 43 const base::string16& display_source,
50 const base::string16& replace_id, 44 const base::string16& replace_id,
51 const message_center::RichNotificationData& rich_notification_data, 45 const message_center::RichNotificationData& rich_notification_data,
52 NotificationDelegate* delegate); 46 NotificationDelegate* delegate);
53 47
54 Notification(const std::string& id, const Notification& notification); 48 Notification(const std::string& id, const Notification& notification);
55 49
56 Notification(const Notification& notification); 50 Notification(const Notification& notification);
57 virtual ~Notification(); 51 virtual ~Notification();
58 Notification& operator=(const Notification& notification); 52 Notification& operator=(const Notification& notification);
59 53
60 // The origin URL of the script which requested the notification. 54 // The origin URL of the script which requested the notification.
61 const GURL& origin_url() const { return origin_url_; } 55 const GURL& origin_url() const { return origin_url_; }
62 56
63 // A url for the icon to be shown (optional).
64 const GURL& icon_url() const { return icon_url_; }
65
66 // A unique identifier used to update (replace) or remove a notification. 57 // A unique identifier used to update (replace) or remove a notification.
67 const base::string16& replace_id() const { return replace_id_; } 58 const base::string16& replace_id() const { return replace_id_; }
68 59
69 // A url for the button icons to be shown (optional). 60 // A url for the button icons to be shown (optional).
70 const GURL& button_one_icon_url() const { return button_one_icon_url_; } 61 const GURL& button_one_icon_url() const { return button_one_icon_url_; }
71 const GURL& button_two_icon_url() const { return button_two_icon_url_; } 62 const GURL& button_two_icon_url() const { return button_two_icon_url_; }
72 63
73 // A url for the image to be shown (optional). 64 // A url for the image to be shown (optional).
74 const GURL& image_url() const { return image_url_; } 65 const GURL& image_url() const { return image_url_; }
75 66
76 // Id of the delegate embedded inside this instance. 67 // Id of the delegate embedded inside this instance.
77 std::string delegate_id() const { return delegate()->id(); } 68 std::string delegate_id() const { return delegate()->id(); }
78 69
79 NotificationDelegate* delegate() const { return delegate_.get(); } 70 NotificationDelegate* delegate() const { return delegate_.get(); }
80 71
81 private: 72 private:
82 // The Origin of the page/worker which created this notification. 73 // The Origin of the page/worker which created this notification.
83 GURL origin_url_; 74 GURL origin_url_;
84 75
85 // URL for the icon associated with the notification. Requires delegate_
86 // to have a non NULL RenderViewHost.
87 GURL icon_url_;
88
89 // The URLs of the button images for a rich notification. 76 // The URLs of the button images for a rich notification.
90 GURL button_one_icon_url_; 77 GURL button_one_icon_url_;
91 GURL button_two_icon_url_; 78 GURL button_two_icon_url_;
92 79
93 // The URL of a large image to be displayed for a a rich notification. 80 // The URL of a large image to be displayed for a a rich notification.
94 GURL image_url_; 81 GURL image_url_;
95 82
96 // The user-supplied replace ID for the notification. 83 // The user-supplied replace ID for the notification.
97 base::string16 replace_id_; 84 base::string16 replace_id_;
98 85
99 // A proxy object that allows access back to the JavaScript object that 86 // A proxy object that allows access back to the JavaScript object that
100 // represents the notification, for firing events. 87 // represents the notification, for firing events.
101 scoped_refptr<NotificationDelegate> delegate_; 88 scoped_refptr<NotificationDelegate> delegate_;
102 }; 89 };
103 90
104 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_H_ 91 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_H_
OLDNEW
« no previous file with comments | « chrome/browser/notifications/message_center_notifications_unittest.cc ('k') | chrome/browser/notifications/notification.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698