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_api_call_flow.h" | 5 #include "chrome/common/net/gaia/oauth2_api_call_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" |
11 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
12 #include "chrome/common/net/gaia/gaia_urls.h" | 12 #include "chrome/common/net/gaia/gaia_urls.h" |
13 #include "net/base/escape.h" | 13 #include "net/base/escape.h" |
14 #include "net/base/load_flags.h" | 14 #include "net/base/load_flags.h" |
15 #include "net/http/http_status_code.h" | 15 #include "net/http/http_status_code.h" |
16 #include "net/url_request/url_request_context_getter.h" | 16 #include "net/url_request/url_request_context_getter.h" |
17 #include "net/url_request/url_request_status.h" | 17 #include "net/url_request/url_request_status.h" |
18 | 18 |
19 using content::URLFetcher; | 19 using content::URLFetcher; |
20 using content::URLFetcherDelegate; | 20 using net::URLFetcherDelegate; |
21 using net::ResponseCookies; | 21 using net::ResponseCookies; |
22 using net::URLRequestContextGetter; | 22 using net::URLRequestContextGetter; |
23 using net::URLRequestStatus; | 23 using net::URLRequestStatus; |
24 | 24 |
25 namespace { | 25 namespace { |
26 static const char kAuthorizationHeaderFormat[] = | 26 static const char kAuthorizationHeaderFormat[] = |
27 "Authorization: Bearer %s"; | 27 "Authorization: Bearer %s"; |
28 | 28 |
29 static std::string MakeAuthorizationHeader(const std::string& auth_token) { | 29 static std::string MakeAuthorizationHeader(const std::string& auth_token) { |
30 return StringPrintf(kAuthorizationHeaderFormat, auth_token.c_str()); | 30 return StringPrintf(kAuthorizationHeaderFormat, auth_token.c_str()); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 result->SetRequestContext(context_); | 156 result->SetRequestContext(context_); |
157 result->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 157 result->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
158 net::LOAD_DO_NOT_SAVE_COOKIES); | 158 net::LOAD_DO_NOT_SAVE_COOKIES); |
159 result->AddExtraRequestHeader(MakeAuthorizationHeader(access_token_)); | 159 result->AddExtraRequestHeader(MakeAuthorizationHeader(access_token_)); |
160 | 160 |
161 if (!empty_body) | 161 if (!empty_body) |
162 result->SetUploadData("application/x-www-form-urlencoded", body); | 162 result->SetUploadData("application/x-www-form-urlencoded", body); |
163 | 163 |
164 return result; | 164 return result; |
165 } | 165 } |
OLD | NEW |