Chromium Code Reviews| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 #include "content/public/browser/notification_observer.h" | 23 #include "content/public/browser/notification_observer.h" |
| 24 #include "content/public/browser/notification_registrar.h" | 24 #include "content/public/browser/notification_registrar.h" |
| 25 #include "content/public/browser/notification_source.h" | 25 #include "content/public/browser/notification_source.h" |
| 26 #include "ui/message_center/notifier_settings.h" | 26 #include "ui/message_center/notifier_settings.h" |
| 27 | 27 |
| 28 #if defined(OS_CHROMEOS) | 28 #if defined(OS_CHROMEOS) |
| 29 #include "components/user_manager/user_manager.h" | 29 #include "components/user_manager/user_manager.h" |
| 30 #endif | 30 #endif |
| 31 | 31 |
| 32 class Profile; | 32 class Profile; |
| 33 | 33 class NotifierSource; |
| 34 #if defined(OS_CHROMEOS) | |
| 35 namespace arc { | |
| 36 class ArcNotifierManager; | |
| 37 } | |
| 38 #endif | |
| 39 | 34 |
| 40 namespace base { | 35 namespace base { |
| 41 class CancelableTaskTracker; | 36 class CancelableTaskTracker; |
| 42 } | 37 } |
| 43 | 38 |
| 44 namespace favicon_base { | 39 namespace favicon_base { |
| 45 struct FaviconImageResult; | 40 struct FaviconImageResult; |
| 46 } | 41 } |
| 47 | 42 |
| 48 namespace message_center { | 43 namespace message_center { |
| 49 class ProfileNotifierGroup; | 44 class ProfileNotifierGroup; |
| 50 } | 45 } |
| 51 | 46 |
| 52 // The class to bridge between the settings UI of notifiers and the preference | 47 // The class to bridge between the settings UI of notifiers and the preference |
| 53 // storage. | 48 // storage. |
| 54 class MessageCenterSettingsController | 49 class MessageCenterSettingsController |
| 55 : public message_center::NotifierSettingsProvider, | 50 : public message_center::NotifierSettingsProvider, |
| 56 public content::NotificationObserver, | 51 public content::NotificationObserver, |
| 57 public ProfileAttributesStorage::Observer, | 52 public ProfileAttributesStorage::Observer, |
| 58 #if defined(OS_CHROMEOS) | 53 #if defined(OS_CHROMEOS) |
| 59 public user_manager::UserManager::UserSessionStateObserver, | 54 public user_manager::UserManager::UserSessionStateObserver, |
| 60 #endif | 55 #endif |
| 61 public AppIconLoaderDelegate { | 56 public message_center::NotifierSettingsObserver { |
| 62 public: | 57 public: |
| 63 explicit MessageCenterSettingsController( | 58 explicit MessageCenterSettingsController( |
| 64 ProfileAttributesStorage& profile_attributes_storage); | 59 ProfileAttributesStorage& profile_attributes_storage); |
| 65 ~MessageCenterSettingsController() override; | 60 ~MessageCenterSettingsController() override; |
| 66 | 61 |
| 67 // Overridden from message_center::NotifierSettingsProvider. | 62 // Overridden from message_center::NotifierSettingsProvider. |
| 68 void AddObserver(message_center::NotifierSettingsObserver* observer) override; | 63 void AddObserver(message_center::NotifierSettingsObserver* observer) override; |
| 69 void RemoveObserver( | 64 void RemoveObserver( |
| 70 message_center::NotifierSettingsObserver* observer) override; | 65 message_center::NotifierSettingsObserver* observer) override; |
| 71 size_t GetNotifierGroupCount() const override; | 66 size_t GetNotifierGroupCount() const override; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 83 const message_center::NotifierId& notifier_id) const override; | 78 const message_center::NotifierId& notifier_id) const override; |
| 84 void OnNotifierAdvancedSettingsRequested( | 79 void OnNotifierAdvancedSettingsRequested( |
| 85 const message_center::NotifierId& notifier_id, | 80 const message_center::NotifierId& notifier_id, |
| 86 const std::string* notification_id) override; | 81 const std::string* notification_id) override; |
| 87 | 82 |
| 88 #if defined(OS_CHROMEOS) | 83 #if defined(OS_CHROMEOS) |
| 89 // Overridden from user_manager::UserManager::UserSessionStateObserver. | 84 // Overridden from user_manager::UserManager::UserSessionStateObserver. |
| 90 void ActiveUserChanged(const user_manager::User* active_user) override; | 85 void ActiveUserChanged(const user_manager::User* active_user) override; |
| 91 #endif | 86 #endif |
| 92 | 87 |
| 93 // Overridden from AppIconLoaderDelegate. | |
| 94 void OnAppImageUpdated(const std::string& id, | |
| 95 const gfx::ImageSkia& image) override; | |
| 96 | |
| 97 private: | 88 private: |
| 98 // Overridden from content::NotificationObserver. | 89 // Overridden from content::NotificationObserver. |
| 99 void Observe(int type, | 90 void Observe(int type, |
| 100 const content::NotificationSource& source, | 91 const content::NotificationSource& source, |
| 101 const content::NotificationDetails& details) override; | 92 const content::NotificationDetails& details) override; |
| 102 | 93 |
| 103 // ProfileAttributesStorage::Observer: | 94 // Overridden from ProfileAttributesStorage::Observer. |
| 104 void OnProfileAdded(const base::FilePath& profile_path) override; | 95 void OnProfileAdded(const base::FilePath& profile_path) override; |
| 105 void OnProfileWasRemoved(const base::FilePath& profile_path, | 96 void OnProfileWasRemoved(const base::FilePath& profile_path, |
| 106 const base::string16& profile_name) override; | 97 const base::string16& profile_name) override; |
| 107 void OnProfileNameChanged(const base::FilePath& profile_path, | 98 void OnProfileNameChanged(const base::FilePath& profile_path, |
| 108 const base::string16& old_profile_name) override; | 99 const base::string16& old_profile_name) override; |
| 109 void OnProfileAuthInfoChanged(const base::FilePath& profile_path) override; | 100 void OnProfileAuthInfoChanged(const base::FilePath& profile_path) override; |
| 110 | 101 |
| 111 void OnFaviconLoaded(const GURL& url, | 102 // Overridden from message_center::NotifierSettingsObserver. |
|
dewittj
2016/06/16 19:45:36
While I agree that pulling these out is a nice thi
| |
| 112 const favicon_base::FaviconImageResult& favicon_result); | 103 void UpdateIconImage(const message_center::NotifierId&, |
| 104 const gfx::Image&) override; | |
| 105 void NotifierGroupChanged() override; | |
| 106 void NotifierEnabledChanged(const message_center::NotifierId&, bool) override; | |
| 113 | 107 |
| 114 #if defined(OS_CHROMEOS) | 108 #if defined(OS_CHROMEOS) |
| 115 // Sets up the notifier group for the guest session. This needs to be | 109 // Sets up the notifier group for the guest session. This needs to be |
| 116 // separated from RebuildNotifierGroup() and called asynchronously to avoid | 110 // separated from RebuildNotifierGroup() and called asynchronously to avoid |
| 117 // the infinite loop of creating profile. See more the comment of | 111 // the infinite loop of creating profile. See more the comment of |
| 118 // RebuildNotifierGroups(). | 112 // RebuildNotifierGroups(). |
| 119 void CreateNotifierGroupForGuestLogin(); | 113 void CreateNotifierGroupForGuestLogin(); |
| 120 #endif | 114 #endif |
| 121 | 115 |
| 122 // Sets up the notifier groups for all profiles. If |notify| is true, then | 116 // Sets up the notifier groups for all profiles. If |notify| is true, then |
| 123 // it sends out a NotifierGroupChange notification to each observer. | 117 // it sends out a NotifierGroupChange notification to each observer. |
| 124 void RebuildNotifierGroups(bool notify); | 118 void RebuildNotifierGroups(bool notify); |
| 125 | 119 |
| 126 // The views displaying notifier settings. | 120 // The views displaying notifier settings. |
| 127 base::ObserverList<message_center::NotifierSettingsObserver> observers_; | 121 base::ObserverList<message_center::NotifierSettingsObserver> observers_; |
| 128 | 122 |
| 129 // The task tracker for loading favicons. | |
| 130 std::unique_ptr<base::CancelableTaskTracker> favicon_tracker_; | |
| 131 | |
| 132 std::unique_ptr<AppIconLoader> app_icon_loader_; | |
| 133 | |
| 134 #if defined(OS_CHROMEOS) | |
| 135 std::unique_ptr<arc::ArcNotifierManager> arc_notifier_manager_; | |
| 136 #endif | |
| 137 | |
| 138 std::map<base::string16, ContentSettingsPattern> patterns_; | |
| 139 | |
| 140 // The list of all configurable notifier groups. This is each profile that is | 123 // The list of all configurable notifier groups. This is each profile that is |
| 141 // loaded (and in the ProfileAttributesStorage - so no incognito profiles go | 124 // loaded (and in the ProfileAttributesStorage - so no incognito profiles go |
| 142 // here). | 125 // here). |
| 143 std::vector<std::unique_ptr<message_center::ProfileNotifierGroup>> | 126 std::vector<std::unique_ptr<message_center::ProfileNotifierGroup>> |
| 144 notifier_groups_; | 127 notifier_groups_; |
| 145 | 128 |
| 129 // Notifier source for each notifier type. | |
| 130 std::map<message_center::NotifierId::NotifierType, | |
| 131 std::unique_ptr<NotifierSource>> | |
| 132 sources_; | |
| 133 | |
| 146 size_t current_notifier_group_; | 134 size_t current_notifier_group_; |
| 147 | 135 |
| 148 content::NotificationRegistrar registrar_; | 136 content::NotificationRegistrar registrar_; |
| 149 | 137 |
| 150 ProfileAttributesStorage& profile_attributes_storage_; | 138 ProfileAttributesStorage& profile_attributes_storage_; |
| 151 | 139 |
| 152 base::WeakPtrFactory<MessageCenterSettingsController> weak_factory_; | 140 base::WeakPtrFactory<MessageCenterSettingsController> weak_factory_; |
| 153 | 141 |
| 154 DISALLOW_COPY_AND_ASSIGN(MessageCenterSettingsController); | 142 DISALLOW_COPY_AND_ASSIGN(MessageCenterSettingsController); |
| 155 }; | 143 }; |
| 156 | 144 |
| 157 #endif // CHROME_BROWSER_NOTIFICATIONS_MESSAGE_CENTER_SETTINGS_CONTROLLER_H_ | 145 #endif // CHROME_BROWSER_NOTIFICATIONS_MESSAGE_CENTER_SETTINGS_CONTROLLER_H_ |
| OLD | NEW |