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/device_cloud_policy_manager_chromeos.h" | 5 #include "chrome/browser/policy/device_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/chromeos/system/statistics_provider.h" | 9 #include "chrome/browser/chromeos/system/statistics_provider.h" |
10 #include "chrome/browser/policy/cloud_policy_client.h" | 10 #include "chrome/browser/policy/cloud_policy_client.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 "serial_number", // VPD v2+ devices | 42 "serial_number", // VPD v2+ devices |
43 "Product_SN", // Mario | 43 "Product_SN", // Mario |
44 "sn", // old ZGB devices (more recent ones use serial_number) | 44 "sn", // old ZGB devices (more recent ones use serial_number) |
45 }; | 45 }; |
46 | 46 |
47 } // namespace | 47 } // namespace |
48 | 48 |
49 DeviceCloudPolicyManagerChromeOS::DeviceCloudPolicyManagerChromeOS( | 49 DeviceCloudPolicyManagerChromeOS::DeviceCloudPolicyManagerChromeOS( |
50 scoped_ptr<DeviceCloudPolicyStoreChromeOS> store, | 50 scoped_ptr<DeviceCloudPolicyStoreChromeOS> store, |
51 EnterpriseInstallAttributes* install_attributes) | 51 EnterpriseInstallAttributes* install_attributes) |
52 : CloudPolicyManager(make_scoped_ptr<CloudPolicyStore>(store.get())), | 52 : CloudPolicyManager(store.get()), |
53 device_store_(store.release()), // Hack: retain |store| till here. | 53 device_store_(store.Pass()), |
54 install_attributes_(install_attributes), | 54 install_attributes_(install_attributes), |
55 device_management_service_(NULL), | 55 device_management_service_(NULL), |
56 local_state_(NULL) {} | 56 local_state_(NULL) {} |
57 | 57 |
58 DeviceCloudPolicyManagerChromeOS::~DeviceCloudPolicyManagerChromeOS() {} | 58 DeviceCloudPolicyManagerChromeOS::~DeviceCloudPolicyManagerChromeOS() {} |
59 | 59 |
60 void DeviceCloudPolicyManagerChromeOS::Connect( | 60 void DeviceCloudPolicyManagerChromeOS::Connect( |
61 PrefService* local_state, | 61 PrefService* local_state, |
62 DeviceManagementService* device_management_service) { | 62 DeviceManagementService* device_management_service) { |
63 CHECK(!device_management_service_); | 63 CHECK(!device_management_service_); |
64 CHECK(device_management_service); | 64 CHECK(device_management_service); |
65 CHECK(local_state); | 65 CHECK(local_state); |
66 | 66 |
67 local_state_ = local_state; | 67 local_state_ = local_state; |
68 device_management_service_ = device_management_service; | 68 device_management_service_ = device_management_service; |
69 | 69 |
70 StartIfManaged(); | 70 StartIfManaged(); |
71 } | 71 } |
72 | 72 |
73 void DeviceCloudPolicyManagerChromeOS::StartEnrollment( | 73 void DeviceCloudPolicyManagerChromeOS::StartEnrollment( |
74 const std::string& auth_token, | 74 const std::string& auth_token, |
75 const AllowedDeviceModes& allowed_device_modes, | 75 const AllowedDeviceModes& allowed_device_modes, |
76 const EnrollmentCallback& callback) { | 76 const EnrollmentCallback& callback) { |
77 CHECK(device_management_service_); | 77 CHECK(device_management_service_); |
78 ShutdownService(); | 78 ShutdownService(); |
79 | 79 |
80 enrollment_handler_.reset( | 80 enrollment_handler_.reset( |
81 new EnrollmentHandlerChromeOS( | 81 new EnrollmentHandlerChromeOS( |
82 device_store_, install_attributes_, CreateClient(), auth_token, | 82 device_store_.get(), install_attributes_, CreateClient(), auth_token, |
83 allowed_device_modes, | 83 allowed_device_modes, |
84 base::Bind(&DeviceCloudPolicyManagerChromeOS::EnrollmentCompleted, | 84 base::Bind(&DeviceCloudPolicyManagerChromeOS::EnrollmentCompleted, |
85 base::Unretained(this), callback))); | 85 base::Unretained(this), callback))); |
86 enrollment_handler_->StartEnrollment(); | 86 enrollment_handler_->StartEnrollment(); |
87 } | 87 } |
88 | 88 |
89 void DeviceCloudPolicyManagerChromeOS::CancelEnrollment() { | 89 void DeviceCloudPolicyManagerChromeOS::CancelEnrollment() { |
90 if (enrollment_handler_.get()) { | 90 if (enrollment_handler_.get()) { |
91 enrollment_handler_.reset(); | 91 enrollment_handler_.reset(); |
92 StartIfManaged(); | 92 StartIfManaged(); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 local_state_ && | 157 local_state_ && |
158 cloud_policy_store()->is_initialized() && | 158 cloud_policy_store()->is_initialized() && |
159 cloud_policy_store()->is_managed() && | 159 cloud_policy_store()->is_managed() && |
160 !cloud_policy_service()) { | 160 !cloud_policy_service()) { |
161 InitializeService(CreateClient()); | 161 InitializeService(CreateClient()); |
162 StartRefreshScheduler(local_state_, prefs::kDevicePolicyRefreshRate); | 162 StartRefreshScheduler(local_state_, prefs::kDevicePolicyRefreshRate); |
163 } | 163 } |
164 } | 164 } |
165 | 165 |
166 } // namespace policy | 166 } // namespace policy |
OLD | NEW |