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

Side by Side Diff: chrome/browser/notifications/message_center_settings_controller.h

Issue 1657913003: Refactor of ProfileInfoCache in c/b/notifications (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix errors Created 4 years, 10 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) 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>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/observer_list.h" 16 #include "base/observer_list.h"
17 #include "build/build_config.h" 17 #include "build/build_config.h"
18 #include "chrome/browser/extensions/app_icon_loader.h" 18 #include "chrome/browser/extensions/app_icon_loader.h"
19 #include "chrome/browser/profiles/profile_info_cache_observer.h" 19 #include "chrome/browser/profiles/profile_attributes_storage.h"
20 #include "components/content_settings/core/common/content_settings.h" 20 #include "components/content_settings/core/common/content_settings.h"
21 #include "components/favicon_base/favicon_types.h" 21 #include "components/favicon_base/favicon_types.h"
22 #include "content/public/browser/notification_details.h" 22 #include "content/public/browser/notification_details.h"
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 class ProfileInfoCache;
34 33
35 namespace base { 34 namespace base {
36 class CancelableTaskTracker; 35 class CancelableTaskTracker;
37 } 36 }
38 37
39 namespace favicon_base { 38 namespace favicon_base {
40 struct FaviconImageResult; 39 struct FaviconImageResult;
41 } 40 }
42 41
43 namespace message_center { 42 namespace message_center {
44 class ProfileNotifierGroup; 43 class ProfileNotifierGroup;
45 } 44 }
46 45
47 // The class to bridge between the settings UI of notifiers and the preference 46 // The class to bridge between the settings UI of notifiers and the preference
48 // storage. 47 // storage.
49 class MessageCenterSettingsController 48 class MessageCenterSettingsController
50 : public message_center::NotifierSettingsProvider, 49 : public message_center::NotifierSettingsProvider,
51 public content::NotificationObserver, 50 public content::NotificationObserver,
52 public ProfileInfoCacheObserver, 51 public ProfileAttributesStorage::Observer,
53 #if defined(OS_CHROMEOS) 52 #if defined(OS_CHROMEOS)
54 public user_manager::UserManager::UserSessionStateObserver, 53 public user_manager::UserManager::UserSessionStateObserver,
55 #endif 54 #endif
56 public extensions::AppIconLoader::Delegate { 55 public extensions::AppIconLoader::Delegate {
57 public: 56 public:
58 explicit MessageCenterSettingsController( 57 explicit MessageCenterSettingsController(ProfileAttributesStorage& storage);
59 ProfileInfoCache* profile_info_cache);
60 ~MessageCenterSettingsController() override; 58 ~MessageCenterSettingsController() override;
61 59
62 // Overridden from message_center::NotifierSettingsProvider. 60 // Overridden from message_center::NotifierSettingsProvider.
63 void AddObserver(message_center::NotifierSettingsObserver* observer) override; 61 void AddObserver(message_center::NotifierSettingsObserver* observer) override;
64 void RemoveObserver( 62 void RemoveObserver(
65 message_center::NotifierSettingsObserver* observer) override; 63 message_center::NotifierSettingsObserver* observer) override;
66 size_t GetNotifierGroupCount() const override; 64 size_t GetNotifierGroupCount() const override;
67 const message_center::NotifierGroup& GetNotifierGroupAt( 65 const message_center::NotifierGroup& GetNotifierGroupAt(
68 size_t index) const override; 66 size_t index) const override;
69 bool IsNotifierGroupActiveAt(size_t index) const override; 67 bool IsNotifierGroupActiveAt(size_t index) const override;
(...skipping 17 matching lines...) Expand all
87 85
88 // Overridden from extensions::AppIconLoader::Delegate. 86 // Overridden from extensions::AppIconLoader::Delegate.
89 void SetAppImage(const std::string& id, const gfx::ImageSkia& image) override; 87 void SetAppImage(const std::string& id, const gfx::ImageSkia& image) override;
90 88
91 private: 89 private:
92 // Overridden from content::NotificationObserver. 90 // Overridden from content::NotificationObserver.
93 void Observe(int type, 91 void Observe(int type,
94 const content::NotificationSource& source, 92 const content::NotificationSource& source,
95 const content::NotificationDetails& details) override; 93 const content::NotificationDetails& details) override;
96 94
97 // ProfileInfoCacheObserver: 95 // ProfileAttributesStorage::Observer:
98 void OnProfileAdded(const base::FilePath& profile_path) override; 96 void OnProfileAdded(const base::FilePath& profile_path) override;
99 void OnProfileWasRemoved(const base::FilePath& profile_path, 97 void OnProfileWasRemoved(const base::FilePath& profile_path,
100 const base::string16& profile_name) override; 98 const base::string16& profile_name) override;
101 void OnProfileNameChanged(const base::FilePath& profile_path, 99 void OnProfileNameChanged(const base::FilePath& profile_path,
102 const base::string16& old_profile_name) override; 100 const base::string16& old_profile_name) override;
103 void OnProfileAuthInfoChanged(const base::FilePath& profile_path) override; 101 void OnProfileAuthInfoChanged(const base::FilePath& profile_path) override;
104 102
105 void OnFaviconLoaded(const GURL& url, 103 void OnFaviconLoaded(const GURL& url,
106 const favicon_base::FaviconImageResult& favicon_result); 104 const favicon_base::FaviconImageResult& favicon_result);
107 105
(...skipping 13 matching lines...) Expand all
121 base::ObserverList<message_center::NotifierSettingsObserver> observers_; 119 base::ObserverList<message_center::NotifierSettingsObserver> observers_;
122 120
123 // The task tracker for loading favicons. 121 // The task tracker for loading favicons.
124 scoped_ptr<base::CancelableTaskTracker> favicon_tracker_; 122 scoped_ptr<base::CancelableTaskTracker> favicon_tracker_;
125 123
126 scoped_ptr<extensions::AppIconLoader> app_icon_loader_; 124 scoped_ptr<extensions::AppIconLoader> app_icon_loader_;
127 125
128 std::map<base::string16, ContentSettingsPattern> patterns_; 126 std::map<base::string16, ContentSettingsPattern> patterns_;
129 127
130 // 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
131 // loaded (and in the ProfileInfoCache - so no incognito profiles go here). 129 // loaded (and in the ProfileAttributesStorage - so no incognito profiles go
130 // here).
132 std::vector<scoped_ptr<message_center::ProfileNotifierGroup>> 131 std::vector<scoped_ptr<message_center::ProfileNotifierGroup>>
133 notifier_groups_; 132 notifier_groups_;
134 133
135 size_t current_notifier_group_; 134 size_t current_notifier_group_;
136 135
137 content::NotificationRegistrar registrar_; 136 content::NotificationRegistrar registrar_;
138 137
139 ProfileInfoCache* profile_info_cache_; 138 ProfileAttributesStorage& storage_;
dewittj 2016/02/08 18:07:10 nit: profile_attributes_storage_
lwchkg 2016/02/08 19:06:43 Acknowledged.
140 139
141 base::WeakPtrFactory<MessageCenterSettingsController> weak_factory_; 140 base::WeakPtrFactory<MessageCenterSettingsController> weak_factory_;
142 141
143 DISALLOW_COPY_AND_ASSIGN(MessageCenterSettingsController); 142 DISALLOW_COPY_AND_ASSIGN(MessageCenterSettingsController);
144 }; 143 };
145 144
146 #endif // CHROME_BROWSER_NOTIFICATIONS_MESSAGE_CENTER_SETTINGS_CONTROLLER_H_ 145 #endif // CHROME_BROWSER_NOTIFICATIONS_MESSAGE_CENTER_SETTINGS_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698