Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(517)

Side by Side Diff: components/policy/core/common/cloud/policy_header_service.cc

Issue 1131113004: Convert JsonWriter::Write to taking a const ref for the in-param (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: another rebase Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 if (user_policy_store_->policy()->has_policy_token()) { 67 if (user_policy_store_->policy()->has_policy_token()) {
68 value.SetString(kUserPolicyTokenKey, 68 value.SetString(kUserPolicyTokenKey,
69 user_policy_store_->policy()->policy_token()); 69 user_policy_store_->policy()->policy_token());
70 } 70 }
71 if (!verification_key_hash_.empty()) 71 if (!verification_key_hash_.empty())
72 value.SetString(kVerificationKeyHashKey, verification_key_hash_); 72 value.SetString(kVerificationKeyHashKey, verification_key_hash_);
73 73
74 // TODO(atwilson): add user_policy_token once the server starts sending it 74 // TODO(atwilson): add user_policy_token once the server starts sending it
75 // down (http://crbug.com/326799). 75 // down (http://crbug.com/326799).
76 std::string json; 76 std::string json;
77 base::JSONWriter::Write(&value, &json); 77 base::JSONWriter::Write(value, &json);
78 DCHECK(!json.empty()); 78 DCHECK(!json.empty());
79 79
80 // Base64-encode the result so we can include it in a header. 80 // Base64-encode the result so we can include it in a header.
81 std::string encoded; 81 std::string encoded;
82 base::Base64Encode(json, &encoded); 82 base::Base64Encode(json, &encoded);
83 return encoded; 83 return encoded;
84 } 84 }
85 85
86 void PolicyHeaderService::OnStoreLoaded(CloudPolicyStore* store) { 86 void PolicyHeaderService::OnStoreLoaded(CloudPolicyStore* store) {
87 // If we have a PolicyHeaderIOHelper, notify it of the new header value. 87 // If we have a PolicyHeaderIOHelper, notify it of the new header value.
88 if (!helpers_.empty()) { 88 if (!helpers_.empty()) {
89 std::string new_header = CreateHeaderValue(); 89 std::string new_header = CreateHeaderValue();
90 for (std::vector<PolicyHeaderIOHelper*>::const_iterator it = 90 for (std::vector<PolicyHeaderIOHelper*>::const_iterator it =
91 helpers_.begin(); it != helpers_.end(); ++it) { 91 helpers_.begin(); it != helpers_.end(); ++it) {
92 (*it)->UpdateHeader(new_header); 92 (*it)->UpdateHeader(new_header);
93 } 93 }
94 } 94 }
95 } 95 }
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
OLDNEW
« no previous file with comments | « components/omnibox/search_suggestion_parser.cc ('k') | components/policy/core/common/policy_loader_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698