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

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

Issue 10537158: Add support for Ash to Notifications (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Undo accidental UserManagerImpl change Created 8 years, 6 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 | Annotate | Revision Log
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 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/string16.h" 12 #include "base/string16.h"
13 #include "chrome/browser/notifications/notification_object_proxy.h" 13 #include "chrome/browser/notifications/notification_delegate.h"
14 #include "googleurl/src/gurl.h" 14 #include "googleurl/src/gurl.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextDirection.h" 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextDirection.h"
16 #include "ui/gfx/image/image_skia.h"
16 17
17 class NotificationDelegate; 18 // Representation of a notification to be shown to the user.
18 19 // On non-Ash platforms these are rendered as HTML, sometimes described by a
19 // Representation of an notification to be shown to the user. All 20 // data url converted from text + icon data. On Ash they are rendered as
20 // notifications at this level are HTML, although they may be 21 // formated text and icon data.
21 // data: URLs representing simple text+icon notifications.
22 class Notification { 22 class Notification {
23 public: 23 public:
24 // Initializes a notification with HTML content. 24 // Initializes a notification with HTML content.
25 Notification(const GURL& origin_url, 25 Notification(const GURL& origin_url,
26 const GURL& content_url, 26 const GURL& content_url,
27 const string16& display_source, 27 const string16& display_source,
28 const string16& replace_id, 28 const string16& replace_id,
29 NotificationDelegate* delegate); 29 NotificationDelegate* delegate);
30 // Initializes a notification with text content, and then creates a 30
31 // HTML representation of it for display (satisfying the invariant outlined 31 // Initializes a notification with text content. On non-ash platforms, this
32 // at the top of this class). 32 // creates an HTML representation using a data: URL for display.
33 Notification(const GURL& origin_url, 33 Notification(const GURL& origin_url,
34 const GURL& icon_url, 34 const GURL& icon_url,
35 const string16& title, 35 const string16& title,
36 const string16& body, 36 const string16& body,
37 WebKit::WebTextDirection dir, 37 WebKit::WebTextDirection dir,
38 const string16& display_source, 38 const string16& display_source,
39 const string16& replace_id, 39 const string16& replace_id,
40 NotificationDelegate* delegate); 40 NotificationDelegate* delegate);
41
42 // Initializes a notification with text content and an icon image. Currently
43 // only used on Ash. Does not generate content_url_.
44 Notification(const GURL& origin_url,
45 const gfx::ImageSkia& icon,
46 const string16& title,
47 const string16& body,
48 WebKit::WebTextDirection dir,
49 const string16& display_source,
50 const string16& replace_id,
51 NotificationDelegate* delegate);
52
41 Notification(const Notification& notification); 53 Notification(const Notification& notification);
42 ~Notification(); 54 ~Notification();
43 Notification& operator=(const Notification& notification); 55 Notification& operator=(const Notification& notification);
44 56
45 // If this is a HTML notification. 57 // If this is a HTML notification.
46 bool is_html() const { return is_html_; } 58 bool is_html() const { return is_html_; }
47 59
48 // The URL (may be data:) containing the contents for the notification. 60 // The URL (may be data:) containing the contents for the notification.
49 const GURL& content_url() const { return content_url_; } 61 const GURL& content_url() const { return content_url_; }
50 62
51 // Parameters for text-only notifications. 63 // Title and message text of the notification.
52 const string16& title() const { return title_; } 64 const string16& title() const { return title_; }
53 const string16& body() const { return body_; } 65 const string16& body() const { return body_; }
54 66
55 // The origin URL of the script which requested the notification. 67 // The origin URL of the script which requested the notification.
56 const GURL& origin_url() const { return origin_url_; } 68 const GURL& origin_url() const { return origin_url_; }
57 69
70 // A url for the icon to be shown (optional).
71 const GURL& icon_url() const { return icon_url_; }
72
73 // An image for the icon to be shown (optional).
74 const gfx::ImageSkia& icon() const { return icon_; }
75
58 // A display string for the source of the notification. 76 // A display string for the source of the notification.
59 const string16& display_source() const { return display_source_; } 77 const string16& display_source() const { return display_source_; }
60 78
79 // A unique identifier used to update (replace) or remove a notification.
61 const string16& replace_id() const { return replace_id_; } 80 const string16& replace_id() const { return replace_id_; }
62 81
63 void Display() const { delegate()->Display(); } 82 void Display() const { delegate()->Display(); }
64 void Error() const { delegate()->Error(); } 83 void Error() const { delegate()->Error(); }
65 void Click() const { delegate()->Click(); } 84 void Click() const { delegate()->Click(); }
66 void Close(bool by_user) const { delegate()->Close(by_user); } 85 void Close(bool by_user) const { delegate()->Close(by_user); }
67 86
68 std::string notification_id() const { return delegate()->id(); } 87 std::string notification_id() const { return delegate()->id(); }
69 88
89 content::RenderViewHost* GetRenderViewHost() const {
90 return delegate()->GetRenderViewHost();
91 }
92
70 private: 93 private:
71 NotificationDelegate* delegate() const { return delegate_.get(); } 94 NotificationDelegate* delegate() const { return delegate_.get(); }
72 95
73 // The Origin of the page/worker which created this notification. 96 // The Origin of the page/worker which created this notification.
74 GURL origin_url_; 97 GURL origin_url_;
75 98
99 // Image data for the associated icon, used by Ash when available.
100 gfx::ImageSkia icon_;
101
102 // URL for the icon associated with the notification. Requires delegate_
103 // to have a non NULL RenderViewHost.
104 GURL icon_url_;
105
76 // If this is a HTML notification, the content is in |content_url_|. If 106 // If this is a HTML notification, the content is in |content_url_|. If
77 // false, the data is in |title_| and |body_|. 107 // false, the data is in |title_| and |body_|.
78 bool is_html_; 108 bool is_html_;
79 109
80 // The URL of the HTML content of the toast (may be a data: URL for simple 110 // The URL of the HTML content of the toast (may be a data: URL for simple
81 // string-based notifications). 111 // string-based notifications).
82 GURL content_url_; 112 GURL content_url_;
83 113
84 // The content for a text notification. 114 // The content for a text notification.
85 string16 title_; 115 string16 title_;
86 string16 body_; 116 string16 body_;
87 117
88 // The display string for the source of the notification. Could be 118 // The display string for the source of the notification. Could be
89 // the same as origin_url_, or the name of an extension. 119 // the same as origin_url_, or the name of an extension.
90 string16 display_source_; 120 string16 display_source_;
91 121
92 // The replace ID for the notification. 122 // The replace ID for the notification.
93 string16 replace_id_; 123 string16 replace_id_;
94 124
95 // A proxy object that allows access back to the JavaScript object that 125 // A proxy object that allows access back to the JavaScript object that
96 // represents the notification, for firing events. 126 // represents the notification, for firing events.
97 scoped_refptr<NotificationDelegate> delegate_; 127 scoped_refptr<NotificationDelegate> delegate_;
98 }; 128 };
99 129
100 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_H_ 130 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_H_
OLDNEW
« no previous file with comments | « chrome/browser/notifications/desktop_notification_service_win.cc ('k') | chrome/browser/notifications/notification.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698