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

Side by Side Diff: third_party/WebKit/Source/platform/network/ResourceRequest.cpp

Issue 2264503002: Clean up SecurityOrigin handling around CrossOriginAccessControl::handleRedirect() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 3 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
« no previous file with comments | « third_party/WebKit/Source/platform/network/ResourceRequest.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
3 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. 3 * Copyright (C) 2009, 2012 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 m_didSetHTTPReferrer = true; 246 m_didSetHTTPReferrer = true;
247 } 247 }
248 248
249 void ResourceRequest::clearHTTPReferrer() 249 void ResourceRequest::clearHTTPReferrer()
250 { 250 {
251 m_httpHeaderFields.remove(HTTPNames::Referer); 251 m_httpHeaderFields.remove(HTTPNames::Referer);
252 m_referrerPolicy = ReferrerPolicyDefault; 252 m_referrerPolicy = ReferrerPolicyDefault;
253 m_didSetHTTPReferrer = false; 253 m_didSetHTTPReferrer = false;
254 } 254 }
255 255
256 void ResourceRequest::setHTTPOrigin(PassRefPtr<SecurityOrigin> origin) 256 void ResourceRequest::setHTTPOrigin(const SecurityOrigin* origin)
257 { 257 {
258 setHTTPHeaderField(HTTPNames::Origin, origin->toAtomicString()); 258 setHTTPHeaderField(HTTPNames::Origin, origin->toAtomicString());
259 if (origin->hasSuborigin()) 259 if (origin->hasSuborigin())
260 setHTTPHeaderField(HTTPNames::Suborigin, AtomicString(origin->suborigin( )->name())); 260 setHTTPHeaderField(HTTPNames::Suborigin, AtomicString(origin->suborigin( )->name()));
261 } 261 }
262 262
263 void ResourceRequest::clearHTTPOrigin() 263 void ResourceRequest::clearHTTPOrigin()
264 { 264 {
265 m_httpHeaderFields.remove(HTTPNames::Origin); 265 m_httpHeaderFields.remove(HTTPNames::Origin);
266 m_httpHeaderFields.remove(HTTPNames::Suborigin); 266 m_httpHeaderFields.remove(HTTPNames::Suborigin);
267 } 267 }
268 268
269 void ResourceRequest::addHTTPOriginIfNeeded(PassRefPtr<SecurityOrigin> origin) 269 void ResourceRequest::addHTTPOriginIfNeeded(const SecurityOrigin* origin)
270 { 270 {
271 if (!httpOrigin().isEmpty()) 271 if (!httpOrigin().isEmpty())
272 return; // Request already has an Origin header. 272 return; // Request already has an Origin header.
273 273
274 // Don't send an Origin header for GET or HEAD to avoid privacy issues. 274 // Don't send an Origin header for GET or HEAD to avoid privacy issues.
275 // For example, if an intranet page has a hyperlink to an external web 275 // For example, if an intranet page has a hyperlink to an external web
276 // site, we don't want to include the Origin of the request because it 276 // site, we don't want to include the Origin of the request because it
277 // will leak the internal host name. Similar privacy concerns have lead 277 // will leak the internal host name. Similar privacy concerns have lead
278 // to the widespread suppression of the Referer header at the network 278 // to the widespread suppression of the Referer header at the network
279 // layer. 279 // layer.
280 if (httpMethod() == HTTPNames::GET || httpMethod() == HTTPNames::HEAD) 280 if (httpMethod() == HTTPNames::GET || httpMethod() == HTTPNames::HEAD)
281 return; 281 return;
282 282
283 // For non-GET and non-HEAD methods, always send an Origin header so the 283 // For non-GET and non-HEAD methods, always send an Origin header so the
284 // server knows we support this feature. 284 // server knows we support this feature.
285 285
286 AtomicString originString = origin->toAtomicString(); 286 AtomicString originString = origin->toAtomicString();
287 if (originString.isEmpty()) { 287 if (originString.isEmpty()) {
288 // If we don't know what origin header to attach, we attach the value 288 // If we don't know what origin header to attach, we attach the value
289 // for an empty origin. 289 // for an empty origin.
290 setHTTPOrigin(SecurityOrigin::createUnique()); 290 setHTTPOrigin(SecurityOrigin::createUnique().get());
291 return; 291 return;
292 } 292 }
293 setHTTPOrigin(origin); 293 setHTTPOrigin(origin);
294 } 294 }
295 295
296 void ResourceRequest::clearHTTPUserAgent() 296 void ResourceRequest::clearHTTPUserAgent()
297 { 297 {
298 m_httpHeaderFields.remove(HTTPNames::User_Agent); 298 m_httpHeaderFields.remove(HTTPNames::User_Agent);
299 } 299 }
300 300
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 m_didSetHTTPReferrer = false; 445 m_didSetHTTPReferrer = false;
446 m_checkForBrowserSideNavigation = true; 446 m_checkForBrowserSideNavigation = true;
447 m_uiStartTime = 0; 447 m_uiStartTime = 0;
448 m_isExternalRequest = false; 448 m_isExternalRequest = false;
449 m_inputPerfMetricReportPolicy = InputToLoadPerfMetricReportPolicy::NoReport; 449 m_inputPerfMetricReportPolicy = InputToLoadPerfMetricReportPolicy::NoReport;
450 m_redirectStatus = RedirectStatus::NoRedirect; 450 m_redirectStatus = RedirectStatus::NoRedirect;
451 m_requestorOrigin = SecurityOrigin::createUnique(); 451 m_requestorOrigin = SecurityOrigin::createUnique();
452 } 452 }
453 453
454 } // namespace blink 454 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/network/ResourceRequest.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698