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

Side by Side Diff: chrome/browser/extensions/app_notify_channel_setup.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/browser/extensions/app_notify_channel_setup.h" 5 #include "chrome/browser/extensions/app_notify_channel_setup.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/bind.h" 11 #include "base/bind.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/json/json_reader.h" 13 #include "base/json/json_reader.h"
14 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
15 #include "base/stringprintf.h" 15 #include "base/stringprintf.h"
16 #include "chrome/browser/prefs/pref_service.h" 16 #include "chrome/browser/prefs/pref_service.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/signin/signin_manager.h" 18 #include "chrome/browser/signin/signin_manager.h"
19 #include "chrome/browser/signin/signin_manager_factory.h" 19 #include "chrome/browser/signin/signin_manager_factory.h"
20 #include "chrome/browser/signin/token_service.h" 20 #include "chrome/browser/signin/token_service.h"
21 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
22 #include "chrome/common/net/gaia/gaia_constants.h" 22 #include "chrome/common/net/gaia/gaia_constants.h"
23 #include "chrome/common/net/gaia/gaia_urls.h" 23 #include "chrome/common/net/gaia/gaia_urls.h"
24 #include "chrome/common/pref_names.h" 24 #include "chrome/common/pref_names.h"
25 #include "content/public/browser/browser_thread.h" 25 #include "content/public/browser/browser_thread.h"
26 #include "content/public/common/content_url_request_user_data.h"
26 #include "content/public/common/url_fetcher.h" 27 #include "content/public/common/url_fetcher.h"
27 #include "net/base/escape.h" 28 #include "net/base/escape.h"
28 #include "net/base/load_flags.h" 29 #include "net/base/load_flags.h"
29 #include "net/http/http_request_headers.h" 30 #include "net/http/http_request_headers.h"
30 #include "net/http/http_status_code.h" 31 #include "net/http/http_status_code.h"
31 #include "net/url_request/url_request_status.h" 32 #include "net/url_request/url_request_status.h"
32 33
33 using base::StringPrintf; 34 using base::StringPrintf;
34 using content::BrowserThread; 35 using content::BrowserThread;
35 using content::URLFetcher; 36 using content::URLFetcher;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 } 132 }
132 133
133 // The contents of |body| should be URL-encoded as appropriate. 134 // The contents of |body| should be URL-encoded as appropriate.
134 URLFetcher* AppNotifyChannelSetup::CreateURLFetcher( 135 URLFetcher* AppNotifyChannelSetup::CreateURLFetcher(
135 const GURL& url, const std::string& body, const std::string& auth_token) { 136 const GURL& url, const std::string& body, const std::string& auth_token) {
136 CHECK(url.is_valid()); 137 CHECK(url.is_valid());
137 URLFetcher::RequestType type = 138 URLFetcher::RequestType type =
138 body.empty() ? URLFetcher::GET : URLFetcher::POST; 139 body.empty() ? URLFetcher::GET : URLFetcher::POST;
139 URLFetcher* fetcher = URLFetcher::Create(0, url, type, this); 140 URLFetcher* fetcher = URLFetcher::Create(0, url, type, this);
140 fetcher->SetRequestContext(profile_->GetRequestContext()); 141 fetcher->SetRequestContext(profile_->GetRequestContext());
142 // No user data, as the request will be cookie-less.
143 fetcher->SetContentURLRequestUserData(
144 new content::ContentURLRequestUserData());
141 // Always set flags to neither send nor save cookies. 145 // Always set flags to neither send nor save cookies.
142 fetcher->SetLoadFlags( 146 fetcher->SetLoadFlags(
143 net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES); 147 net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES);
144 fetcher->SetExtraRequestHeaders(MakeAuthorizationHeader(auth_token)); 148 fetcher->SetExtraRequestHeaders(MakeAuthorizationHeader(auth_token));
145 if (!body.empty()) { 149 if (!body.empty()) {
146 fetcher->SetUploadData("application/x-www-form-urlencoded", body); 150 fetcher->SetUploadData("application/x-www-form-urlencoded", body);
147 } 151 }
148 return fetcher; 152 return fetcher;
149 } 153 }
150 154
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 DictionaryValue* dict = static_cast<DictionaryValue*>(value.get()); 403 DictionaryValue* dict = static_cast<DictionaryValue*>(value.get());
400 if (!dict->Get("id", &channel_id_value)) 404 if (!dict->Get("id", &channel_id_value))
401 return false; 405 return false;
402 if (channel_id_value->GetType() != base::Value::TYPE_STRING) 406 if (channel_id_value->GetType() != base::Value::TYPE_STRING)
403 return false; 407 return false;
404 408
405 StringValue* channel_id = static_cast<StringValue*>(channel_id_value); 409 StringValue* channel_id = static_cast<StringValue*>(channel_id_value);
406 channel_id->GetAsString(result); 410 channel_id->GetAsString(result);
407 return true; 411 return true;
408 } 412 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698