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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
11 #include "base/files/file_enumerator.h" | 11 #include "base/files/file_enumerator.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
15 #include "base/message_loop/message_loop_proxy.h" | 15 #include "base/message_loop/message_loop_proxy.h" |
16 #include "base/path_service.h" | 16 #include "base/path_service.h" |
17 #include "base/sequenced_task_runner.h" | 17 #include "base/sequenced_task_runner.h" |
18 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
19 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
20 #include "chrome/browser/chromeos/policy/device_local_account.h" | 20 #include "chrome/browser/chromeos/policy/device_local_account.h" |
21 #include "chrome/browser/chromeos/policy/device_local_account_external_data_serv
ice.h" | 21 #include "chrome/browser/chromeos/policy/device_local_account_external_data_serv
ice.h" |
22 #include "chrome/browser/chromeos/policy/device_local_account_policy_store.h" | 22 #include "chrome/browser/chromeos/policy/device_local_account_policy_store.h" |
23 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 23 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
| 24 #include "chrome/common/chrome_content_client.h" |
24 #include "chromeos/chromeos_paths.h" | 25 #include "chromeos/chromeos_paths.h" |
25 #include "chromeos/dbus/session_manager_client.h" | 26 #include "chromeos/dbus/session_manager_client.h" |
26 #include "chromeos/settings/cros_settings_names.h" | 27 #include "chromeos/settings/cros_settings_names.h" |
27 #include "chromeos/settings/cros_settings_provider.h" | 28 #include "chromeos/settings/cros_settings_provider.h" |
28 #include "components/policy/core/common/cloud/cloud_policy_client.h" | 29 #include "components/policy/core/common/cloud/cloud_policy_client.h" |
29 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 30 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
30 #include "components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h" | 31 #include "components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h" |
31 #include "components/policy/core/common/cloud/device_management_service.h" | 32 #include "components/policy/core/common/cloud/device_management_service.h" |
32 #include "components/policy/core/common/cloud/system_policy_request_context.h" | 33 #include "components/policy/core/common/cloud/system_policy_request_context.h" |
33 #include "content/public/common/content_client.h" | |
34 #include "net/url_request/url_request_context_getter.h" | 34 #include "net/url_request/url_request_context_getter.h" |
35 #include "policy/policy_constants.h" | 35 #include "policy/policy_constants.h" |
36 #include "policy/proto/device_management_backend.pb.h" | 36 #include "policy/proto/device_management_backend.pb.h" |
37 #include "url/gurl.h" | 37 #include "url/gurl.h" |
38 | 38 |
39 namespace em = enterprise_management; | 39 namespace em = enterprise_management; |
40 | 40 |
41 namespace policy { | 41 namespace policy { |
42 | 42 |
43 namespace { | 43 namespace { |
44 | 44 |
45 // Creates and initializes a cloud policy client. Returns NULL if the device | 45 // Creates and initializes a cloud policy client. Returns NULL if the device |
46 // doesn't have credentials in device settings (i.e. is not | 46 // doesn't have credentials in device settings (i.e. is not |
47 // enterprise-enrolled). | 47 // enterprise-enrolled). |
48 scoped_ptr<CloudPolicyClient> CreateClient( | 48 scoped_ptr<CloudPolicyClient> CreateClient( |
49 chromeos::DeviceSettingsService* device_settings_service, | 49 chromeos::DeviceSettingsService* device_settings_service, |
50 DeviceManagementService* device_management_service, | 50 DeviceManagementService* device_management_service, |
51 scoped_refptr<net::URLRequestContextGetter> system_request_context) { | 51 scoped_refptr<net::URLRequestContextGetter> system_request_context) { |
52 const em::PolicyData* policy_data = device_settings_service->policy_data(); | 52 const em::PolicyData* policy_data = device_settings_service->policy_data(); |
53 if (!policy_data || | 53 if (!policy_data || |
54 !policy_data->has_request_token() || | 54 !policy_data->has_request_token() || |
55 !policy_data->has_device_id() || | 55 !policy_data->has_device_id() || |
56 !device_management_service) { | 56 !device_management_service) { |
57 return scoped_ptr<CloudPolicyClient>(); | 57 return scoped_ptr<CloudPolicyClient>(); |
58 } | 58 } |
59 | 59 |
60 scoped_refptr<net::URLRequestContextGetter> request_context = | 60 scoped_refptr<net::URLRequestContextGetter> request_context = |
61 new SystemPolicyRequestContext( | 61 new SystemPolicyRequestContext( |
62 system_request_context, | 62 system_request_context, GetUserAgent()); |
63 content::GetUserAgent(GURL( | |
64 device_management_service->GetServerUrl()))); | |
65 | 63 |
66 scoped_ptr<CloudPolicyClient> client( | 64 scoped_ptr<CloudPolicyClient> client( |
67 new CloudPolicyClient(std::string(), std::string(), | 65 new CloudPolicyClient(std::string(), std::string(), |
68 kPolicyVerificationKeyHash, | 66 kPolicyVerificationKeyHash, |
69 USER_AFFILIATION_MANAGED, | 67 USER_AFFILIATION_MANAGED, |
70 NULL, device_management_service, request_context)); | 68 NULL, device_management_service, request_context)); |
71 client->SetupRegistration(policy_data->request_token(), | 69 client->SetupRegistration(policy_data->request_token(), |
72 policy_data->device_id()); | 70 policy_data->device_id()); |
73 return client.Pass(); | 71 return client.Pass(); |
74 } | 72 } |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 CloudPolicyStore* store) { | 502 CloudPolicyStore* store) { |
505 for (PolicyBrokerMap::iterator it(policy_brokers_.begin()); | 503 for (PolicyBrokerMap::iterator it(policy_brokers_.begin()); |
506 it != policy_brokers_.end(); ++it) { | 504 it != policy_brokers_.end(); ++it) { |
507 if (it->second->core()->store() == store) | 505 if (it->second->core()->store() == store) |
508 return it->second; | 506 return it->second; |
509 } | 507 } |
510 return NULL; | 508 return NULL; |
511 } | 509 } |
512 | 510 |
513 } // namespace policy | 511 } // namespace policy |
OLD | NEW |