| 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" |
| 11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/files/file_enumerator.h" | 13 #include "base/files/file_enumerator.h" |
| 14 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/memory/ptr_util.h" |
| 16 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
| 17 #include "base/path_service.h" | 18 #include "base/path_service.h" |
| 18 #include "base/sequenced_task_runner.h" | 19 #include "base/sequenced_task_runner.h" |
| 19 #include "base/stl_util.h" | 20 #include "base/stl_util.h" |
| 20 #include "base/strings/string_number_conversions.h" | 21 #include "base/strings/string_number_conversions.h" |
| 21 #include "base/threading/thread_task_runner_handle.h" | 22 #include "base/threading/thread_task_runner_handle.h" |
| 22 #include "chrome/browser/browser_process.h" | 23 #include "chrome/browser/browser_process.h" |
| 23 #include "chrome/browser/chromeos/policy/affiliated_cloud_policy_invalidator.h" | 24 #include "chrome/browser/chromeos/policy/affiliated_cloud_policy_invalidator.h" |
| 24 #include "chrome/browser/chromeos/policy/device_local_account.h" | 25 #include "chrome/browser/chromeos/policy/device_local_account.h" |
| 25 #include "chrome/browser/chromeos/policy/device_local_account_external_data_serv
ice.h" | 26 #include "chrome/browser/chromeos/policy/device_local_account_external_data_serv
ice.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 DeviceManagementService* device_management_service, | 59 DeviceManagementService* device_management_service, |
| 59 scoped_refptr<net::URLRequestContextGetter> system_request_context) { | 60 scoped_refptr<net::URLRequestContextGetter> system_request_context) { |
| 60 const em::PolicyData* policy_data = device_settings_service->policy_data(); | 61 const em::PolicyData* policy_data = device_settings_service->policy_data(); |
| 61 if (!policy_data || | 62 if (!policy_data || |
| 62 !policy_data->has_request_token() || | 63 !policy_data->has_request_token() || |
| 63 !policy_data->has_device_id() || | 64 !policy_data->has_device_id() || |
| 64 !device_management_service) { | 65 !device_management_service) { |
| 65 return std::unique_ptr<CloudPolicyClient>(); | 66 return std::unique_ptr<CloudPolicyClient>(); |
| 66 } | 67 } |
| 67 | 68 |
| 68 std::unique_ptr<CloudPolicyClient> client(new CloudPolicyClient( | 69 std::unique_ptr<CloudPolicyClient> client = |
| 69 std::string(), std::string(), kPolicyVerificationKeyHash, | 70 base::MakeUnique<CloudPolicyClient>( |
| 70 device_management_service, system_request_context, | 71 std::string() /* machine_id */, std::string() /* machine_model */, |
| 71 nullptr /* signing_service */)); | 72 device_management_service, system_request_context, |
| 73 nullptr /* signing_service */); |
| 72 client->SetupRegistration(policy_data->request_token(), | 74 client->SetupRegistration(policy_data->request_token(), |
| 73 policy_data->device_id()); | 75 policy_data->device_id()); |
| 74 return client; | 76 return client; |
| 75 } | 77 } |
| 76 | 78 |
| 77 // Get the subdirectory of the force-installed extension cache and the component | 79 // Get the subdirectory of the force-installed extension cache and the component |
| 78 // policy cache used for |account_id|. | 80 // policy cache used for |account_id|. |
| 79 std::string GetCacheSubdirectoryForAccountID(const std::string& account_id) { | 81 std::string GetCacheSubdirectoryForAccountID(const std::string& account_id) { |
| 80 return base::HexEncode(account_id.c_str(), account_id.size()); | 82 return base::HexEncode(account_id.c_str(), account_id.size()); |
| 81 } | 83 } |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 return nullptr; | 570 return nullptr; |
| 569 } | 571 } |
| 570 | 572 |
| 571 void DeviceLocalAccountPolicyService::NotifyPolicyUpdated( | 573 void DeviceLocalAccountPolicyService::NotifyPolicyUpdated( |
| 572 const std::string& user_id) { | 574 const std::string& user_id) { |
| 573 for (auto& observer : observers_) | 575 for (auto& observer : observers_) |
| 574 observer.OnPolicyUpdated(user_id); | 576 observer.OnPolicyUpdated(user_id); |
| 575 } | 577 } |
| 576 | 578 |
| 577 } // namespace policy | 579 } // namespace policy |
| OLD | NEW |