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

Side by Side Diff: chrome/browser/chromeos/policy/device_local_account_policy_service.h

Issue 23494053: Remove NOTIFICATION_SYSTEM_SETTING_CHANGED, switch CrosSettings to base::CallbackRegistry. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: trailing space Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_POLICY_SERVICE_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_POLICY_SERVICE_H_
6 #define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_POLICY_SERVICE_H_ 6 #define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_POLICY_SERVICE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.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 "chrome/browser/chromeos/settings/cros_settings.h"
17 #include "chrome/browser/policy/cloud/cloud_policy_core.h" 18 #include "chrome/browser/policy/cloud/cloud_policy_core.h"
18 #include "chrome/browser/policy/cloud/cloud_policy_store.h" 19 #include "chrome/browser/policy/cloud/cloud_policy_store.h"
19 #include "content/public/browser/notification_observer.h"
20 20
21 namespace base { 21 namespace base {
22 class SequencedTaskRunner; 22 class SequencedTaskRunner;
23 } 23 }
24 24
25 namespace chromeos { 25 namespace chromeos {
26 class CrosSettings; 26 class CrosSettings;
27 class DeviceSettingsService; 27 class DeviceSettingsService;
28 class SessionManagerClient; 28 class SessionManagerClient;
29 } 29 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 scoped_ptr<DeviceLocalAccountPolicyStore> store_; 68 scoped_ptr<DeviceLocalAccountPolicyStore> store_;
69 CloudPolicyCore core_; 69 CloudPolicyCore core_;
70 70
71 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyBroker); 71 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyBroker);
72 }; 72 };
73 73
74 // Manages user policy blobs for device-local accounts present on the device. 74 // Manages user policy blobs for device-local accounts present on the device.
75 // The actual policy blobs are brokered by session_manager (to prevent file 75 // The actual policy blobs are brokered by session_manager (to prevent file
76 // manipulation), and we're making signature checks on the policy blobs to 76 // manipulation), and we're making signature checks on the policy blobs to
77 // ensure they're issued by the device owner. 77 // ensure they're issued by the device owner.
78 class DeviceLocalAccountPolicyService : public content::NotificationObserver, 78 class DeviceLocalAccountPolicyService : public CloudPolicyStore::Observer {
79 public CloudPolicyStore::Observer {
80 public: 79 public:
81 // Interface for interested parties to observe policy changes. 80 // Interface for interested parties to observe policy changes.
82 class Observer { 81 class Observer {
83 public: 82 public:
84 virtual ~Observer() {} 83 virtual ~Observer() {}
85 84
86 // Policy for the given |user_id| has changed. 85 // Policy for the given |user_id| has changed.
87 virtual void OnPolicyUpdated(const std::string& user_id) = 0; 86 virtual void OnPolicyUpdated(const std::string& user_id) = 0;
88 87
89 // The list of accounts has been updated. 88 // The list of accounts has been updated.
(...skipping 16 matching lines...) Expand all
106 // does not belong to an existing device-local account. 105 // does not belong to an existing device-local account.
107 DeviceLocalAccountPolicyBroker* GetBrokerForUser(const std::string& user_id); 106 DeviceLocalAccountPolicyBroker* GetBrokerForUser(const std::string& user_id);
108 107
109 // Indicates whether policy has been successfully fetched for the given 108 // Indicates whether policy has been successfully fetched for the given
110 // |user_id|. 109 // |user_id|.
111 bool IsPolicyAvailableForUser(const std::string& user_id); 110 bool IsPolicyAvailableForUser(const std::string& user_id);
112 111
113 void AddObserver(Observer* observer); 112 void AddObserver(Observer* observer);
114 void RemoveObserver(Observer* observer); 113 void RemoveObserver(Observer* observer);
115 114
116 // NotificationObserver:
117 virtual void Observe(int type,
118 const content::NotificationSource& source,
119 const content::NotificationDetails& details) OVERRIDE;
120
121 // CloudPolicyStore::Observer: 115 // CloudPolicyStore::Observer:
122 virtual void OnStoreLoaded(CloudPolicyStore* store) OVERRIDE; 116 virtual void OnStoreLoaded(CloudPolicyStore* store) OVERRIDE;
123 virtual void OnStoreError(CloudPolicyStore* store) OVERRIDE; 117 virtual void OnStoreError(CloudPolicyStore* store) OVERRIDE;
124 118
125 private: 119 private:
126 struct PolicyBrokerWrapper { 120 struct PolicyBrokerWrapper {
127 PolicyBrokerWrapper(); 121 PolicyBrokerWrapper();
128 122
129 // Return the |broker|, creating it first if necessary. 123 // Return the |broker|, creating it first if necessary.
130 DeviceLocalAccountPolicyBroker* GetBroker(); 124 DeviceLocalAccountPolicyBroker* GetBroker();
(...skipping 13 matching lines...) Expand all
144 DeviceLocalAccountPolicyService* parent; 138 DeviceLocalAccountPolicyService* parent;
145 DeviceLocalAccountPolicyBroker* broker; 139 DeviceLocalAccountPolicyBroker* broker;
146 }; 140 };
147 141
148 typedef std::map<std::string, PolicyBrokerWrapper> PolicyBrokerMap; 142 typedef std::map<std::string, PolicyBrokerWrapper> PolicyBrokerMap;
149 143
150 // Re-queries the list of defined device-local accounts from device settings 144 // Re-queries the list of defined device-local accounts from device settings
151 // and updates |policy_brokers_| to match that list. 145 // and updates |policy_brokers_| to match that list.
152 void UpdateAccountList(); 146 void UpdateAccountList();
153 147
148 // Calls |UpdateAccountList| if there are no previous calls pending.
149 void UpdateAccountListIfNonePending();
150
154 // Deletes brokers in |map| and clears it. 151 // Deletes brokers in |map| and clears it.
155 void DeleteBrokers(PolicyBrokerMap* map); 152 void DeleteBrokers(PolicyBrokerMap* map);
156 153
157 // Find the broker for a given |store|. Returns NULL if |store| is unknown. 154 // Find the broker for a given |store|. Returns NULL if |store| is unknown.
158 DeviceLocalAccountPolicyBroker* GetBrokerForStore(CloudPolicyStore* store); 155 DeviceLocalAccountPolicyBroker* GetBrokerForStore(CloudPolicyStore* store);
159 156
160 chromeos::SessionManagerClient* session_manager_client_; 157 chromeos::SessionManagerClient* session_manager_client_;
161 chromeos::DeviceSettingsService* device_settings_service_; 158 chromeos::DeviceSettingsService* device_settings_service_;
162 chromeos::CrosSettings* cros_settings_; 159 chromeos::CrosSettings* cros_settings_;
163 160
164 DeviceManagementService* device_management_service_; 161 DeviceManagementService* device_management_service_;
165 162
166 // The device-local account policy brokers, keyed by user ID. 163 // The device-local account policy brokers, keyed by user ID.
167 PolicyBrokerMap policy_brokers_; 164 PolicyBrokerMap policy_brokers_;
168 165
169 ObserverList<Observer, true> observers_; 166 ObserverList<Observer, true> observers_;
170 167
168 scoped_ptr<chromeos::CrosSettings::ObserverSubscription>
169 local_accounts_subscription_;
170
171 // Weak pointer factory for cros_settings_->PrepareTrustedValues() callbacks. 171 // Weak pointer factory for cros_settings_->PrepareTrustedValues() callbacks.
172 base::WeakPtrFactory<DeviceLocalAccountPolicyService> 172 base::WeakPtrFactory<DeviceLocalAccountPolicyService>
173 cros_settings_callback_factory_; 173 cros_settings_callback_factory_;
174 174
175 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyService); 175 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyService);
176 }; 176 };
177 177
178 } // namespace policy 178 } // namespace policy
179 179
180 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_POLICY_SERVICE_H_ 180 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_POLICY_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698