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 <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "net/url_request/url_fetcher.h" | 23 #include "net/url_request/url_fetcher.h" |
24 #include "net/url_request/url_request_context_getter.h" | 24 #include "net/url_request/url_request_context_getter.h" |
25 #include "net/url_request/url_request_status.h" | 25 #include "net/url_request/url_request_status.h" |
26 | 26 |
27 using net::URLFetcher; | 27 using net::URLFetcher; |
28 using net::URLRequestContextGetter; | 28 using net::URLRequestContextGetter; |
29 using net::URLRequestStatus; | 29 using net::URLRequestStatus; |
30 | 30 |
31 namespace { | 31 namespace { |
32 | 32 |
33 static const char kForceValueFalse[] = "false"; | 33 const char kForceValueFalse[] = "false"; |
34 static const char kForceValueTrue[] = "true"; | 34 const char kForceValueTrue[] = "true"; |
35 static const char kResponseTypeValueNone[] = "none"; | 35 const char kResponseTypeValueNone[] = "none"; |
36 static const char kResponseTypeValueToken[] = "token"; | 36 const char kResponseTypeValueToken[] = "token"; |
37 | 37 |
38 static const char kOAuth2IssueTokenBodyFormat[] = | 38 const char kOAuth2IssueTokenBodyFormat[] = |
39 "force=%s" | 39 "force=%s" |
40 "&response_type=%s" | 40 "&response_type=%s" |
41 "&scope=%s" | 41 "&scope=%s" |
42 "&client_id=%s" | 42 "&client_id=%s" |
43 "&origin=%s"; | 43 "&origin=%s"; |
44 static const char kIssueAdviceKey[] = "issueAdvice"; | 44 const char kIssueAdviceKey[] = "issueAdvice"; |
45 static const char kIssueAdviceValueAuto[] = "auto"; | 45 const char kIssueAdviceValueConsent[] = "consent"; |
46 static const char kIssueAdviceValueConsent[] = "consent"; | 46 const char kAccessTokenKey[] = "token"; |
47 static const char kAccessTokenKey[] = "token"; | 47 const char kConsentKey[] = "consent"; |
48 static const char kConsentKey[] = "consent"; | 48 const char kExpiresInKey[] = "expiresIn"; |
49 static const char kExpiresInKey[] = "expiresIn"; | 49 const char kScopesKey[] = "scopes"; |
50 static const char kScopesKey[] = "scopes"; | 50 const char kDescriptionKey[] = "description"; |
51 static const char kDescriptionKey[] = "description"; | 51 const char kDetailKey[] = "detail"; |
52 static const char kDetailKey[] = "detail"; | 52 const char kDetailSeparators[] = "\n"; |
53 static const char kDetailSeparators[] = "\n"; | 53 const char kError[] = "error"; |
54 static const char kError[] = "error"; | 54 const char kMessage[] = "message"; |
55 static const char kMessage[] = "message"; | |
56 | 55 |
57 static GoogleServiceAuthError CreateAuthError(const net::URLFetcher* source) { | 56 static GoogleServiceAuthError CreateAuthError(const net::URLFetcher* source) { |
58 URLRequestStatus status = source->GetStatus(); | 57 URLRequestStatus status = source->GetStatus(); |
59 if (status.status() == URLRequestStatus::CANCELED) { | 58 if (status.status() == URLRequestStatus::CANCELED) { |
60 return GoogleServiceAuthError(GoogleServiceAuthError::REQUEST_CANCELED); | 59 return GoogleServiceAuthError(GoogleServiceAuthError::REQUEST_CANCELED); |
61 } | 60 } |
62 if (status.status() == URLRequestStatus::FAILED) { | 61 if (status.status() == URLRequestStatus::FAILED) { |
63 DLOG(WARNING) << "Server returned error: errno " << status.error(); | 62 DLOG(WARNING) << "Server returned error: errno " << status.error(); |
64 return GoogleServiceAuthError::FromConnectionError(status.error()); | 63 return GoogleServiceAuthError::FromConnectionError(status.error()); |
65 } | 64 } |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 for (size_t i = 0; i < entry.details.size(); i++) | 272 for (size_t i = 0; i < entry.details.size(); i++) |
274 TrimWhitespace(entry.details[i], TRIM_ALL, &entry.details[i]); | 273 TrimWhitespace(entry.details[i], TRIM_ALL, &entry.details[i]); |
275 issue_advice->push_back(entry); | 274 issue_advice->push_back(entry); |
276 } | 275 } |
277 | 276 |
278 if (!success) | 277 if (!success) |
279 issue_advice->clear(); | 278 issue_advice->clear(); |
280 | 279 |
281 return success; | 280 return success; |
282 } | 281 } |
OLD | NEW |