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

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: oops 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/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.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/chromeos/settings/cros_settings.h"
16 #include "chrome/browser/policy/cloud/cloud_policy_core.h" 17 #include "chrome/browser/policy/cloud/cloud_policy_core.h"
17 #include "chrome/browser/policy/cloud/cloud_policy_store.h" 18 #include "chrome/browser/policy/cloud/cloud_policy_store.h"
18 #include "content/public/browser/notification_observer.h"
19 19
20 namespace chromeos { 20 namespace chromeos {
21 class CrosSettings; 21 class CrosSettings;
22 class DeviceSettingsService; 22 class DeviceSettingsService;
23 class SessionManagerClient; 23 class SessionManagerClient;
24 } 24 }
25 25
26 namespace policy { 26 namespace policy {
27 27
28 class CloudPolicyClient; 28 class CloudPolicyClient;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 scoped_ptr<DeviceLocalAccountPolicyStore> store_; 61 scoped_ptr<DeviceLocalAccountPolicyStore> store_;
62 CloudPolicyCore core_; 62 CloudPolicyCore core_;
63 63
64 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyBroker); 64 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyBroker);
65 }; 65 };
66 66
67 // Manages user policy blobs for device-local accounts present on the device. 67 // Manages user policy blobs for device-local accounts present on the device.
68 // The actual policy blobs are brokered by session_manager (to prevent file 68 // The actual policy blobs are brokered by session_manager (to prevent file
69 // manipulation), and we're making signature checks on the policy blobs to 69 // manipulation), and we're making signature checks on the policy blobs to
70 // ensure they're issued by the device owner. 70 // ensure they're issued by the device owner.
71 class DeviceLocalAccountPolicyService : public content::NotificationObserver, 71 class DeviceLocalAccountPolicyService : public CloudPolicyStore::Observer {
72 public CloudPolicyStore::Observer {
73 public: 72 public:
74 // Interface for interested parties to observe policy changes. 73 // Interface for interested parties to observe policy changes.
75 class Observer { 74 class Observer {
76 public: 75 public:
77 virtual ~Observer() {} 76 virtual ~Observer() {}
78 77
79 // Policy for the given |user_id| has changed. 78 // Policy for the given |user_id| has changed.
80 virtual void OnPolicyUpdated(const std::string& user_id) = 0; 79 virtual void OnPolicyUpdated(const std::string& user_id) = 0;
81 80
82 // The list of accounts has been updated. 81 // The list of accounts has been updated.
(...skipping 16 matching lines...) Expand all
99 // does not belong to an existing device-local account. 98 // does not belong to an existing device-local account.
100 DeviceLocalAccountPolicyBroker* GetBrokerForUser(const std::string& user_id); 99 DeviceLocalAccountPolicyBroker* GetBrokerForUser(const std::string& user_id);
101 100
102 // Indicates whether policy has been successfully fetched for the given 101 // Indicates whether policy has been successfully fetched for the given
103 // |user_id|. 102 // |user_id|.
104 bool IsPolicyAvailableForUser(const std::string& user_id); 103 bool IsPolicyAvailableForUser(const std::string& user_id);
105 104
106 void AddObserver(Observer* observer); 105 void AddObserver(Observer* observer);
107 void RemoveObserver(Observer* observer); 106 void RemoveObserver(Observer* observer);
108 107
109 // NotificationObserver:
110 virtual void Observe(int type,
111 const content::NotificationSource& source,
112 const content::NotificationDetails& details) OVERRIDE;
113
114 // CloudPolicyStore::Observer: 108 // CloudPolicyStore::Observer:
115 virtual void OnStoreLoaded(CloudPolicyStore* store) OVERRIDE; 109 virtual void OnStoreLoaded(CloudPolicyStore* store) OVERRIDE;
116 virtual void OnStoreError(CloudPolicyStore* store) OVERRIDE; 110 virtual void OnStoreError(CloudPolicyStore* store) OVERRIDE;
117 111
118 private: 112 private:
119 struct PolicyBrokerWrapper { 113 struct PolicyBrokerWrapper {
120 PolicyBrokerWrapper(); 114 PolicyBrokerWrapper();
121 115
122 // Return the |broker|, creating it first if necessary. 116 // Return the |broker|, creating it first if necessary.
123 DeviceLocalAccountPolicyBroker* GetBroker(); 117 DeviceLocalAccountPolicyBroker* GetBroker();
(...skipping 13 matching lines...) Expand all
137 DeviceLocalAccountPolicyService* parent; 131 DeviceLocalAccountPolicyService* parent;
138 DeviceLocalAccountPolicyBroker* broker; 132 DeviceLocalAccountPolicyBroker* broker;
139 }; 133 };
140 134
141 typedef std::map<std::string, PolicyBrokerWrapper> PolicyBrokerMap; 135 typedef std::map<std::string, PolicyBrokerWrapper> PolicyBrokerMap;
142 136
143 // Re-queries the list of defined device-local accounts from device settings 137 // Re-queries the list of defined device-local accounts from device settings
144 // and updates |policy_brokers_| to match that list. 138 // and updates |policy_brokers_| to match that list.
145 void UpdateAccountList(); 139 void UpdateAccountList();
146 140
141 // Calls |UpdateAccountList| if there are no previous calls pending.
142 void UpdateAccountListIfNonePending();
143
147 // Deletes brokers in |map| and clears it. 144 // Deletes brokers in |map| and clears it.
148 void DeleteBrokers(PolicyBrokerMap* map); 145 void DeleteBrokers(PolicyBrokerMap* map);
149 146
150 // Find the broker for a given |store|. Returns NULL if |store| is unknown. 147 // Find the broker for a given |store|. Returns NULL if |store| is unknown.
151 DeviceLocalAccountPolicyBroker* GetBrokerForStore(CloudPolicyStore* store); 148 DeviceLocalAccountPolicyBroker* GetBrokerForStore(CloudPolicyStore* store);
152 149
153 chromeos::SessionManagerClient* session_manager_client_; 150 chromeos::SessionManagerClient* session_manager_client_;
154 chromeos::DeviceSettingsService* device_settings_service_; 151 chromeos::DeviceSettingsService* device_settings_service_;
155 chromeos::CrosSettings* cros_settings_; 152 chromeos::CrosSettings* cros_settings_;
156 153
157 DeviceManagementService* device_management_service_; 154 DeviceManagementService* device_management_service_;
158 155
159 // The device-local account policy brokers, keyed by user ID. 156 // The device-local account policy brokers, keyed by user ID.
160 PolicyBrokerMap policy_brokers_; 157 PolicyBrokerMap policy_brokers_;
161 158
162 ObserverList<Observer, true> observers_; 159 ObserverList<Observer, true> observers_;
163 160
161 scoped_ptr<chromeos::CrosSettings::ObserverSubscription>
162 local_accounts_subscription_;
163
164 // Weak pointer factory for cros_settings_->PrepareTrustedValues() callbacks. 164 // Weak pointer factory for cros_settings_->PrepareTrustedValues() callbacks.
165 base::WeakPtrFactory<DeviceLocalAccountPolicyService> 165 base::WeakPtrFactory<DeviceLocalAccountPolicyService>
166 cros_settings_callback_factory_; 166 cros_settings_callback_factory_;
167 167
168 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyService); 168 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyService);
169 }; 169 };
170 170
171 } // namespace policy 171 } // namespace policy
172 172
173 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_POLICY_SERVICE_H_ 173 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_POLICY_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698