| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 11 #include "base/metrics/sparse_histogram.h" | 11 #include "base/metrics/sparse_histogram.h" |
| 12 #include "base/sequenced_task_runner.h" | 12 #include "base/sequenced_task_runner.h" |
| 13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/chromeos/policy/policy_oauth2_token_fetcher.h" | 14 #include "chrome/browser/chromeos/policy/policy_oauth2_token_fetcher.h" |
| 15 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom
eos.h" | 15 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom
eos.h" |
| 16 #include "chrome/browser/chromeos/policy/wildcard_login_checker.h" | 16 #include "chrome/browser/chromeos/policy/wildcard_login_checker.h" |
| 17 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 17 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 18 #include "chrome/browser/lifetime/application_lifetime.h" | 18 #include "chrome/browser/lifetime/application_lifetime.h" |
| 19 #include "chrome/common/chrome_content_client.h" |
| 19 #include "components/policy/core/common/cloud/cloud_external_data_manager.h" | 20 #include "components/policy/core/common/cloud/cloud_external_data_manager.h" |
| 20 #include "components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h" | 21 #include "components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h" |
| 21 #include "components/policy/core/common/cloud/device_management_service.h" | 22 #include "components/policy/core/common/cloud/device_management_service.h" |
| 22 #include "components/policy/core/common/cloud/system_policy_request_context.h" | 23 #include "components/policy/core/common/cloud/system_policy_request_context.h" |
| 23 #include "components/policy/core/common/policy_pref_names.h" | 24 #include "components/policy/core/common/policy_pref_names.h" |
| 24 #include "content/public/common/content_client.h" | |
| 25 #include "net/url_request/url_request_context_getter.h" | 25 #include "net/url_request/url_request_context_getter.h" |
| 26 #include "url/gurl.h" | 26 #include "url/gurl.h" |
| 27 | 27 |
| 28 namespace em = enterprise_management; | 28 namespace em = enterprise_management; |
| 29 | 29 |
| 30 namespace policy { | 30 namespace policy { |
| 31 | 31 |
| 32 namespace { | 32 namespace { |
| 33 | 33 |
| 34 // UMA histogram names. | 34 // UMA histogram names. |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 local_state_ = local_state; | 108 local_state_ = local_state; |
| 109 scoped_refptr<net::URLRequestContextGetter> request_context; | 109 scoped_refptr<net::URLRequestContextGetter> request_context; |
| 110 if (system_request_context) { | 110 if (system_request_context) { |
| 111 // |system_request_context| can be null for tests. | 111 // |system_request_context| can be null for tests. |
| 112 // Use the system request context here instead of a context derived | 112 // Use the system request context here instead of a context derived |
| 113 // from the Profile because Connect() is called before the profile is | 113 // from the Profile because Connect() is called before the profile is |
| 114 // fully initialized (required so we can perform the initial policy load). | 114 // fully initialized (required so we can perform the initial policy load). |
| 115 // TODO(atwilson): Change this to use a UserPolicyRequestContext once | 115 // TODO(atwilson): Change this to use a UserPolicyRequestContext once |
| 116 // Connect() is called after profile initialization. http://crbug.com/323591 | 116 // Connect() is called after profile initialization. http://crbug.com/323591 |
| 117 request_context = new SystemPolicyRequestContext( | 117 request_context = new SystemPolicyRequestContext( |
| 118 system_request_context, | 118 system_request_context, GetUserAgent()); |
| 119 content::GetUserAgent(GURL( | |
| 120 device_management_service->GetServerUrl()))); | |
| 121 } | 119 } |
| 122 scoped_ptr<CloudPolicyClient> cloud_policy_client( | 120 scoped_ptr<CloudPolicyClient> cloud_policy_client( |
| 123 new CloudPolicyClient(std::string(), std::string(), | 121 new CloudPolicyClient(std::string(), std::string(), |
| 124 kPolicyVerificationKeyHash, user_affiliation, | 122 kPolicyVerificationKeyHash, user_affiliation, |
| 125 NULL, device_management_service, | 123 NULL, device_management_service, |
| 126 request_context)); | 124 request_context)); |
| 127 core()->Connect(cloud_policy_client.Pass()); | 125 core()->Connect(cloud_policy_client.Pass()); |
| 128 client()->AddObserver(this); | 126 client()->AddObserver(this); |
| 129 | 127 |
| 130 external_data_manager_->Connect(request_context); | 128 external_data_manager_->Connect(request_context); |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 // OnComponentCloudPolicyUpdated() once it's ready. | 370 // OnComponentCloudPolicyUpdated() once it's ready. |
| 373 return; | 371 return; |
| 374 } | 372 } |
| 375 | 373 |
| 376 core()->StartRefreshScheduler(); | 374 core()->StartRefreshScheduler(); |
| 377 core()->TrackRefreshDelayPref(local_state_, | 375 core()->TrackRefreshDelayPref(local_state_, |
| 378 policy_prefs::kUserPolicyRefreshRate); | 376 policy_prefs::kUserPolicyRefreshRate); |
| 379 } | 377 } |
| 380 | 378 |
| 381 } // namespace policy | 379 } // namespace policy |
| OLD | NEW |