OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_MESSAGE_CENTER_SETTINGS_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_NOTIFICATIONS_MESSAGE_CENTER_SETTINGS_CONTROLLER_H_ |
6 #define CHROME_BROWSER_NOTIFICATIONS_MESSAGE_CENTER_SETTINGS_CONTROLLER_H_ | 6 #define CHROME_BROWSER_NOTIFICATIONS_MESSAGE_CENTER_SETTINGS_CONTROLLER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/scoped_vector.h" |
13 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
14 #include "chrome/browser/extensions/app_icon_loader.h" | 15 #include "chrome/browser/extensions/app_icon_loader.h" |
15 #include "chrome/browser/profiles/profile.h" | |
16 #include "chrome/common/content_settings.h" | 16 #include "chrome/common/content_settings.h" |
| 17 #include "content/public/browser/notification_details.h" |
17 #include "content/public/browser/notification_observer.h" | 18 #include "content/public/browser/notification_observer.h" |
18 #include "content/public/browser/notification_registrar.h" | 19 #include "content/public/browser/notification_registrar.h" |
| 20 #include "content/public/browser/notification_source.h" |
19 #include "ui/message_center/notifier_settings.h" | 21 #include "ui/message_center/notifier_settings.h" |
20 | 22 |
21 class CancelableTaskTracker; | 23 class CancelableTaskTracker; |
| 24 class ProfileInfoCache; |
22 | 25 |
23 namespace chrome { | 26 namespace chrome { |
24 struct FaviconImageResult; | 27 struct FaviconImageResult; |
25 } | 28 } |
26 | 29 |
| 30 namespace message_center { |
| 31 class ProfileNotifierGroup; |
| 32 } |
| 33 |
27 // The class to bridge between the settings UI of notifiers and the preference | 34 // The class to bridge between the settings UI of notifiers and the preference |
28 // storage. | 35 // storage. |
29 class MessageCenterSettingsController | 36 class MessageCenterSettingsController |
30 : public message_center::NotifierSettingsProvider, | 37 : public message_center::NotifierSettingsProvider, |
31 public extensions::AppIconLoader::Delegate, | 38 public content::NotificationObserver, |
32 public content::NotificationObserver { | 39 public extensions::AppIconLoader::Delegate { |
33 public: | 40 public: |
34 MessageCenterSettingsController(); | 41 explicit MessageCenterSettingsController( |
| 42 ProfileInfoCache* profile_info_cache); |
35 virtual ~MessageCenterSettingsController(); | 43 virtual ~MessageCenterSettingsController(); |
36 | 44 |
37 // Overridden from message_center::NotifierSettingsProvider. | 45 // Overridden from message_center::NotifierSettingsProvider. |
38 virtual void AddObserver( | 46 virtual void AddObserver( |
39 message_center::NotifierSettingsObserver* observer) OVERRIDE; | 47 message_center::NotifierSettingsObserver* observer) OVERRIDE; |
40 virtual void RemoveObserver( | 48 virtual void RemoveObserver( |
41 message_center::NotifierSettingsObserver* observer) OVERRIDE; | 49 message_center::NotifierSettingsObserver* observer) OVERRIDE; |
| 50 virtual size_t GetNotifierGroupCount() const OVERRIDE; |
| 51 virtual const message_center::NotifierGroup& GetNotifierGroupAt( |
| 52 size_t index) const OVERRIDE; |
| 53 virtual void SwitchToNotifierGroup(size_t index) OVERRIDE; |
| 54 virtual const message_center::NotifierGroup& GetActiveNotifierGroup() const |
| 55 OVERRIDE; |
42 virtual void GetNotifierList( | 56 virtual void GetNotifierList( |
43 std::vector<message_center::Notifier*>* notifiers) | 57 std::vector<message_center::Notifier*>* notifiers) OVERRIDE; |
44 OVERRIDE; | 58 virtual void SetNotifierEnabled(const message_center::Notifier& notifier, |
45 virtual void SetNotifierEnabled( | 59 bool enabled) OVERRIDE; |
46 const message_center::Notifier& notifier, | |
47 bool enabled) OVERRIDE; | |
48 virtual void OnNotifierSettingsClosing() OVERRIDE; | 60 virtual void OnNotifierSettingsClosing() OVERRIDE; |
49 | 61 |
50 // Overridden from extensions::AppIconLoader::Delegate. | 62 // Overridden from extensions::AppIconLoader::Delegate. |
51 virtual void SetAppImage(const std::string& id, | 63 virtual void SetAppImage(const std::string& id, |
52 const gfx::ImageSkia& image) OVERRIDE; | 64 const gfx::ImageSkia& image) OVERRIDE; |
53 | 65 |
54 private: | 66 private: |
55 // Overridden from content::NotificationObserver. | 67 // Overridden from content::NotificationObserver. |
56 virtual void Observe(int type, | 68 virtual void Observe(int type, |
57 const content::NotificationSource& source, | 69 const content::NotificationSource& source, |
58 const content::NotificationDetails& details) OVERRIDE; | 70 const content::NotificationDetails& details) OVERRIDE; |
59 | 71 |
60 void OnFaviconLoaded(const GURL& url, | 72 void OnFaviconLoaded(const GURL& url, |
61 const chrome::FaviconImageResult& favicon_result); | 73 const chrome::FaviconImageResult& favicon_result); |
62 | 74 |
| 75 void RebuildNotifierGroups(); |
| 76 |
63 // The views displaying notifier settings. | 77 // The views displaying notifier settings. |
64 ObserverList<message_center::NotifierSettingsObserver> observers_; | 78 ObserverList<message_center::NotifierSettingsObserver> observers_; |
65 | 79 |
66 // The task tracker for loading favicons. | 80 // The task tracker for loading favicons. |
67 scoped_ptr<CancelableTaskTracker> favicon_tracker_; | 81 scoped_ptr<CancelableTaskTracker> favicon_tracker_; |
68 | 82 |
69 scoped_ptr<extensions::AppIconLoader> app_icon_loader_; | 83 scoped_ptr<extensions::AppIconLoader> app_icon_loader_; |
70 | 84 |
71 std::map<string16, ContentSettingsPattern> patterns_; | 85 std::map<string16, ContentSettingsPattern> patterns_; |
72 | 86 |
73 // The Registrar used to register for notifications. | 87 // The list of all configurable notifier groups. This is each profile that is |
| 88 // loaded (and in the ProfileInfoCache - so no incognito profiles go here). |
| 89 ScopedVector<message_center::ProfileNotifierGroup> notifier_groups_; |
| 90 size_t current_notifier_group_; |
| 91 |
74 content::NotificationRegistrar registrar_; | 92 content::NotificationRegistrar registrar_; |
75 | 93 |
76 // TODO(sidharthms): Fix this for multi-profile. | 94 ProfileInfoCache* profile_info_cache_; |
77 // The profile associated with message center settings. | |
78 Profile* profile_; | |
79 | 95 |
80 DISALLOW_COPY_AND_ASSIGN(MessageCenterSettingsController); | 96 DISALLOW_COPY_AND_ASSIGN(MessageCenterSettingsController); |
81 }; | 97 }; |
82 | 98 |
83 #endif // CHROME_BROWSER_NOTIFICATIONS_MESSAGE_CENTER_SETTINGS_CONTROLLER_H_ | 99 #endif // CHROME_BROWSER_NOTIFICATIONS_MESSAGE_CENTER_SETTINGS_CONTROLLER_H_ |
OLD | NEW |