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

Side by Side Diff: remoting/host/token_validator_base.cc

Issue 1864213002: Convert //remoting to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac IWYU Created 4 years, 8 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
« no previous file with comments | « remoting/host/token_validator_base.h ('k') | remoting/host/token_validator_factory_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "remoting/host/token_validator_base.h" 5 #include "remoting/host/token_validator_base.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 } 202 }
203 203
204 int response = request_->GetResponseCode(); 204 int response = request_->GetResponseCode();
205 if (response != 200) { 205 if (response != 200) {
206 LOG(ERROR) 206 LOG(ERROR)
207 << "Error " << response << " validating token: '" << data_ << "'"; 207 << "Error " << response << " validating token: '" << data_ << "'";
208 return std::string(); 208 return std::string();
209 } 209 }
210 210
211 // Decode the JSON data from the response. 211 // Decode the JSON data from the response.
212 scoped_ptr<base::Value> value = base::JSONReader::Read(data_); 212 std::unique_ptr<base::Value> value = base::JSONReader::Read(data_);
213 base::DictionaryValue* dict; 213 base::DictionaryValue* dict;
214 if (!value || !value->GetAsDictionary(&dict)) { 214 if (!value || !value->GetAsDictionary(&dict)) {
215 LOG(ERROR) << "Invalid token validation response: '" << data_ << "'"; 215 LOG(ERROR) << "Invalid token validation response: '" << data_ << "'";
216 return std::string(); 216 return std::string();
217 } 217 }
218 218
219 std::string token_scope; 219 std::string token_scope;
220 dict->GetStringWithoutPathExpansion("scope", &token_scope); 220 dict->GetStringWithoutPathExpansion("scope", &token_scope);
221 if (!IsValidScope(token_scope)) { 221 if (!IsValidScope(token_scope)) {
222 LOG(ERROR) << "Invalid scope: '" << token_scope 222 LOG(ERROR) << "Invalid scope: '" << token_scope
223 << "', expected: '" << token_scope_ <<"'."; 223 << "', expected: '" << token_scope_ <<"'.";
224 return std::string(); 224 return std::string();
225 } 225 }
226 226
227 std::string shared_secret; 227 std::string shared_secret;
228 // Everything is valid, so return the shared secret to the caller. 228 // Everything is valid, so return the shared secret to the caller.
229 dict->GetStringWithoutPathExpansion("access_token", &shared_secret); 229 dict->GetStringWithoutPathExpansion("access_token", &shared_secret);
230 return shared_secret; 230 return shared_secret;
231 } 231 }
232 232
233 } // namespace remoting 233 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/token_validator_base.h ('k') | remoting/host/token_validator_factory_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698