Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: chrome/common/net/gaia/oauth2_mint_token_fetcher.cc

Issue 10554008: Move content::URLFetcher static functions to net::URLFetcher (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix win link error Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_fetcher.h" 5 #include "chrome/common/net/gaia/oauth2_mint_token_fetcher.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "base/stringprintf.h" 12 #include "base/stringprintf.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/common/net/gaia/gaia_urls.h" 14 #include "chrome/common/net/gaia/gaia_urls.h"
15 #include "chrome/common/net/gaia/google_service_auth_error.h" 15 #include "chrome/common/net/gaia/google_service_auth_error.h"
16 #include "content/public/common/url_fetcher.h"
17 #include "net/base/escape.h" 16 #include "net/base/escape.h"
18 #include "net/base/load_flags.h" 17 #include "net/base/load_flags.h"
19 #include "net/http/http_status_code.h" 18 #include "net/http/http_status_code.h"
19 #include "net/url_request/url_fetcher.h"
20 #include "net/url_request/url_request_context_getter.h" 20 #include "net/url_request/url_request_context_getter.h"
21 #include "net/url_request/url_request_status.h" 21 #include "net/url_request/url_request_status.h"
22 22
23 using net::URLFetcher; 23 using net::URLFetcher;
24 using net::URLFetcherDelegate; 24 using net::URLFetcherDelegate;
25 using net::ResponseCookies; 25 using net::ResponseCookies;
26 using net::URLRequestContextGetter; 26 using net::URLRequestContextGetter;
27 using net::URLRequestStatus; 27 using net::URLRequestStatus;
28 28
29 namespace { 29 namespace {
(...skipping 17 matching lines...) Expand all
47 return GoogleServiceAuthError::FromConnectionError(status.error()); 47 return GoogleServiceAuthError::FromConnectionError(status.error());
48 } 48 }
49 } 49 }
50 50
51 static URLFetcher* CreateFetcher(URLRequestContextGetter* getter, 51 static URLFetcher* CreateFetcher(URLRequestContextGetter* getter,
52 const GURL& url, 52 const GURL& url,
53 const std::string& headers, 53 const std::string& headers,
54 const std::string& body, 54 const std::string& body,
55 URLFetcherDelegate* delegate) { 55 URLFetcherDelegate* delegate) {
56 bool empty_body = body.empty(); 56 bool empty_body = body.empty();
57 URLFetcher* result = content::URLFetcher::Create( 57 URLFetcher* result = net::URLFetcher::Create(
58 0, url, 58 0, url,
59 empty_body ? URLFetcher::GET : URLFetcher::POST, 59 empty_body ? URLFetcher::GET : URLFetcher::POST,
60 delegate); 60 delegate);
61 61
62 result->SetRequestContext(getter); 62 result->SetRequestContext(getter);
63 result->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | 63 result->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |
64 net::LOAD_DO_NOT_SAVE_COOKIES); 64 net::LOAD_DO_NOT_SAVE_COOKIES);
65 65
66 if (!empty_body) 66 if (!empty_body)
67 result->SetUploadData("application/x-www-form-urlencoded", body); 67 result->SetUploadData("application/x-www-form-urlencoded", body);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 CHECK(access_token); 181 CHECK(access_token);
182 std::string data; 182 std::string data;
183 source->GetResponseAsString(&data); 183 source->GetResponseAsString(&data);
184 scoped_ptr<base::Value> value(base::JSONReader::Read(data)); 184 scoped_ptr<base::Value> value(base::JSONReader::Read(data));
185 if (!value.get() || value->GetType() != base::Value::TYPE_DICTIONARY) 185 if (!value.get() || value->GetType() != base::Value::TYPE_DICTIONARY)
186 return false; 186 return false;
187 187
188 DictionaryValue* dict = static_cast<DictionaryValue*>(value.get()); 188 DictionaryValue* dict = static_cast<DictionaryValue*>(value.get());
189 return dict->GetString(kAccessTokenKey, access_token); 189 return dict->GetString(kAccessTokenKey, access_token);
190 } 190 }
OLDNEW
« no previous file with comments | « chrome/common/net/gaia/oauth2_api_call_flow_unittest.cc ('k') | chrome/common/net/gaia/oauth2_mint_token_fetcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698