| 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/user_cloud_policy_manager_chromeos.h" | 5 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <utility> | 8 #include <utility> |
| 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/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/memory/ptr_util.h" |
| 14 #include "base/metrics/histogram_macros.h" | 15 #include "base/metrics/histogram_macros.h" |
| 15 #include "base/metrics/sparse_histogram.h" | 16 #include "base/metrics/sparse_histogram.h" |
| 16 #include "base/sequenced_task_runner.h" | 17 #include "base/sequenced_task_runner.h" |
| 17 #include "base/values.h" | 18 #include "base/values.h" |
| 18 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
| 19 #include "chrome/browser/chromeos/login/helper.h" | 20 #include "chrome/browser/chromeos/login/helper.h" |
| 20 #include "chrome/browser/chromeos/login/session/user_session_manager.h" | 21 #include "chrome/browser/chromeos/login/session/user_session_manager.h" |
| 21 #include "chrome/browser/chromeos/login/users/affiliation.h" | 22 #include "chrome/browser/chromeos/login/users/affiliation.h" |
| 22 #include "chrome/browser/chromeos/login/users/chrome_user_manager_impl.h" | 23 #include "chrome/browser/chromeos/login/users/chrome_user_manager_impl.h" |
| 23 #include "chrome/browser/chromeos/policy/policy_oauth2_token_fetcher.h" | 24 #include "chrome/browser/chromeos/policy/policy_oauth2_token_fetcher.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 PrefService* local_state, | 125 PrefService* local_state, |
| 125 DeviceManagementService* device_management_service, | 126 DeviceManagementService* device_management_service, |
| 126 scoped_refptr<net::URLRequestContextGetter> system_request_context) { | 127 scoped_refptr<net::URLRequestContextGetter> system_request_context) { |
| 127 DCHECK(device_management_service); | 128 DCHECK(device_management_service); |
| 128 DCHECK(local_state); | 129 DCHECK(local_state); |
| 129 local_state_ = local_state; | 130 local_state_ = local_state; |
| 130 // Note: |system_request_context| can be null for tests. | 131 // Note: |system_request_context| can be null for tests. |
| 131 // Use the system request context here instead of a context derived | 132 // Use the system request context here instead of a context derived |
| 132 // from the Profile because Connect() is called before the profile is | 133 // from the Profile because Connect() is called before the profile is |
| 133 // fully initialized (required so we can perform the initial policy load). | 134 // fully initialized (required so we can perform the initial policy load). |
| 134 std::unique_ptr<CloudPolicyClient> cloud_policy_client(new CloudPolicyClient( | 135 std::unique_ptr<CloudPolicyClient> cloud_policy_client = |
| 135 std::string(), std::string(), kPolicyVerificationKeyHash, | 136 base::MakeUnique<CloudPolicyClient>( |
| 136 device_management_service, system_request_context, | 137 std::string() /* machine_id */, std::string() /* machine_model */, |
| 137 nullptr /* signing_service */)); | 138 device_management_service, system_request_context, |
| 139 nullptr /* signing_service */); |
| 138 CreateComponentCloudPolicyService( | 140 CreateComponentCloudPolicyService( |
| 139 dm_protocol::kChromeExtensionPolicyType, component_policy_cache_path_, | 141 dm_protocol::kChromeExtensionPolicyType, component_policy_cache_path_, |
| 140 system_request_context, cloud_policy_client.get(), schema_registry()); | 142 system_request_context, cloud_policy_client.get(), schema_registry()); |
| 141 core()->Connect(std::move(cloud_policy_client)); | 143 core()->Connect(std::move(cloud_policy_client)); |
| 142 client()->AddObserver(this); | 144 client()->AddObserver(this); |
| 143 | 145 |
| 144 external_data_manager_->Connect(system_request_context); | 146 external_data_manager_->Connect(system_request_context); |
| 145 | 147 |
| 146 // Determine the next step after the CloudPolicyService initializes. | 148 // Determine the next step after the CloudPolicyService initializes. |
| 147 if (service()->IsInitializationComplete()) { | 149 if (service()->IsInitializationComplete()) { |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 // OnComponentCloudPolicyUpdated() once it's ready. | 450 // OnComponentCloudPolicyUpdated() once it's ready. |
| 449 return; | 451 return; |
| 450 } | 452 } |
| 451 | 453 |
| 452 core()->StartRefreshScheduler(); | 454 core()->StartRefreshScheduler(); |
| 453 core()->TrackRefreshDelayPref(local_state_, | 455 core()->TrackRefreshDelayPref(local_state_, |
| 454 policy_prefs::kUserPolicyRefreshRate); | 456 policy_prefs::kUserPolicyRefreshRate); |
| 455 } | 457 } |
| 456 | 458 |
| 457 } // namespace policy | 459 } // namespace policy |
| OLD | NEW |