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/memory/scoped_vector.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
16 #include "chrome/browser/extensions/app_icon_loader.h" | 16 #include "chrome/browser/extensions/app_icon_loader.h" |
| 17 #include "chrome/browser/profiles/profile_info_cache_observer.h" |
17 #include "components/content_settings/core/common/content_settings.h" | 18 #include "components/content_settings/core/common/content_settings.h" |
18 #include "components/favicon_base/favicon_types.h" | 19 #include "components/favicon_base/favicon_types.h" |
19 #include "content/public/browser/notification_details.h" | 20 #include "content/public/browser/notification_details.h" |
20 #include "content/public/browser/notification_observer.h" | 21 #include "content/public/browser/notification_observer.h" |
21 #include "content/public/browser/notification_registrar.h" | 22 #include "content/public/browser/notification_registrar.h" |
22 #include "content/public/browser/notification_source.h" | 23 #include "content/public/browser/notification_source.h" |
23 #include "ui/message_center/notifier_settings.h" | 24 #include "ui/message_center/notifier_settings.h" |
24 | 25 |
25 #if defined(OS_CHROMEOS) | 26 #if defined(OS_CHROMEOS) |
26 #include "components/user_manager/user_manager.h" | 27 #include "components/user_manager/user_manager.h" |
(...skipping 12 matching lines...) Expand all Loading... |
39 | 40 |
40 namespace message_center { | 41 namespace message_center { |
41 class ProfileNotifierGroup; | 42 class ProfileNotifierGroup; |
42 } | 43 } |
43 | 44 |
44 // The class to bridge between the settings UI of notifiers and the preference | 45 // The class to bridge between the settings UI of notifiers and the preference |
45 // storage. | 46 // storage. |
46 class MessageCenterSettingsController | 47 class MessageCenterSettingsController |
47 : public message_center::NotifierSettingsProvider, | 48 : public message_center::NotifierSettingsProvider, |
48 public content::NotificationObserver, | 49 public content::NotificationObserver, |
| 50 public ProfileInfoCacheObserver, |
49 #if defined(OS_CHROMEOS) | 51 #if defined(OS_CHROMEOS) |
50 public user_manager::UserManager::UserSessionStateObserver, | 52 public user_manager::UserManager::UserSessionStateObserver, |
51 #endif | 53 #endif |
52 public extensions::AppIconLoader::Delegate { | 54 public extensions::AppIconLoader::Delegate { |
53 public: | 55 public: |
54 explicit MessageCenterSettingsController( | 56 explicit MessageCenterSettingsController( |
55 ProfileInfoCache* profile_info_cache); | 57 ProfileInfoCache* profile_info_cache); |
56 ~MessageCenterSettingsController() override; | 58 ~MessageCenterSettingsController() override; |
57 | 59 |
58 // Overridden from message_center::NotifierSettingsProvider. | 60 // Overridden from message_center::NotifierSettingsProvider. |
(...skipping 24 matching lines...) Expand all Loading... |
83 | 85 |
84 // Overridden from extensions::AppIconLoader::Delegate. | 86 // Overridden from extensions::AppIconLoader::Delegate. |
85 void SetAppImage(const std::string& id, const gfx::ImageSkia& image) override; | 87 void SetAppImage(const std::string& id, const gfx::ImageSkia& image) override; |
86 | 88 |
87 private: | 89 private: |
88 // Overridden from content::NotificationObserver. | 90 // Overridden from content::NotificationObserver. |
89 void Observe(int type, | 91 void Observe(int type, |
90 const content::NotificationSource& source, | 92 const content::NotificationSource& source, |
91 const content::NotificationDetails& details) override; | 93 const content::NotificationDetails& details) override; |
92 | 94 |
| 95 // ProfileInfoCacheObserver: |
| 96 void OnProfileAdded(const base::FilePath& profile_path) override; |
| 97 void OnProfileWasRemoved(const base::FilePath& profile_path, |
| 98 const base::string16& profile_name) override; |
| 99 void OnProfileNameChanged(const base::FilePath& profile_path, |
| 100 const base::string16& old_profile_name) override; |
| 101 void OnProfileUserNameChanged(const base::FilePath& profile_path) override; |
| 102 |
93 void OnFaviconLoaded(const GURL& url, | 103 void OnFaviconLoaded(const GURL& url, |
94 const favicon_base::FaviconImageResult& favicon_result); | 104 const favicon_base::FaviconImageResult& favicon_result); |
95 | 105 |
96 #if defined(OS_CHROMEOS) | 106 #if defined(OS_CHROMEOS) |
97 // Sets up the notifier group for the guest session. This needs to be | 107 // Sets up the notifier group for the guest session. This needs to be |
98 // separated from RebuildNotifierGroup() and called asynchronously to avoid | 108 // separated from RebuildNotifierGroup() and called asynchronously to avoid |
99 // the infinite loop of creating profile. See more the comment of | 109 // the infinite loop of creating profile. See more the comment of |
100 // RebuildNotifierGroups(). | 110 // RebuildNotifierGroups(). |
101 void CreateNotifierGroupForGuestLogin(); | 111 void CreateNotifierGroupForGuestLogin(); |
102 #endif | 112 #endif |
103 | 113 |
104 void RebuildNotifierGroups(); | 114 // Sets up the notifier groups for all profiles. If |notify| is true, then |
| 115 // it sends out a NotifierGroupChange notification to each observer. |
| 116 void RebuildNotifierGroups(bool notify); |
105 | 117 |
106 // The views displaying notifier settings. | 118 // The views displaying notifier settings. |
107 ObserverList<message_center::NotifierSettingsObserver> observers_; | 119 ObserverList<message_center::NotifierSettingsObserver> observers_; |
108 | 120 |
109 // The task tracker for loading favicons. | 121 // The task tracker for loading favicons. |
110 scoped_ptr<base::CancelableTaskTracker> favicon_tracker_; | 122 scoped_ptr<base::CancelableTaskTracker> favicon_tracker_; |
111 | 123 |
112 scoped_ptr<extensions::AppIconLoader> app_icon_loader_; | 124 scoped_ptr<extensions::AppIconLoader> app_icon_loader_; |
113 | 125 |
114 std::map<base::string16, ContentSettingsPattern> patterns_; | 126 std::map<base::string16, ContentSettingsPattern> patterns_; |
115 | 127 |
116 // The list of all configurable notifier groups. This is each profile that is | 128 // The list of all configurable notifier groups. This is each profile that is |
117 // loaded (and in the ProfileInfoCache - so no incognito profiles go here). | 129 // loaded (and in the ProfileInfoCache - so no incognito profiles go here). |
118 ScopedVector<message_center::ProfileNotifierGroup> notifier_groups_; | 130 ScopedVector<message_center::ProfileNotifierGroup> notifier_groups_; |
119 size_t current_notifier_group_; | 131 size_t current_notifier_group_; |
120 | 132 |
121 content::NotificationRegistrar registrar_; | 133 content::NotificationRegistrar registrar_; |
122 | 134 |
123 ProfileInfoCache* profile_info_cache_; | 135 ProfileInfoCache* profile_info_cache_; |
124 | 136 |
125 base::WeakPtrFactory<MessageCenterSettingsController> weak_factory_; | 137 base::WeakPtrFactory<MessageCenterSettingsController> weak_factory_; |
126 | 138 |
127 DISALLOW_COPY_AND_ASSIGN(MessageCenterSettingsController); | 139 DISALLOW_COPY_AND_ASSIGN(MessageCenterSettingsController); |
128 }; | 140 }; |
129 | 141 |
130 #endif // CHROME_BROWSER_NOTIFICATIONS_MESSAGE_CENTER_SETTINGS_CONTROLLER_H_ | 142 #endif // CHROME_BROWSER_NOTIFICATIONS_MESSAGE_CENTER_SETTINGS_CONTROLLER_H_ |
OLD | NEW |