[email protected] | 0fecda6 | 2010-03-19 21:59:01 | [diff] [blame^] | 1 | // Copyright (c) 2010 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_CHROMEOS_NOTIFICATIONS_SYSTEM_NOTIFICATION_H_ |
| 6 | #define CHROME_BROWSER_CHROMEOS_NOTIFICATIONS_SYSTEM_NOTIFICATION_H_ |
| 7 | |
| 8 | #include <string> |
| 9 | |
| 10 | #include "base/basictypes.h" |
| 11 | #include "base/move.h" |
| 12 | #include "base/ref_counted.h" |
| 13 | #include "base/string16.h" |
| 14 | #include "chrome/browser/chromeos/notifications/balloon_collection_impl.h" |
| 15 | #include "chrome/browser/notifications/notification_delegate.h" |
| 16 | |
| 17 | class Profile; |
| 18 | |
| 19 | namespace chromeos { |
| 20 | |
| 21 | // The system notification object handles the display of a system notification |
| 22 | |
| 23 | class SystemNotification { |
| 24 | public: |
| 25 | // The profile is the current user profile. The id is any string used |
| 26 | // to uniquely identify this notification. The title is the title of |
| 27 | // the message to be displayed. On creation, the message is hidden. |
| 28 | SystemNotification(Profile* profile, std::string id, string16 title); |
| 29 | |
| 30 | ~SystemNotification(); |
| 31 | |
| 32 | // Show will show or update the message for this notification |
| 33 | void Show(const string16& message); |
| 34 | |
| 35 | // Hide will dismiss the notification, if the notification is already |
| 36 | // hidden it does nothing |
| 37 | void Hide(); |
| 38 | |
| 39 | // Current visibility state for this notification |
| 40 | bool visible() const { return visible_; } |
| 41 | |
| 42 | private: |
| 43 | class Delegate : public NotificationDelegate { |
| 44 | public: |
| 45 | explicit Delegate(std::string id) : id_(base::move(id)) {} |
| 46 | void Display() {} |
| 47 | void Error() {} |
| 48 | void Close(bool by_user) {} |
| 49 | std::string id() const { return id_; } |
| 50 | |
| 51 | private: |
| 52 | std::string id_; |
| 53 | |
| 54 | DISALLOW_COPY_AND_ASSIGN(Delegate); |
| 55 | }; |
| 56 | |
| 57 | Profile* profile_; |
| 58 | BalloonCollectionImpl* collection_; |
| 59 | scoped_refptr<Delegate> delegate_; |
| 60 | string16 title_; |
| 61 | bool visible_; |
| 62 | |
| 63 | DISALLOW_COPY_AND_ASSIGN(SystemNotification); |
| 64 | }; |
| 65 | |
| 66 | } // namespace chromeos |
| 67 | |
| 68 | #endif // CHROME_BROWSER_CHROMEOS_NOTIFICATIONS_SYSTEM_NOTIFICATION_H_ |
| 69 | |