OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/policy/core/common/cloud/user_cloud_policy_store_base.h" | 5 #include "components/policy/core/common/cloud/user_cloud_policy_store_base.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "components/policy/core/common/cloud/cloud_external_data_manager.h" | 9 #include "components/policy/core/common/cloud/cloud_external_data_manager.h" |
8 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 10 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
9 #include "components/policy/core/common/policy_map.h" | 11 #include "components/policy/core/common/policy_map.h" |
10 #include "policy/proto/cloud_policy.pb.h" | 12 #include "policy/proto/cloud_policy.pb.h" |
11 | 13 |
12 namespace policy { | 14 namespace policy { |
13 | 15 |
14 // Decodes a CloudPolicySettings object into a policy map. The implementation is | 16 // Decodes a CloudPolicySettings object into a policy map. The implementation is |
15 // generated code in policy/cloud_policy_generated.cc. | 17 // generated code in policy/cloud_policy_generated.cc. |
16 void DecodePolicy(const enterprise_management::CloudPolicySettings& policy, | 18 void DecodePolicy(const enterprise_management::CloudPolicySettings& policy, |
17 base::WeakPtr<CloudExternalDataManager> external_data_manager, | 19 base::WeakPtr<CloudExternalDataManager> external_data_manager, |
18 PolicyMap* policies); | 20 PolicyMap* policies); |
19 | 21 |
20 UserCloudPolicyStoreBase::UserCloudPolicyStoreBase( | 22 UserCloudPolicyStoreBase::UserCloudPolicyStoreBase( |
21 scoped_refptr<base::SequencedTaskRunner> background_task_runner) | 23 scoped_refptr<base::SequencedTaskRunner> background_task_runner) |
22 : background_task_runner_(background_task_runner) {} | 24 : background_task_runner_(background_task_runner) {} |
23 | 25 |
24 UserCloudPolicyStoreBase::~UserCloudPolicyStoreBase() { | 26 UserCloudPolicyStoreBase::~UserCloudPolicyStoreBase() { |
25 } | 27 } |
26 | 28 |
27 scoped_ptr<UserCloudPolicyValidator> UserCloudPolicyStoreBase::CreateValidator( | 29 scoped_ptr<UserCloudPolicyValidator> UserCloudPolicyStoreBase::CreateValidator( |
28 scoped_ptr<enterprise_management::PolicyFetchResponse> policy, | 30 scoped_ptr<enterprise_management::PolicyFetchResponse> policy, |
29 CloudPolicyValidatorBase::ValidateTimestampOption timestamp_option) { | 31 CloudPolicyValidatorBase::ValidateTimestampOption timestamp_option) { |
30 // Configure the validator. | 32 // Configure the validator. |
31 UserCloudPolicyValidator* validator = | 33 UserCloudPolicyValidator* validator = UserCloudPolicyValidator::Create( |
32 UserCloudPolicyValidator::Create(policy.Pass(), background_task_runner_); | 34 std::move(policy), background_task_runner_); |
33 validator->ValidatePolicyType(dm_protocol::kChromeUserPolicyType); | 35 validator->ValidatePolicyType(dm_protocol::kChromeUserPolicyType); |
34 validator->ValidateAgainstCurrentPolicy( | 36 validator->ValidateAgainstCurrentPolicy( |
35 policy_.get(), | 37 policy_.get(), |
36 timestamp_option, | 38 timestamp_option, |
37 CloudPolicyValidatorBase::DM_TOKEN_REQUIRED); | 39 CloudPolicyValidatorBase::DM_TOKEN_REQUIRED); |
38 validator->ValidatePayload(); | 40 validator->ValidatePayload(); |
39 return scoped_ptr<UserCloudPolicyValidator>(validator); | 41 return scoped_ptr<UserCloudPolicyValidator>(validator); |
40 } | 42 } |
41 | 43 |
42 void UserCloudPolicyStoreBase::InstallPolicy( | 44 void UserCloudPolicyStoreBase::InstallPolicy( |
43 scoped_ptr<enterprise_management::PolicyData> policy_data, | 45 scoped_ptr<enterprise_management::PolicyData> policy_data, |
44 scoped_ptr<enterprise_management::CloudPolicySettings> payload) { | 46 scoped_ptr<enterprise_management::CloudPolicySettings> payload) { |
45 // Decode the payload. | 47 // Decode the payload. |
46 policy_map_.Clear(); | 48 policy_map_.Clear(); |
47 DecodePolicy(*payload, external_data_manager(), &policy_map_); | 49 DecodePolicy(*payload, external_data_manager(), &policy_map_); |
48 policy_ = policy_data.Pass(); | 50 policy_ = std::move(policy_data); |
49 } | 51 } |
50 | 52 |
51 } // namespace policy | 53 } // namespace policy |
OLD | NEW |