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/policy_header_service.h" | 5 #include "components/policy/core/common/cloud/policy_header_service.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "components/policy/core/common/cloud/cloud_policy_store.h" | 10 #include "components/policy/core/common/cloud/cloud_policy_store.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 device_policy_store_->RemoveObserver(this); | 38 device_policy_store_->RemoveObserver(this); |
39 } | 39 } |
40 | 40 |
41 scoped_ptr<PolicyHeaderIOHelper> | 41 scoped_ptr<PolicyHeaderIOHelper> |
42 PolicyHeaderService::CreatePolicyHeaderIOHelper( | 42 PolicyHeaderService::CreatePolicyHeaderIOHelper( |
43 scoped_refptr<base::SequencedTaskRunner> task_runner) { | 43 scoped_refptr<base::SequencedTaskRunner> task_runner) { |
44 std::string initial_header_value = CreateHeaderValue(); | 44 std::string initial_header_value = CreateHeaderValue(); |
45 scoped_ptr<PolicyHeaderIOHelper> helper = make_scoped_ptr( | 45 scoped_ptr<PolicyHeaderIOHelper> helper = make_scoped_ptr( |
46 new PolicyHeaderIOHelper(server_url_, initial_header_value, task_runner)); | 46 new PolicyHeaderIOHelper(server_url_, initial_header_value, task_runner)); |
47 helpers_.push_back(helper.get()); | 47 helpers_.push_back(helper.get()); |
48 return helper.Pass(); | 48 return helper; |
49 } | 49 } |
50 | 50 |
51 std::string PolicyHeaderService::CreateHeaderValue() { | 51 std::string PolicyHeaderService::CreateHeaderValue() { |
52 // If we have no user policy or no token, return an empty header. | 52 // If we have no user policy or no token, return an empty header. |
53 if (!user_policy_store_->has_policy() || | 53 if (!user_policy_store_->has_policy() || |
54 !user_policy_store_->policy()->has_request_token()) { | 54 !user_policy_store_->policy()->has_request_token()) { |
55 return ""; | 55 return ""; |
56 } | 56 } |
57 | 57 |
58 // Generate a Base64-encoded header of the form: | 58 // Generate a Base64-encoded header of the form: |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 96 |
97 void PolicyHeaderService::OnStoreError(CloudPolicyStore* store) { | 97 void PolicyHeaderService::OnStoreError(CloudPolicyStore* store) { |
98 // Do nothing on errors. | 98 // Do nothing on errors. |
99 } | 99 } |
100 | 100 |
101 std::vector<PolicyHeaderIOHelper*> PolicyHeaderService::GetHelpersForTest() { | 101 std::vector<PolicyHeaderIOHelper*> PolicyHeaderService::GetHelpersForTest() { |
102 return helpers_; | 102 return helpers_; |
103 } | 103 } |
104 | 104 |
105 } // namespace policy | 105 } // namespace policy |
OLD | NEW |