Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / notifications / message_center_settings_controller.h
blob6d81bbf9f0774e9676cf5c6bbff6f004bfe11a10
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_NOTIFICATIONS_MESSAGE_CENTER_SETTINGS_CONTROLLER_H_
6 #define CHROME_BROWSER_NOTIFICATIONS_MESSAGE_CENTER_SETTINGS_CONTROLLER_H_
8 #include <map>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/scoped_vector.h"
14 #include "base/memory/weak_ptr.h"
15 #include "base/observer_list.h"
16 #include "chrome/browser/extensions/app_icon_loader.h"
17 #include "chrome/browser/profiles/profile_info_cache_observer.h"
18 #include "components/content_settings/core/common/content_settings.h"
19 #include "components/favicon_base/favicon_types.h"
20 #include "content/public/browser/notification_details.h"
21 #include "content/public/browser/notification_observer.h"
22 #include "content/public/browser/notification_registrar.h"
23 #include "content/public/browser/notification_source.h"
24 #include "ui/message_center/notifier_settings.h"
26 #if defined(OS_CHROMEOS)
27 #include "components/user_manager/user_manager.h"
28 #endif
30 class Profile;
31 class ProfileInfoCache;
33 namespace base {
34 class CancelableTaskTracker;
37 namespace favicon_base {
38 struct FaviconImageResult;
41 namespace message_center {
42 class ProfileNotifierGroup;
45 // The class to bridge between the settings UI of notifiers and the preference
46 // storage.
47 class MessageCenterSettingsController
48 : public message_center::NotifierSettingsProvider,
49 public content::NotificationObserver,
50 public ProfileInfoCacheObserver,
51 #if defined(OS_CHROMEOS)
52 public user_manager::UserManager::UserSessionStateObserver,
53 #endif
54 public extensions::AppIconLoader::Delegate {
55 public:
56 explicit MessageCenterSettingsController(
57 ProfileInfoCache* profile_info_cache);
58 ~MessageCenterSettingsController() override;
60 // Overridden from message_center::NotifierSettingsProvider.
61 void AddObserver(message_center::NotifierSettingsObserver* observer) override;
62 void RemoveObserver(
63 message_center::NotifierSettingsObserver* observer) override;
64 size_t GetNotifierGroupCount() const override;
65 const message_center::NotifierGroup& GetNotifierGroupAt(
66 size_t index) const override;
67 bool IsNotifierGroupActiveAt(size_t index) const override;
68 void SwitchToNotifierGroup(size_t index) override;
69 const message_center::NotifierGroup& GetActiveNotifierGroup() const override;
70 void GetNotifierList(
71 std::vector<message_center::Notifier*>* notifiers) override;
72 void SetNotifierEnabled(const message_center::Notifier& notifier,
73 bool enabled) override;
74 void OnNotifierSettingsClosing() override;
75 bool NotifierHasAdvancedSettings(
76 const message_center::NotifierId& notifier_id) const override;
77 void OnNotifierAdvancedSettingsRequested(
78 const message_center::NotifierId& notifier_id,
79 const std::string* notification_id) override;
81 #if defined(OS_CHROMEOS)
82 // Overridden from user_manager::UserManager::UserSessionStateObserver.
83 void ActiveUserChanged(const user_manager::User* active_user) override;
84 #endif
86 // Overridden from extensions::AppIconLoader::Delegate.
87 void SetAppImage(const std::string& id, const gfx::ImageSkia& image) override;
89 private:
90 // Overridden from content::NotificationObserver.
91 void Observe(int type,
92 const content::NotificationSource& source,
93 const content::NotificationDetails& details) override;
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 OnProfileAuthInfoChanged(const base::FilePath& profile_path) override;
103 void OnFaviconLoaded(const GURL& url,
104 const favicon_base::FaviconImageResult& favicon_result);
106 #if defined(OS_CHROMEOS)
107 // Sets up the notifier group for the guest session. This needs to be
108 // separated from RebuildNotifierGroup() and called asynchronously to avoid
109 // the infinite loop of creating profile. See more the comment of
110 // RebuildNotifierGroups().
111 void CreateNotifierGroupForGuestLogin();
112 #endif
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);
118 // The views displaying notifier settings.
119 base::ObserverList<message_center::NotifierSettingsObserver> observers_;
121 // The task tracker for loading favicons.
122 scoped_ptr<base::CancelableTaskTracker> favicon_tracker_;
124 scoped_ptr<extensions::AppIconLoader> app_icon_loader_;
126 std::map<base::string16, ContentSettingsPattern> patterns_;
128 // The list of all configurable notifier groups. This is each profile that is
129 // loaded (and in the ProfileInfoCache - so no incognito profiles go here).
130 ScopedVector<message_center::ProfileNotifierGroup> notifier_groups_;
131 size_t current_notifier_group_;
133 content::NotificationRegistrar registrar_;
135 ProfileInfoCache* profile_info_cache_;
137 base::WeakPtrFactory<MessageCenterSettingsController> weak_factory_;
139 DISALLOW_COPY_AND_ASSIGN(MessageCenterSettingsController);
142 #endif // CHROME_BROWSER_NOTIFICATIONS_MESSAGE_CENTER_SETTINGS_CONTROLLER_H_