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

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

Issue 9960077: Modify the base::JSONReader interface to take a set of options rather than a boolean flag. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 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 | Annotate | Revision Log
OLDNEW
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 "remoting/host/gaia_oauth_client.h" 5 #include "remoting/host/gaia_oauth_client.h"
6 6
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 if (source->GetResponseCode() == net::HTTP_BAD_REQUEST) { 137 if (source->GetResponseCode() == net::HTTP_BAD_REQUEST) {
138 delegate_->OnOAuthError(); 138 delegate_->OnOAuthError();
139 return; 139 return;
140 } 140 }
141 std::string access_token; 141 std::string access_token;
142 std::string refresh_token; 142 std::string refresh_token;
143 int expires_in_seconds = 0; 143 int expires_in_seconds = 0;
144 if (source->GetResponseCode() == net::HTTP_OK) { 144 if (source->GetResponseCode() == net::HTTP_OK) {
145 std::string data; 145 std::string data;
146 source->GetResponseAsString(&data); 146 source->GetResponseAsString(&data);
147 scoped_ptr<Value> message_value(base::JSONReader::Read(data, false)); 147 scoped_ptr<Value> message_value(base::JSONReader::Read(data));
148 if (message_value.get() && 148 if (message_value.get() &&
149 message_value->IsType(Value::TYPE_DICTIONARY)) { 149 message_value->IsType(Value::TYPE_DICTIONARY)) {
150 scoped_ptr<DictionaryValue> response_dict( 150 scoped_ptr<DictionaryValue> response_dict(
151 static_cast<DictionaryValue*>(message_value.release())); 151 static_cast<DictionaryValue*>(message_value.release()));
152 response_dict->GetString(kAccessTokenValue, &access_token); 152 response_dict->GetString(kAccessTokenValue, &access_token);
153 response_dict->GetString(kRefreshTokenValue, &refresh_token); 153 response_dict->GetString(kRefreshTokenValue, &refresh_token);
154 response_dict->GetInteger(kExpiresInValue, &expires_in_seconds); 154 response_dict->GetInteger(kExpiresInValue, &expires_in_seconds);
155 } 155 }
156 } 156 }
157 if (access_token.empty()) { 157 if (access_token.empty()) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 const std::string& refresh_token, 198 const std::string& refresh_token,
199 int max_retries, 199 int max_retries,
200 Delegate* delegate) { 200 Delegate* delegate) {
201 return core_->RefreshToken(oauth_client_info, 201 return core_->RefreshToken(oauth_client_info,
202 refresh_token, 202 refresh_token,
203 max_retries, 203 max_retries,
204 delegate); 204 delegate);
205 } 205 }
206 206
207 } // namespace remoting 207 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698