| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/common/net/gaia/gaia_oauth_client.h" | 5 #include "chrome/common/net/gaia/gaia_oauth_client.h" |
| 6 | 6 |
| 7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/common/net/http_return.h" | 10 #include "chrome/common/net/http_return.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 if (response_code == RC_BAD_REQUEST) { | 151 if (response_code == RC_BAD_REQUEST) { |
| 152 delegate_->OnOAuthError(); | 152 delegate_->OnOAuthError(); |
| 153 return; | 153 return; |
| 154 } | 154 } |
| 155 std::string access_token; | 155 std::string access_token; |
| 156 std::string refresh_token; | 156 std::string refresh_token; |
| 157 int expires_in_seconds = 0; | 157 int expires_in_seconds = 0; |
| 158 if (response_code == RC_REQUEST_OK) { | 158 if (response_code == RC_REQUEST_OK) { |
| 159 scoped_ptr<Value> message_value( | 159 scoped_ptr<Value> message_value( |
| 160 base::JSONReader::Read(data, false)); | 160 base::JSONReader::Read(data, false)); |
| 161 if (message_value.get() && | 161 if (message_value.get() && message_value->IsDictionary()) { |
| 162 message_value->IsType(Value::TYPE_DICTIONARY)) { | |
| 163 scoped_ptr<DictionaryValue> response_dict( | 162 scoped_ptr<DictionaryValue> response_dict( |
| 164 static_cast<DictionaryValue*>(message_value.release())); | 163 static_cast<DictionaryValue*>(message_value.release())); |
| 165 response_dict->GetString(kAccessTokenValue, &access_token); | 164 response_dict->GetString(kAccessTokenValue, &access_token); |
| 166 response_dict->GetString(kRefreshTokenValue, &refresh_token); | 165 response_dict->GetString(kRefreshTokenValue, &refresh_token); |
| 167 response_dict->GetInteger(kExpiresInValue, &expires_in_seconds); | 166 response_dict->GetInteger(kExpiresInValue, &expires_in_seconds); |
| 168 } | 167 } |
| 169 } | 168 } |
| 170 if (access_token.empty()) { | 169 if (access_token.empty()) { |
| 171 // If we don't have an access token yet and the the error was not | 170 // If we don't have an access token yet and the the error was not |
| 172 // RC_BAD_REQUEST, we may need to retry. | 171 // RC_BAD_REQUEST, we may need to retry. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 const std::string& refresh_token, | 210 const std::string& refresh_token, |
| 212 int max_retries, | 211 int max_retries, |
| 213 Delegate* delegate) { | 212 Delegate* delegate) { |
| 214 return core_->RefreshToken(oauth_client_info, | 213 return core_->RefreshToken(oauth_client_info, |
| 215 refresh_token, | 214 refresh_token, |
| 216 max_retries, | 215 max_retries, |
| 217 delegate); | 216 delegate); |
| 218 } | 217 } |
| 219 | 218 |
| 220 } // namespace gaia | 219 } // namespace gaia |
| OLD | NEW |