| 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" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 #include "policy/proto/device_management_backend.pb.h" | 43 #include "policy/proto/device_management_backend.pb.h" |
| 44 #include "url/gurl.h" | 44 #include "url/gurl.h" |
| 45 | 45 |
| 46 namespace em = enterprise_management; | 46 namespace em = enterprise_management; |
| 47 | 47 |
| 48 namespace policy { | 48 namespace policy { |
| 49 | 49 |
| 50 namespace { | 50 namespace { |
| 51 | 51 |
| 52 // Creates and initializes a cloud policy client. Returns NULL if the device | 52 // Creates and initializes a cloud policy client. Returns NULL if the device |
| 53 // doesn't have credentials in device settings (i.e. is not | 53 // is not enterprise-enrolled. |
| 54 // enterprise-enrolled). | |
| 55 scoped_ptr<CloudPolicyClient> CreateClient( | 54 scoped_ptr<CloudPolicyClient> CreateClient( |
| 56 chromeos::DeviceSettingsService* device_settings_service, | 55 chromeos::DeviceSettingsService* device_settings_service, |
| 57 DeviceManagementService* device_management_service, | 56 DeviceManagementService* device_management_service, |
| 58 scoped_refptr<net::URLRequestContextGetter> system_request_context) { | 57 scoped_refptr<net::URLRequestContextGetter> system_request_context) { |
| 59 const em::PolicyData* policy_data = device_settings_service->policy_data(); | 58 const em::PolicyData* policy_data = device_settings_service->policy_data(); |
| 60 if (!policy_data || | 59 if (!policy_data || |
| 61 !policy_data->has_request_token() || | 60 GetManagementMode(*policy_data) != MANAGEMENT_MODE_ENTERPRISE || |
| 62 !policy_data->has_device_id() || | |
| 63 !device_management_service) { | 61 !device_management_service) { |
| 64 return scoped_ptr<CloudPolicyClient>(); | 62 return scoped_ptr<CloudPolicyClient>(); |
| 65 } | 63 } |
| 66 | 64 |
| 67 scoped_refptr<net::URLRequestContextGetter> request_context = | 65 scoped_refptr<net::URLRequestContextGetter> request_context = |
| 68 new SystemPolicyRequestContext( | 66 new SystemPolicyRequestContext( |
| 69 system_request_context, GetUserAgent()); | 67 system_request_context, GetUserAgent()); |
| 70 | 68 |
| 71 scoped_ptr<CloudPolicyClient> client( | 69 scoped_ptr<CloudPolicyClient> client( |
| 72 new CloudPolicyClient(std::string(), std::string(), | 70 new CloudPolicyClient(std::string(), std::string(), |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 } | 558 } |
| 561 return NULL; | 559 return NULL; |
| 562 } | 560 } |
| 563 | 561 |
| 564 void DeviceLocalAccountPolicyService::NotifyPolicyUpdated( | 562 void DeviceLocalAccountPolicyService::NotifyPolicyUpdated( |
| 565 const std::string& user_id) { | 563 const std::string& user_id) { |
| 566 FOR_EACH_OBSERVER(Observer, observers_, OnPolicyUpdated(user_id)); | 564 FOR_EACH_OBSERVER(Observer, observers_, OnPolicyUpdated(user_id)); |
| 567 } | 565 } |
| 568 | 566 |
| 569 } // namespace policy | 567 } // namespace policy |
| OLD | NEW |