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

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

Issue 9572001: Do cookie checks in NetworkDelegate instead of the URLRequest::Delegate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clang fix Created 8 years, 9 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_access_token_fetcher.h" 5 #include "chrome/common/net/gaia/oauth2_access_token_fetcher.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/json/json_reader.h" 11 #include "base/json/json_reader.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "base/stringprintf.h" 13 #include "base/stringprintf.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "chrome/common/net/gaia/gaia_urls.h" 15 #include "chrome/common/net/gaia/gaia_urls.h"
16 #include "chrome/common/net/gaia/google_service_auth_error.h" 16 #include "chrome/common/net/gaia/google_service_auth_error.h"
17 #include "content/public/common/content_url_request_user_data.h"
17 #include "net/base/escape.h" 18 #include "net/base/escape.h"
18 #include "net/base/load_flags.h" 19 #include "net/base/load_flags.h"
19 #include "net/http/http_status_code.h" 20 #include "net/http/http_status_code.h"
20 #include "net/url_request/url_request_context_getter.h" 21 #include "net/url_request/url_request_context_getter.h"
21 #include "net/url_request/url_request_status.h" 22 #include "net/url_request/url_request_status.h"
22 23
23 using content::URLFetcher; 24 using content::URLFetcher;
24 using content::URLFetcherDelegate; 25 using content::URLFetcherDelegate;
25 using net::ResponseCookies; 26 using net::ResponseCookies;
26 using net::URLRequestContextGetter; 27 using net::URLRequestContextGetter;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 const GURL& url, 72 const GURL& url,
72 const std::string& body, 73 const std::string& body,
73 URLFetcherDelegate* delegate) { 74 URLFetcherDelegate* delegate) {
74 bool empty_body = body.empty(); 75 bool empty_body = body.empty();
75 URLFetcher* result = URLFetcher::Create( 76 URLFetcher* result = URLFetcher::Create(
76 0, url, 77 0, url,
77 empty_body ? URLFetcher::GET : URLFetcher::POST, 78 empty_body ? URLFetcher::GET : URLFetcher::POST,
78 delegate); 79 delegate);
79 80
80 result->SetRequestContext(getter); 81 result->SetRequestContext(getter);
82 // No user data, as the request will be cookie-less.
83 result->SetContentURLRequestUserData(
84 new content::ContentURLRequestUserData());
81 result->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | 85 result->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |
82 net::LOAD_DO_NOT_SAVE_COOKIES); 86 net::LOAD_DO_NOT_SAVE_COOKIES);
83 87
84 if (!empty_body) 88 if (!empty_body)
85 result->SetUploadData("application/x-www-form-urlencoded", body); 89 result->SetUploadData("application/x-www-form-urlencoded", body);
86 90
87 return result; 91 return result;
88 } 92 }
89 } // namespace 93 } // namespace
90 94
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 std::string data; 210 std::string data;
207 source->GetResponseAsString(&data); 211 source->GetResponseAsString(&data);
208 base::JSONReader reader; 212 base::JSONReader reader;
209 scoped_ptr<base::Value> value(reader.Read(data, false)); 213 scoped_ptr<base::Value> value(reader.Read(data, false));
210 if (!value.get() || value->GetType() != base::Value::TYPE_DICTIONARY) 214 if (!value.get() || value->GetType() != base::Value::TYPE_DICTIONARY)
211 return false; 215 return false;
212 216
213 DictionaryValue* dict = static_cast<DictionaryValue*>(value.get()); 217 DictionaryValue* dict = static_cast<DictionaryValue*>(value.get());
214 return GetStringFromDictionary(dict, kAccessTokenKey, access_token); 218 return GetStringFromDictionary(dict, kAccessTokenKey, access_token);
215 } 219 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698