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

Side by Side Diff: ui/message_center/message_center.h

Issue 11819048: Implement message center on Windows (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase. Created 7 years, 11 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 UI_MESSAGE_CENTER_MESSAGE_CENTER_H_ 5 #ifndef UI_MESSAGE_CENTER_MESSAGE_CENTER_H_
6 #define UI_MESSAGE_CENTER_MESSAGE_CENTER_H_ 6 #define UI_MESSAGE_CENTER_MESSAGE_CENTER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/observer_list.h" 11 #include "base/observer_list.h"
12 #include "ui/message_center/message_center_export.h" 12 #include "ui/message_center/message_center_export.h"
13 #include "ui/message_center/notification_list.h" 13 #include "ui/message_center/notification_list.h"
14 #include "ui/notifications/notification_types.h" 14 #include "ui/notifications/notification_types.h"
15 15
16 template <typename T> struct DefaultSingletonTraits;
17
18 namespace base { 16 namespace base {
19 class DictionaryValue; 17 class DictionaryValue;
20 } 18 }
21 19
22 // Class for managing the NotificationList. The client (e.g. Chrome) calls 20 // Class for managing the NotificationList. The client (e.g. Chrome) calls
23 // [Add|Remove|Update]Notification to create and update notifications in the 21 // [Add|Remove|Update]Notification to create and update notifications in the
24 // list. It can also implement Delegate to receive callbacks when a 22 // list. It can also implement Delegate to receive callbacks when a
25 // notification is removed (closed), or clicked on. 23 // notification is removed (closed), or clicked on.
26 // If an Observer is provided, it will be informed when the notification list 24 // If an Observer is provided, it will be informed when the notification list
27 // changes, and is expected to handle creating, showing, and hiding of any 25 // changes, and is expected to handle creating, showing, and hiding of any
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 // 65 //
68 // TODO(miket): consider providing default implementations for the pure 66 // TODO(miket): consider providing default implementations for the pure
69 // virtuals above, to avoid changing so many files in disparate parts of 67 // virtuals above, to avoid changing so many files in disparate parts of
70 // the codebase each time we enhance this interface. 68 // the codebase each time we enhance this interface.
71 virtual void OnButtonClicked(const std::string& id, int button_index); 69 virtual void OnButtonClicked(const std::string& id, int button_index);
72 70
73 protected: 71 protected:
74 virtual ~Delegate() {} 72 virtual ~Delegate() {}
75 }; 73 };
76 74
77 static MessageCenter* GetInstance(); 75 MessageCenter();
78
79 virtual ~MessageCenter(); 76 virtual ~MessageCenter();
80 77
81 // Called to set the delegate. Generally called only once, except in tests. 78 // Called to set the delegate. Generally called only once, except in tests.
82 // Changing the delegate does not affect notifications in its 79 // Changing the delegate does not affect notifications in its
83 // NotificationList. 80 // NotificationList.
84 void SetDelegate(Delegate* delegate); 81 void SetDelegate(Delegate* delegate);
85 82
86 // Management of the observer list. 83 // Management of the observer list.
87 void AddObserver(Observer* observer); 84 void AddObserver(Observer* observer);
88 void RemoveObserver(Observer* observer); 85 void RemoveObserver(Observer* observer);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 virtual void DisableNotificationByExtension(const std::string& id) OVERRIDE; 136 virtual void DisableNotificationByExtension(const std::string& id) OVERRIDE;
140 virtual void DisableNotificationByUrl(const std::string& id) OVERRIDE; 137 virtual void DisableNotificationByUrl(const std::string& id) OVERRIDE;
141 virtual void ShowNotificationSettings(const std::string& id) OVERRIDE; 138 virtual void ShowNotificationSettings(const std::string& id) OVERRIDE;
142 virtual void OnNotificationClicked(const std::string& id) OVERRIDE; 139 virtual void OnNotificationClicked(const std::string& id) OVERRIDE;
143 virtual void OnQuietModeChanged(bool quiet_mode) OVERRIDE; 140 virtual void OnQuietModeChanged(bool quiet_mode) OVERRIDE;
144 virtual void OnButtonClicked(const std::string& id, int button_index) 141 virtual void OnButtonClicked(const std::string& id, int button_index)
145 OVERRIDE; 142 OVERRIDE;
146 virtual NotificationList* GetNotificationList() OVERRIDE; 143 virtual NotificationList* GetNotificationList() OVERRIDE;
147 144
148 private: 145 private:
149 friend struct DefaultSingletonTraits<MessageCenter>;
150 MessageCenter();
151
152 // Calls OnMessageCenterChanged on each observer. 146 // Calls OnMessageCenterChanged on each observer.
153 void NotifyMessageCenterChanged(bool new_notification); 147 void NotifyMessageCenterChanged(bool new_notification);
154 148
155 scoped_ptr<NotificationList> notification_list_; 149 scoped_ptr<NotificationList> notification_list_;
156 ObserverList<Observer> observer_list_; 150 ObserverList<Observer> observer_list_;
157 Delegate* delegate_; 151 Delegate* delegate_;
158 152
159 DISALLOW_COPY_AND_ASSIGN(MessageCenter); 153 DISALLOW_COPY_AND_ASSIGN(MessageCenter);
160 }; 154 };
161 155
162 } // namespace message_center 156 } // namespace message_center
163 157
164 #endif // UI_MESSAGE_CENTER_MESSAGE_CENTER_H_ 158 #endif // UI_MESSAGE_CENTER_MESSAGE_CENTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698