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

Side by Side Diff: net/url_request/url_request_http_job.cc

Issue 2254693002: Delay generation of User-Agent header to URLRequestHttpJob and accept custom User-Agent from XHR/Fe… Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changed Android test 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
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 "net/url_request/url_request_http_job.h" 5 #include "net/url_request/url_request_http_job.h"
6 6
7 #include "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 380
381 // Our consumer should have made sure that this is a safe referrer. See for 381 // Our consumer should have made sure that this is a safe referrer. See for
382 // instance WebCore::FrameLoader::HideReferrer. 382 // instance WebCore::FrameLoader::HideReferrer.
383 if (referrer.is_valid()) { 383 if (referrer.is_valid()) {
384 request_info_.extra_headers.SetHeader(HttpRequestHeaders::kReferer, 384 request_info_.extra_headers.SetHeader(HttpRequestHeaders::kReferer,
385 referrer.spec()); 385 referrer.spec());
386 } 386 }
387 387
388 request_info_.token_binding_referrer = request_->token_binding_referrer(); 388 request_info_.token_binding_referrer = request_->token_binding_referrer();
389 389
390 if (request_->has_default_user_agent()) {
391 request_info_.extra_headers.SetHeaderIfMissing(
392 HttpRequestHeaders::kUserAgent, request_->default_user_agent());
393 }
394
390 request_info_.extra_headers.SetHeaderIfMissing( 395 request_info_.extra_headers.SetHeaderIfMissing(
391 HttpRequestHeaders::kUserAgent, 396 HttpRequestHeaders::kUserAgent,
392 http_user_agent_settings_ ? 397 http_user_agent_settings_ ?
393 http_user_agent_settings_->GetUserAgent() : std::string()); 398 http_user_agent_settings_->GetUserAgent() : std::string());
394 399
395 AddExtraHeaders(); 400 AddExtraHeaders();
396 AddCookieHeaderAndStart(); 401 AddCookieHeaderAndStart();
397 } 402 }
398 403
399 void URLRequestHttpJob::Kill() { 404 void URLRequestHttpJob::Kill() {
(...skipping 1208 matching lines...) Expand 10 before | Expand all | Expand 10 after
1608 // Notify NetworkQualityEstimator. 1613 // Notify NetworkQualityEstimator.
1609 if (request()) { 1614 if (request()) {
1610 NetworkQualityEstimator* network_quality_estimator = 1615 NetworkQualityEstimator* network_quality_estimator =
1611 request()->context()->network_quality_estimator(); 1616 request()->context()->network_quality_estimator();
1612 if (network_quality_estimator) 1617 if (network_quality_estimator)
1613 network_quality_estimator->NotifyURLRequestDestroyed(*request()); 1618 network_quality_estimator->NotifyURLRequestDestroyed(*request());
1614 } 1619 }
1615 } 1620 }
1616 1621
1617 } // namespace net 1622 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698