| 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/chromeos/policy/device_local_account_policy_service.h" | 5 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 #include "policy/proto/device_management_backend.pb.h" | 44 #include "policy/proto/device_management_backend.pb.h" |
| 45 #include "url/gurl.h" | 45 #include "url/gurl.h" |
| 46 | 46 |
| 47 namespace em = enterprise_management; | 47 namespace em = enterprise_management; |
| 48 | 48 |
| 49 namespace policy { | 49 namespace policy { |
| 50 | 50 |
| 51 namespace { | 51 namespace { |
| 52 | 52 |
| 53 // Creates and initializes a cloud policy client. Returns nullptr if the device | 53 // Creates and initializes a cloud policy client. Returns nullptr if the device |
| 54 // is not enterprise-enrolled. | 54 // doesn't have credentials in device settings (i.e. is not |
| 55 // enterprise-enrolled). |
| 55 std::unique_ptr<CloudPolicyClient> CreateClient( | 56 std::unique_ptr<CloudPolicyClient> CreateClient( |
| 56 chromeos::DeviceSettingsService* device_settings_service, | 57 chromeos::DeviceSettingsService* device_settings_service, |
| 57 DeviceManagementService* device_management_service, | 58 DeviceManagementService* device_management_service, |
| 58 scoped_refptr<net::URLRequestContextGetter> system_request_context) { | 59 scoped_refptr<net::URLRequestContextGetter> system_request_context) { |
| 59 const em::PolicyData* policy_data = device_settings_service->policy_data(); | 60 const em::PolicyData* policy_data = device_settings_service->policy_data(); |
| 60 if (!policy_data || | 61 if (!policy_data || |
| 61 GetManagementMode(*policy_data) != MANAGEMENT_MODE_ENTERPRISE_MANAGED || | 62 !policy_data->has_request_token() || |
| 63 !policy_data->has_device_id() || |
| 62 !device_management_service) { | 64 !device_management_service) { |
| 63 return std::unique_ptr<CloudPolicyClient>(); | 65 return std::unique_ptr<CloudPolicyClient>(); |
| 64 } | 66 } |
| 65 | 67 |
| 66 std::unique_ptr<CloudPolicyClient> client(new CloudPolicyClient( | 68 std::unique_ptr<CloudPolicyClient> client(new CloudPolicyClient( |
| 67 std::string(), std::string(), kPolicyVerificationKeyHash, | 69 std::string(), std::string(), kPolicyVerificationKeyHash, |
| 68 device_management_service, system_request_context)); | 70 device_management_service, system_request_context)); |
| 69 client->SetupRegistration(policy_data->request_token(), | 71 client->SetupRegistration(policy_data->request_token(), |
| 70 policy_data->device_id()); | 72 policy_data->device_id()); |
| 71 return client; | 73 return client; |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 } | 559 } |
| 558 return nullptr; | 560 return nullptr; |
| 559 } | 561 } |
| 560 | 562 |
| 561 void DeviceLocalAccountPolicyService::NotifyPolicyUpdated( | 563 void DeviceLocalAccountPolicyService::NotifyPolicyUpdated( |
| 562 const std::string& user_id) { | 564 const std::string& user_id) { |
| 563 FOR_EACH_OBSERVER(Observer, observers_, OnPolicyUpdated(user_id)); | 565 FOR_EACH_OBSERVER(Observer, observers_, OnPolicyUpdated(user_id)); |
| 564 } | 566 } |
| 565 | 567 |
| 566 } // namespace policy | 568 } // namespace policy |
| OLD | NEW |