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 "google_apis/gaia/oauth2_mint_token_flow.h" | 5 #include "google_apis/gaia/oauth2_mint_token_flow.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 if (status.status() == URLRequestStatus::CANCELED) { | 65 if (status.status() == URLRequestStatus::CANCELED) { |
66 return GoogleServiceAuthError(GoogleServiceAuthError::REQUEST_CANCELED); | 66 return GoogleServiceAuthError(GoogleServiceAuthError::REQUEST_CANCELED); |
67 } | 67 } |
68 if (status.status() == URLRequestStatus::FAILED) { | 68 if (status.status() == URLRequestStatus::FAILED) { |
69 DLOG(WARNING) << "Server returned error: errno " << status.error(); | 69 DLOG(WARNING) << "Server returned error: errno " << status.error(); |
70 return GoogleServiceAuthError::FromConnectionError(status.error()); | 70 return GoogleServiceAuthError::FromConnectionError(status.error()); |
71 } | 71 } |
72 | 72 |
73 std::string response_body; | 73 std::string response_body; |
74 source->GetResponseAsString(&response_body); | 74 source->GetResponseAsString(&response_body); |
75 scoped_ptr<base::Value> value = base::JSONReader::Read(response_body); | 75 std::unique_ptr<base::Value> value = base::JSONReader::Read(response_body); |
76 base::DictionaryValue* response; | 76 base::DictionaryValue* response; |
77 if (!value.get() || !value->GetAsDictionary(&response)) { | 77 if (!value.get() || !value->GetAsDictionary(&response)) { |
78 return GoogleServiceAuthError::FromUnexpectedServiceResponse( | 78 return GoogleServiceAuthError::FromUnexpectedServiceResponse( |
79 base::StringPrintf( | 79 base::StringPrintf( |
80 "Not able to parse a JSON object from a service response. " | 80 "Not able to parse a JSON object from a service response. " |
81 "HTTP Status of the response is: %d", source->GetResponseCode())); | 81 "HTTP Status of the response is: %d", source->GetResponseCode())); |
82 } | 82 } |
83 base::DictionaryValue* error; | 83 base::DictionaryValue* error; |
84 if (!response->GetDictionary(kError, &error)) { | 84 if (!response->GetDictionary(kError, &error)) { |
85 return GoogleServiceAuthError::FromUnexpectedServiceResponse( | 85 return GoogleServiceAuthError::FromUnexpectedServiceResponse( |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 kOAuth2IssueTokenBodyFormatDeviceIdAddendum, | 180 kOAuth2IssueTokenBodyFormatDeviceIdAddendum, |
181 net::EscapeUrlEncodedData(parameters_.device_id, true).c_str())); | 181 net::EscapeUrlEncodedData(parameters_.device_id, true).c_str())); |
182 } | 182 } |
183 return body; | 183 return body; |
184 } | 184 } |
185 | 185 |
186 void OAuth2MintTokenFlow::ProcessApiCallSuccess( | 186 void OAuth2MintTokenFlow::ProcessApiCallSuccess( |
187 const net::URLFetcher* source) { | 187 const net::URLFetcher* source) { |
188 std::string response_body; | 188 std::string response_body; |
189 source->GetResponseAsString(&response_body); | 189 source->GetResponseAsString(&response_body); |
190 scoped_ptr<base::Value> value = base::JSONReader::Read(response_body); | 190 std::unique_ptr<base::Value> value = base::JSONReader::Read(response_body); |
191 base::DictionaryValue* dict = NULL; | 191 base::DictionaryValue* dict = NULL; |
192 if (!value.get() || !value->GetAsDictionary(&dict)) { | 192 if (!value.get() || !value->GetAsDictionary(&dict)) { |
193 ReportFailure(GoogleServiceAuthError::FromUnexpectedServiceResponse( | 193 ReportFailure(GoogleServiceAuthError::FromUnexpectedServiceResponse( |
194 "Not able to parse a JSON object from a service response.")); | 194 "Not able to parse a JSON object from a service response.")); |
195 return; | 195 return; |
196 } | 196 } |
197 | 197 |
198 std::string issue_advice_value; | 198 std::string issue_advice_value; |
199 if (!dict->GetString(kIssueAdviceKey, &issue_advice_value)) { | 199 if (!dict->GetString(kIssueAdviceKey, &issue_advice_value)) { |
200 ReportFailure(GoogleServiceAuthError::FromUnexpectedServiceResponse( | 200 ReportFailure(GoogleServiceAuthError::FromUnexpectedServiceResponse( |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 detail, base::ASCIIToUTF16(kDetailSeparators), | 272 detail, base::ASCIIToUTF16(kDetailSeparators), |
273 base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); | 273 base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
274 issue_advice->push_back(entry); | 274 issue_advice->push_back(entry); |
275 } | 275 } |
276 | 276 |
277 if (!success) | 277 if (!success) |
278 issue_advice->clear(); | 278 issue_advice->clear(); |
279 | 279 |
280 return success; | 280 return success; |
281 } | 281 } |
OLD | NEW |