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/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/files/file_enumerator.h" | 12 #include "base/files/file_enumerator.h" |
13 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
16 #include "base/message_loop/message_loop_proxy.h" | 16 #include "base/message_loop/message_loop_proxy.h" |
17 #include "base/path_service.h" | 17 #include "base/path_service.h" |
18 #include "base/sequenced_task_runner.h" | 18 #include "base/sequenced_task_runner.h" |
19 #include "base/stl_util.h" | 19 #include "base/stl_util.h" |
20 #include "base/strings/string_number_conversions.h" | 20 #include "base/strings/string_number_conversions.h" |
21 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
22 #include "chrome/browser/chromeos/policy/device_local_account.h" | 22 #include "chrome/browser/chromeos/policy/device_local_account.h" |
23 #include "chrome/browser/chromeos/policy/device_local_account_external_data_serv
ice.h" | 23 #include "chrome/browser/chromeos/policy/device_local_account_external_data_serv
ice.h" |
24 #include "chrome/browser/chromeos/policy/device_local_account_policy_store.h" | 24 #include "chrome/browser/chromeos/policy/device_local_account_policy_store.h" |
| 25 #include "chrome/browser/chromeos/policy/policy_util.h" |
25 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 26 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
26 #include "chrome/common/chrome_content_client.h" | 27 #include "chrome/common/chrome_content_client.h" |
27 #include "chromeos/chromeos_paths.h" | 28 #include "chromeos/chromeos_paths.h" |
28 #include "chromeos/dbus/session_manager_client.h" | 29 #include "chromeos/dbus/session_manager_client.h" |
29 #include "chromeos/settings/cros_settings_names.h" | 30 #include "chromeos/settings/cros_settings_names.h" |
30 #include "chromeos/settings/cros_settings_provider.h" | 31 #include "chromeos/settings/cros_settings_provider.h" |
31 #include "components/policy/core/browser/browser_policy_connector.h" | 32 #include "components/policy/core/browser/browser_policy_connector.h" |
32 #include "components/policy/core/common/cloud/cloud_policy_client.h" | 33 #include "components/policy/core/common/cloud/cloud_policy_client.h" |
33 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 34 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
34 #include "components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h" | 35 #include "components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h" |
35 #include "components/policy/core/common/cloud/device_management_service.h" | 36 #include "components/policy/core/common/cloud/device_management_service.h" |
36 #include "components/policy/core/common/cloud/resource_cache.h" | 37 #include "components/policy/core/common/cloud/resource_cache.h" |
37 #include "components/policy/core/common/cloud/system_policy_request_context.h" | 38 #include "components/policy/core/common/cloud/system_policy_request_context.h" |
38 #include "components/policy/core/common/policy_namespace.h" | 39 #include "components/policy/core/common/policy_namespace.h" |
39 #include "components/policy/core/common/policy_switches.h" | 40 #include "components/policy/core/common/policy_switches.h" |
40 #include "content/public/browser/browser_thread.h" | 41 #include "content/public/browser/browser_thread.h" |
41 #include "net/url_request/url_request_context_getter.h" | 42 #include "net/url_request/url_request_context_getter.h" |
42 #include "policy/policy_constants.h" | 43 #include "policy/policy_constants.h" |
43 #include "policy/proto/device_management_backend.pb.h" | 44 #include "policy/proto/device_management_backend.pb.h" |
44 #include "url/gurl.h" | 45 #include "url/gurl.h" |
45 | 46 |
46 namespace em = enterprise_management; | 47 namespace em = enterprise_management; |
47 | 48 |
48 namespace policy { | 49 namespace policy { |
49 | 50 |
50 namespace { | 51 namespace { |
51 | 52 |
52 // Creates and initializes a cloud policy client. Returns NULL if the device | 53 // Creates and initializes a cloud policy client. Returns NULL if the device |
53 // doesn't have credentials in device settings (i.e. is not | 54 // is not enterprise-enrolled. |
54 // enterprise-enrolled). | |
55 scoped_ptr<CloudPolicyClient> CreateClient( | 55 scoped_ptr<CloudPolicyClient> CreateClient( |
56 chromeos::DeviceSettingsService* device_settings_service, | 56 chromeos::DeviceSettingsService* device_settings_service, |
57 DeviceManagementService* device_management_service, | 57 DeviceManagementService* device_management_service, |
58 scoped_refptr<net::URLRequestContextGetter> system_request_context) { | 58 scoped_refptr<net::URLRequestContextGetter> system_request_context) { |
59 const em::PolicyData* policy_data = device_settings_service->policy_data(); | 59 const em::PolicyData* policy_data = device_settings_service->policy_data(); |
60 if (!policy_data || | 60 if (!policy_data || |
61 !policy_data->has_request_token() || | 61 !PolicyUtil::IsEnterpriseManaged(*policy_data) || |
62 !policy_data->has_device_id() || | |
63 !device_management_service) { | 62 !device_management_service) { |
64 return scoped_ptr<CloudPolicyClient>(); | 63 return scoped_ptr<CloudPolicyClient>(); |
65 } | 64 } |
66 | 65 |
67 scoped_refptr<net::URLRequestContextGetter> request_context = | 66 scoped_refptr<net::URLRequestContextGetter> request_context = |
68 new SystemPolicyRequestContext( | 67 new SystemPolicyRequestContext( |
69 system_request_context, GetUserAgent()); | 68 system_request_context, GetUserAgent()); |
70 | 69 |
71 scoped_ptr<CloudPolicyClient> client( | 70 scoped_ptr<CloudPolicyClient> client( |
72 new CloudPolicyClient(std::string(), std::string(), | 71 new CloudPolicyClient(std::string(), std::string(), |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 } | 559 } |
561 return NULL; | 560 return NULL; |
562 } | 561 } |
563 | 562 |
564 void DeviceLocalAccountPolicyService::NotifyPolicyUpdated( | 563 void DeviceLocalAccountPolicyService::NotifyPolicyUpdated( |
565 const std::string& user_id) { | 564 const std::string& user_id) { |
566 FOR_EACH_OBSERVER(Observer, observers_, OnPolicyUpdated(user_id)); | 565 FOR_EACH_OBSERVER(Observer, observers_, OnPolicyUpdated(user_id)); |
567 } | 566 } |
568 | 567 |
569 } // namespace policy | 568 } // namespace policy |
OLD | NEW |