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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "chrome/browser/chrome_notification_types.h" | 15 #include "chrome/browser/chrome_notification_types.h" |
16 #include "chrome/browser/chromeos/login/users/user.h" | |
17 #include "chrome/browser/chromeos/policy/device_local_account.h" | 16 #include "chrome/browser/chromeos/policy/device_local_account.h" |
18 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 17 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
19 #include "chrome/browser/policy/profile_policy_connector.h" | 18 #include "chrome/browser/policy/profile_policy_connector.h" |
20 #include "chrome/browser/policy/profile_policy_connector_factory.h" | 19 #include "chrome/browser/policy/profile_policy_connector_factory.h" |
21 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
22 #include "chromeos/settings/cros_settings_names.h" | 21 #include "chromeos/settings/cros_settings_names.h" |
23 #include "chromeos/settings/cros_settings_provider.h" | 22 #include "chromeos/settings/cros_settings_provider.h" |
24 #include "components/policy/core/common/cloud/cloud_policy_core.h" | 23 #include "components/policy/core/common/cloud/cloud_policy_core.h" |
25 #include "components/policy/core/common/cloud/cloud_policy_store.h" | 24 #include "components/policy/core/common/cloud/cloud_policy_store.h" |
26 #include "components/policy/core/common/external_data_fetcher.h" | 25 #include "components/policy/core/common/external_data_fetcher.h" |
27 #include "components/policy/core/common/policy_namespace.h" | 26 #include "components/policy/core/common/policy_namespace.h" |
28 #include "components/policy/core/common/policy_service.h" | 27 #include "components/policy/core/common/policy_service.h" |
| 28 #include "components/user_manager/user.h" |
29 #include "content/public/browser/notification_details.h" | 29 #include "content/public/browser/notification_details.h" |
30 #include "content/public/browser/notification_service.h" | 30 #include "content/public/browser/notification_service.h" |
31 #include "content/public/browser/notification_source.h" | 31 #include "content/public/browser/notification_source.h" |
32 | 32 |
33 namespace policy { | 33 namespace policy { |
34 | 34 |
35 // Helper class that observes a policy for a logged-in user, notifying the | 35 // Helper class that observes a policy for a logged-in user, notifying the |
36 // |parent_| whenever the external data reference for this user changes. | 36 // |parent_| whenever the external data reference for this user changes. |
37 class CloudExternalDataPolicyObserver::PolicyServiceObserver | 37 class CloudExternalDataPolicyObserver::PolicyServiceObserver |
38 : public PolicyService::Observer { | 38 : public PolicyService::Observer { |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 void CloudExternalDataPolicyObserver::Observe( | 161 void CloudExternalDataPolicyObserver::Observe( |
162 int type, | 162 int type, |
163 const content::NotificationSource& source, | 163 const content::NotificationSource& source, |
164 const content::NotificationDetails& details) { | 164 const content::NotificationDetails& details) { |
165 if (type != chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED) { | 165 if (type != chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED) { |
166 NOTREACHED(); | 166 NOTREACHED(); |
167 return; | 167 return; |
168 } | 168 } |
169 Profile* profile = content::Details<Profile>(details).ptr(); | 169 Profile* profile = content::Details<Profile>(details).ptr(); |
170 | 170 |
171 const chromeos::User* user = | 171 const user_manager::User* user = |
172 chromeos::ProfileHelper::Get()->GetUserByProfile(profile); | 172 chromeos::ProfileHelper::Get()->GetUserByProfile(profile); |
173 if (!user) { | 173 if (!user) { |
174 NOTREACHED(); | 174 NOTREACHED(); |
175 return; | 175 return; |
176 } | 176 } |
177 | 177 |
178 const std::string& user_id = user->email(); | 178 const std::string& user_id = user->email(); |
179 if (ContainsKey(logged_in_user_observers_, user_id)) { | 179 if (ContainsKey(logged_in_user_observers_, user_id)) { |
180 NOTREACHED(); | 180 NOTREACHED(); |
181 return; | 181 return; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 void CloudExternalDataPolicyObserver::OnExternalDataFetched( | 307 void CloudExternalDataPolicyObserver::OnExternalDataFetched( |
308 const std::string& user_id, | 308 const std::string& user_id, |
309 scoped_ptr<std::string> data) { | 309 scoped_ptr<std::string> data) { |
310 FetchWeakPtrMap::iterator it = fetch_weak_ptrs_.find(user_id); | 310 FetchWeakPtrMap::iterator it = fetch_weak_ptrs_.find(user_id); |
311 DCHECK(it != fetch_weak_ptrs_.end()); | 311 DCHECK(it != fetch_weak_ptrs_.end()); |
312 fetch_weak_ptrs_.erase(it); | 312 fetch_weak_ptrs_.erase(it); |
313 delegate_->OnExternalDataFetched(policy_, user_id, data.Pass()); | 313 delegate_->OnExternalDataFetched(policy_, user_id, data.Pass()); |
314 } | 314 } |
315 | 315 |
316 } // namespace policy | 316 } // namespace policy |
OLD | NEW |