OLD | NEW |
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 "chrome/common/net/gaia/oauth2_mint_token_flow.h" | 5 #include "chrome/common/net/gaia/oauth2_mint_token_flow.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 kOAuth2IssueTokenBodyFormat, | 172 kOAuth2IssueTokenBodyFormat, |
173 net::EscapeUrlEncodedData(force_value, true).c_str(), | 173 net::EscapeUrlEncodedData(force_value, true).c_str(), |
174 net::EscapeUrlEncodedData(response_type_value, true).c_str(), | 174 net::EscapeUrlEncodedData(response_type_value, true).c_str(), |
175 net::EscapeUrlEncodedData( | 175 net::EscapeUrlEncodedData( |
176 JoinString(parameters_.scopes, ' '), true).c_str(), | 176 JoinString(parameters_.scopes, ' '), true).c_str(), |
177 net::EscapeUrlEncodedData(parameters_.client_id, true).c_str(), | 177 net::EscapeUrlEncodedData(parameters_.client_id, true).c_str(), |
178 net::EscapeUrlEncodedData(parameters_.extension_id, true).c_str()); | 178 net::EscapeUrlEncodedData(parameters_.extension_id, true).c_str()); |
179 } | 179 } |
180 | 180 |
181 void OAuth2MintTokenFlow::ProcessApiCallSuccess( | 181 void OAuth2MintTokenFlow::ProcessApiCallSuccess( |
182 const content::URLFetcher* source) { | 182 const net::URLFetcher* source) { |
183 // TODO(munjal): Change error code paths in this method to report an | 183 // TODO(munjal): Change error code paths in this method to report an |
184 // internal error. | 184 // internal error. |
185 std::string response_body; | 185 std::string response_body; |
186 source->GetResponseAsString(&response_body); | 186 source->GetResponseAsString(&response_body); |
187 base::JSONReader reader; | 187 base::JSONReader reader; |
188 scoped_ptr<base::Value> value(reader.Read(response_body, false)); | 188 scoped_ptr<base::Value> value(reader.Read(response_body, false)); |
189 DictionaryValue* dict = NULL; | 189 DictionaryValue* dict = NULL; |
190 if (!value.get() || !value->GetAsDictionary(&dict)) { | 190 if (!value.get() || !value->GetAsDictionary(&dict)) { |
191 ReportFailure(GoogleServiceAuthError::FromConnectionError(101)); | 191 ReportFailure(GoogleServiceAuthError::FromConnectionError(101)); |
192 return; | 192 return; |
(...skipping 13 matching lines...) Expand all Loading... |
206 } else { | 206 } else { |
207 std::string access_token; | 207 std::string access_token; |
208 if (ParseMintTokenResponse(dict, &access_token)) | 208 if (ParseMintTokenResponse(dict, &access_token)) |
209 ReportSuccess(access_token); | 209 ReportSuccess(access_token); |
210 else | 210 else |
211 ReportFailure(GoogleServiceAuthError::FromConnectionError(101)); | 211 ReportFailure(GoogleServiceAuthError::FromConnectionError(101)); |
212 } | 212 } |
213 } | 213 } |
214 | 214 |
215 void OAuth2MintTokenFlow::ProcessApiCallFailure( | 215 void OAuth2MintTokenFlow::ProcessApiCallFailure( |
216 const content::URLFetcher* source) { | 216 const net::URLFetcher* source) { |
217 ReportFailure(CreateAuthError(source->GetStatus())); | 217 ReportFailure(CreateAuthError(source->GetStatus())); |
218 } | 218 } |
219 void OAuth2MintTokenFlow::ProcessNewAccessToken( | 219 void OAuth2MintTokenFlow::ProcessNewAccessToken( |
220 const std::string& access_token) { | 220 const std::string& access_token) { |
221 // We don't currently store new access tokens. We generate one every time. | 221 // We don't currently store new access tokens. We generate one every time. |
222 // So we have nothing to do here. | 222 // So we have nothing to do here. |
223 return; | 223 return; |
224 } | 224 } |
225 void OAuth2MintTokenFlow::ProcessMintAccessTokenFailure( | 225 void OAuth2MintTokenFlow::ProcessMintAccessTokenFailure( |
226 const GoogleServiceAuthError& error) { | 226 const GoogleServiceAuthError& error) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 | 263 |
264 Tokenize(detail, kDetailSeparators, &entry.details); | 264 Tokenize(detail, kDetailSeparators, &entry.details); |
265 issue_advice->push_back(entry); | 265 issue_advice->push_back(entry); |
266 } | 266 } |
267 | 267 |
268 if (!success) | 268 if (!success) |
269 issue_advice->clear(); | 269 issue_advice->clear(); |
270 | 270 |
271 return success; | 271 return success; |
272 } | 272 } |
OLD | NEW |