OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2009 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. |
| 4 |
| 5 #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_H_ |
| 6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "chrome/browser/notifications/notification_object_proxy.h" |
| 10 #include "googleurl/src/gurl.h" |
| 11 |
| 12 // Representation of an notification to be shown to the user. All |
| 13 // notifications at this level are HTML, although they may be |
| 14 // data: URLs representing simple text+icon notifications. |
| 15 class Notification { |
| 16 public: |
| 17 Notification(const GURL& origin_url, const GURL& content_url, |
| 18 NotificationObjectProxy* proxy) |
| 19 : origin_url_(origin_url), |
| 20 content_url_(content_url), |
| 21 proxy_(proxy) { |
| 22 } |
| 23 |
| 24 Notification(const Notification& notification) |
| 25 : origin_url_(notification.origin_url()), |
| 26 content_url_(notification.content_url()), |
| 27 proxy_(notification.proxy()) { |
| 28 } |
| 29 |
| 30 // The URL (may be data:) containing the contents for the notification. |
| 31 const GURL& content_url() const { return content_url_; } |
| 32 |
| 33 // The origin URL of the script which requested the notification. |
| 34 const GURL& origin_url() const { return origin_url_; } |
| 35 |
| 36 void Display() const { proxy()->Display(); } |
| 37 void Error() const { proxy()->Error(); } |
| 38 void Close(bool by_user) const { proxy()->Close(by_user); } |
| 39 |
| 40 private: |
| 41 NotificationObjectProxy* proxy() const { return proxy_.get(); } |
| 42 |
| 43 // The Origin of the page/worker which created this notification. |
| 44 GURL origin_url_; |
| 45 |
| 46 // The URL of the HTML content of the toast (may be a data: URL for simple |
| 47 // string-based notifications). |
| 48 GURL content_url_; |
| 49 |
| 50 // A proxy object that allows access back to the JavaScript object that |
| 51 // represents the notification, for firing events. |
| 52 scoped_refptr<NotificationObjectProxy> proxy_; |
| 53 |
| 54 // Disallow assign. Copy constructor written above. |
| 55 void operator=(const Notification&); |
| 56 }; |
| 57 |
| 58 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_H_ |
OLD | NEW |