OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #include "chrome/browser/chromeos/policy/cloud_external_data_policy_observer.h" | 5 #include "chrome/browser/chromeos/policy/cloud_external_data_policy_observer.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 | 162 |
163 Profile* profile = content::Details<Profile>(details).ptr(); | 163 Profile* profile = content::Details<Profile>(details).ptr(); |
164 const user_manager::User* user = | 164 const user_manager::User* user = |
165 chromeos::ProfileHelper::Get()->GetUserByProfile(profile); | 165 chromeos::ProfileHelper::Get()->GetUserByProfile(profile); |
166 if (!user) { | 166 if (!user) { |
167 NOTREACHED(); | 167 NOTREACHED(); |
168 return; | 168 return; |
169 } | 169 } |
170 | 170 |
171 const std::string& user_id = user->email(); | 171 const std::string& user_id = user->email(); |
172 if (ContainsKey(logged_in_user_observers_, user_id)) { | 172 if (base::ContainsKey(logged_in_user_observers_, user_id)) { |
173 NOTREACHED(); | 173 NOTREACHED(); |
174 return; | 174 return; |
175 } | 175 } |
176 | 176 |
177 ProfilePolicyConnector* policy_connector = | 177 ProfilePolicyConnector* policy_connector = |
178 ProfilePolicyConnectorFactory::GetForBrowserContext(profile); | 178 ProfilePolicyConnectorFactory::GetForBrowserContext(profile); |
179 logged_in_user_observers_[user_id] = make_linked_ptr( | 179 logged_in_user_observers_[user_id] = make_linked_ptr( |
180 new PolicyServiceObserver(this, | 180 new PolicyServiceObserver(this, |
181 user_id, | 181 user_id, |
182 policy_connector->policy_service())); | 182 policy_connector->policy_service())); |
183 } | 183 } |
184 | 184 |
185 void CloudExternalDataPolicyObserver::OnPolicyUpdated( | 185 void CloudExternalDataPolicyObserver::OnPolicyUpdated( |
186 const std::string& user_id) { | 186 const std::string& user_id) { |
187 if (ContainsKey(logged_in_user_observers_, user_id)) { | 187 if (base::ContainsKey(logged_in_user_observers_, user_id)) { |
188 // When a device-local account is logged in, a policy change triggers both | 188 // When a device-local account is logged in, a policy change triggers both |
189 // OnPolicyUpdated() and PolicyServiceObserver::OnPolicyUpdated(). Ignore | 189 // OnPolicyUpdated() and PolicyServiceObserver::OnPolicyUpdated(). Ignore |
190 // the former so that the policy change is handled only once. | 190 // the former so that the policy change is handled only once. |
191 return; | 191 return; |
192 } | 192 } |
193 | 193 |
194 if (!device_local_account_policy_service_) { | 194 if (!device_local_account_policy_service_) { |
195 NOTREACHED(); | 195 NOTREACHED(); |
196 return; | 196 return; |
197 } | 197 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 std::set<std::string> device_local_accounts; | 246 std::set<std::string> device_local_accounts; |
247 for (std::vector<DeviceLocalAccount>::const_iterator it = | 247 for (std::vector<DeviceLocalAccount>::const_iterator it = |
248 device_local_account_list.begin(); | 248 device_local_account_list.begin(); |
249 it != device_local_account_list.end(); ++it) { | 249 it != device_local_account_list.end(); ++it) { |
250 device_local_accounts.insert(it->user_id); | 250 device_local_accounts.insert(it->user_id); |
251 } | 251 } |
252 | 252 |
253 for (DeviceLocalAccountEntryMap::iterator it = | 253 for (DeviceLocalAccountEntryMap::iterator it = |
254 device_local_account_entries_.begin(); | 254 device_local_account_entries_.begin(); |
255 it != device_local_account_entries_.end(); ) { | 255 it != device_local_account_entries_.end(); ) { |
256 if (!ContainsKey(device_local_accounts, it->first)) { | 256 if (!base::ContainsKey(device_local_accounts, it->first)) { |
257 const std::string user_id = it->first; | 257 const std::string user_id = it->first; |
258 device_local_account_entries_.erase(it++); | 258 device_local_account_entries_.erase(it++); |
259 // When a device-local account whose external data reference was set is | 259 // When a device-local account whose external data reference was set is |
260 // removed, emit a notification that the external data reference has been | 260 // removed, emit a notification that the external data reference has been |
261 // cleared. | 261 // cleared. |
262 HandleExternalDataPolicyUpdate(user_id, NULL); | 262 HandleExternalDataPolicyUpdate(user_id, NULL); |
263 } else { | 263 } else { |
264 ++it; | 264 ++it; |
265 } | 265 } |
266 } | 266 } |
(...skipping 30 matching lines...) Expand all Loading... |
297 void CloudExternalDataPolicyObserver::OnExternalDataFetched( | 297 void CloudExternalDataPolicyObserver::OnExternalDataFetched( |
298 const std::string& user_id, | 298 const std::string& user_id, |
299 std::unique_ptr<std::string> data) { | 299 std::unique_ptr<std::string> data) { |
300 FetchWeakPtrMap::iterator it = fetch_weak_ptrs_.find(user_id); | 300 FetchWeakPtrMap::iterator it = fetch_weak_ptrs_.find(user_id); |
301 DCHECK(it != fetch_weak_ptrs_.end()); | 301 DCHECK(it != fetch_weak_ptrs_.end()); |
302 fetch_weak_ptrs_.erase(it); | 302 fetch_weak_ptrs_.erase(it); |
303 delegate_->OnExternalDataFetched(policy_, user_id, std::move(data)); | 303 delegate_->OnExternalDataFetched(policy_, user_id, std::move(data)); |
304 } | 304 } |
305 | 305 |
306 } // namespace policy | 306 } // namespace policy |
OLD | NEW |