| OLD | NEW |
| 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 #include "chrome/browser/policy/user_cloud_policy_manager_chromeos.h" | 5 #include "chrome/browser/policy/user_cloud_policy_manager_chromeos.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "chrome/browser/policy/cloud_policy_service.h" | 9 #include "chrome/browser/policy/cloud_policy_service.h" |
| 10 #include "chrome/browser/policy/policy_types.h" | |
| 11 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
| 12 | 11 |
| 13 namespace policy { | 12 namespace policy { |
| 14 | 13 |
| 15 UserCloudPolicyManagerChromeOS::UserCloudPolicyManagerChromeOS( | 14 UserCloudPolicyManagerChromeOS::UserCloudPolicyManagerChromeOS( |
| 16 scoped_ptr<CloudPolicyStore> store, | 15 scoped_ptr<CloudPolicyStore> store, |
| 17 bool wait_for_policy_fetch) | 16 bool wait_for_policy_fetch) |
| 18 : CloudPolicyManager(store.get()), | 17 : CloudPolicyManager(store.get()), |
| 19 store_(store.Pass()), | 18 store_(store.Pass()), |
| 20 wait_for_policy_fetch_(wait_for_policy_fetch) {} | 19 wait_for_policy_fetch_(wait_for_policy_fetch) {} |
| 21 | 20 |
| 22 UserCloudPolicyManagerChromeOS::~UserCloudPolicyManagerChromeOS() {} | 21 UserCloudPolicyManagerChromeOS::~UserCloudPolicyManagerChromeOS() {} |
| 23 | 22 |
| 24 void UserCloudPolicyManagerChromeOS::Initialize( | 23 void UserCloudPolicyManagerChromeOS::Connect( |
| 25 PrefService* local_state, | 24 PrefService* local_state, |
| 26 DeviceManagementService* device_management_service, | 25 DeviceManagementService* device_management_service, |
| 27 UserAffiliation user_affiliation) { | 26 UserAffiliation user_affiliation) { |
| 28 DCHECK(device_management_service); | 27 DCHECK(device_management_service); |
| 29 DCHECK(local_state); | 28 DCHECK(local_state); |
| 30 local_state_ = local_state; | 29 local_state_ = local_state; |
| 31 scoped_ptr<CloudPolicyClient> client( | 30 scoped_ptr<CloudPolicyClient> client( |
| 32 new CloudPolicyClient(std::string(), std::string(), user_affiliation, | 31 new CloudPolicyClient(std::string(), std::string(), user_affiliation, |
| 33 POLICY_SCOPE_USER, NULL, | 32 CloudPolicyClient::POLICY_TYPE_USER, NULL, |
| 34 device_management_service)); | 33 device_management_service)); |
| 35 InitializeService(client.Pass()); | 34 InitializeService(client.Pass()); |
| 36 cloud_policy_client()->AddObserver(this); | 35 cloud_policy_client()->AddObserver(this); |
| 37 | 36 |
| 38 if (wait_for_policy_fetch_) { | 37 if (wait_for_policy_fetch_) { |
| 39 // If we are supposed to wait for a policy fetch, we trigger an explicit | 38 // If we are supposed to wait for a policy fetch, we trigger an explicit |
| 40 // policy refresh at startup that allows us to unblock initialization once | 39 // policy refresh at startup that allows us to unblock initialization once |
| 41 // done. The refresh scheduler only gets started once that refresh | 40 // done. The refresh scheduler only gets started once that refresh |
| 42 // completes. Note that we might have to wait for registration to happen, | 41 // completes. Note that we might have to wait for registration to happen, |
| 43 // see OnRegistrationStateChanged() below. | 42 // see OnRegistrationStateChanged() below. |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 void UserCloudPolicyManagerChromeOS::OnClientError(CloudPolicyClient* client) { | 112 void UserCloudPolicyManagerChromeOS::OnClientError(CloudPolicyClient* client) { |
| 114 DCHECK_EQ(cloud_policy_client(), client); | 113 DCHECK_EQ(cloud_policy_client(), client); |
| 115 CancelWaitForPolicyFetch(); | 114 CancelWaitForPolicyFetch(); |
| 116 } | 115 } |
| 117 | 116 |
| 118 void UserCloudPolicyManagerChromeOS::OnInitialPolicyFetchComplete() { | 117 void UserCloudPolicyManagerChromeOS::OnInitialPolicyFetchComplete() { |
| 119 CancelWaitForPolicyFetch(); | 118 CancelWaitForPolicyFetch(); |
| 120 } | 119 } |
| 121 | 120 |
| 122 } // namespace policy | 121 } // namespace policy |
| OLD | NEW |