chore: bump chromium to f5b345dd470f14eef6e44732ccf23 (master) (#20649)
This commit is contained in:
parent
fb8b1fd1c9
commit
b6246dcf12
154 changed files with 1490 additions and 1197 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <utility>
|
||||
|
||||
#include "content/public/browser/browser_context.h"
|
||||
#include "extensions/browser/extension_navigation_ui_data.h"
|
||||
#include "mojo/public/cpp/bindings/binding.h"
|
||||
#include "net/base/completion_repeating_callback.h"
|
||||
|
@ -46,6 +47,7 @@ ProxyingURLLoaderFactory::InProgressRequest::InProgressRequest(
|
|||
traffic_annotation_(traffic_annotation),
|
||||
proxied_loader_binding_(this, std::move(loader_request)),
|
||||
target_client_(std::move(client)),
|
||||
current_response_(network::mojom::URLResponseHead::New()),
|
||||
proxied_client_binding_(this),
|
||||
// TODO(zcbenz): We should always use "extraHeaders" mode to be compatible
|
||||
// with old APIs.
|
||||
|
@ -192,12 +194,12 @@ void ProxyingURLLoaderFactory::InProgressRequest::OnReceiveResponse(
|
|||
if (current_request_uses_header_client_) {
|
||||
// Use the headers we got from OnHeadersReceived as that'll contain
|
||||
// Set-Cookie if it existed.
|
||||
auto saved_headers = current_response_.headers;
|
||||
current_response_ = head;
|
||||
current_response_.headers = saved_headers;
|
||||
auto saved_headers = current_response_->headers;
|
||||
current_response_ = std::move(head);
|
||||
current_response_->headers = saved_headers;
|
||||
ContinueToResponseStarted(net::OK);
|
||||
} else {
|
||||
current_response_ = head;
|
||||
current_response_ = std::move(head);
|
||||
HandleResponseOrRedirectHeaders(
|
||||
base::BindOnce(&InProgressRequest::ContinueToResponseStarted,
|
||||
weak_factory_.GetWeakPtr()));
|
||||
|
@ -212,16 +214,16 @@ void ProxyingURLLoaderFactory::InProgressRequest::OnReceiveRedirect(
|
|||
if (current_request_uses_header_client_) {
|
||||
// Use the headers we got from OnHeadersReceived as that'll contain
|
||||
// Set-Cookie if it existed.
|
||||
auto saved_headers = current_response_.headers;
|
||||
current_response_ = head;
|
||||
auto saved_headers = current_response_->headers;
|
||||
current_response_ = std::move(head);
|
||||
// If this redirect is from an HSTS upgrade, OnHeadersReceived will not be
|
||||
// called before OnReceiveRedirect, so make sure the saved headers exist
|
||||
// before setting them.
|
||||
if (saved_headers)
|
||||
current_response_.headers = saved_headers;
|
||||
current_response_->headers = saved_headers;
|
||||
ContinueToBeforeRedirect(redirect_info, net::OK);
|
||||
} else {
|
||||
current_response_ = head;
|
||||
current_response_ = std::move(head);
|
||||
HandleResponseOrRedirectHeaders(
|
||||
base::BindOnce(&InProgressRequest::ContinueToBeforeRedirect,
|
||||
weak_factory_.GetWeakPtr(), redirect_info));
|
||||
|
@ -286,6 +288,7 @@ void ProxyingURLLoaderFactory::InProgressRequest::OnBeforeSendHeaders(
|
|||
|
||||
void ProxyingURLLoaderFactory::InProgressRequest::OnHeadersReceived(
|
||||
const std::string& headers,
|
||||
const net::IPEndPoint& endpoint,
|
||||
OnHeadersReceivedCallback callback) {
|
||||
if (!current_request_uses_header_client_) {
|
||||
std::move(callback).Run(net::OK, base::nullopt, GURL());
|
||||
|
@ -293,7 +296,8 @@ void ProxyingURLLoaderFactory::InProgressRequest::OnHeadersReceived(
|
|||
}
|
||||
|
||||
on_headers_received_callback_ = std::move(callback);
|
||||
current_response_.headers =
|
||||
current_response_ = network::mojom::URLResponseHead::New();
|
||||
current_response_->headers =
|
||||
base::MakeRefCounted<net::HttpResponseHeaders>(headers);
|
||||
HandleResponseOrRedirectHeaders(
|
||||
base::BindOnce(&InProgressRequest::ContinueToHandleOverrideHeaders,
|
||||
|
@ -447,7 +451,7 @@ void ProxyingURLLoaderFactory::InProgressRequest::
|
|||
// Make sure to update current_response_, since when OnReceiveResponse
|
||||
// is called we will not use its headers as it might be missing the
|
||||
// Set-Cookie line (as that gets stripped over IPC).
|
||||
current_response_.headers = override_headers_;
|
||||
current_response_->headers = override_headers_;
|
||||
}
|
||||
}
|
||||
std::move(on_headers_received_callback_).Run(net::OK, headers, redirect_url_);
|
||||
|
@ -466,7 +470,7 @@ void ProxyingURLLoaderFactory::InProgressRequest::ContinueToResponseStarted(
|
|||
|
||||
DCHECK(!current_request_uses_header_client_ || !override_headers_);
|
||||
if (override_headers_)
|
||||
current_response_.headers = override_headers_;
|
||||
current_response_->headers = override_headers_;
|
||||
|
||||
std::string redirect_location;
|
||||
if (override_headers_ && override_headers_->IsRedirect(&redirect_location)) {
|
||||
|
@ -496,12 +500,12 @@ void ProxyingURLLoaderFactory::InProgressRequest::ContinueToResponseStarted(
|
|||
return;
|
||||
}
|
||||
|
||||
info_->AddResponseInfoFromResourceResponse(current_response_);
|
||||
info_->AddResponseInfoFromResourceResponse(*current_response_);
|
||||
|
||||
proxied_client_binding_.ResumeIncomingMethodCallProcessing();
|
||||
|
||||
factory_->web_request_api()->OnResponseStarted(&info_.value(), request_);
|
||||
target_client_->OnReceiveResponse(current_response_);
|
||||
target_client_->OnReceiveResponse(std::move(current_response_));
|
||||
}
|
||||
|
||||
void ProxyingURLLoaderFactory::InProgressRequest::ContinueToBeforeRedirect(
|
||||
|
@ -512,14 +516,15 @@ void ProxyingURLLoaderFactory::InProgressRequest::ContinueToBeforeRedirect(
|
|||
return;
|
||||
}
|
||||
|
||||
info_->AddResponseInfoFromResourceResponse(current_response_);
|
||||
info_->AddResponseInfoFromResourceResponse(*current_response_);
|
||||
|
||||
if (proxied_client_binding_.is_bound())
|
||||
proxied_client_binding_.ResumeIncomingMethodCallProcessing();
|
||||
|
||||
factory_->web_request_api()->OnBeforeRedirect(&info_.value(), request_,
|
||||
redirect_info.new_url);
|
||||
target_client_->OnReceiveRedirect(redirect_info, current_response_);
|
||||
target_client_->OnReceiveRedirect(redirect_info,
|
||||
std::move(current_response_));
|
||||
request_.url = redirect_info.new_url;
|
||||
request_.method = redirect_info.new_method;
|
||||
request_.site_for_cookies = redirect_info.new_site_for_cookies;
|
||||
|
@ -557,14 +562,14 @@ void ProxyingURLLoaderFactory::InProgressRequest::
|
|||
redirect_info.new_url = redirect_url_;
|
||||
redirect_info.new_site_for_cookies = redirect_url_;
|
||||
|
||||
network::ResourceResponseHead head;
|
||||
auto head = network::mojom::URLResponseHead::New();
|
||||
std::string headers = base::StringPrintf(
|
||||
"HTTP/1.1 %i Internal Redirect\n"
|
||||
"Location: %s\n"
|
||||
"Non-Authoritative-Reason: WebRequest API\n\n",
|
||||
kInternalRedirectStatusCode, redirect_url_.spec().c_str());
|
||||
|
||||
if (network::features::ShouldEnableOutOfBlinkCors()) {
|
||||
if (factory_->browser_context_->ShouldEnableOutOfBlinkCors()) {
|
||||
// Cross-origin requests need to modify the Origin header to 'null'. Since
|
||||
// CorsURLLoader sets |request_initiator| to the Origin request header in
|
||||
// NetworkService, we need to modify |request_initiator| here to craft the
|
||||
|
@ -595,11 +600,11 @@ void ProxyingURLLoaderFactory::InProgressRequest::
|
|||
http_origin.c_str());
|
||||
}
|
||||
}
|
||||
head.headers = base::MakeRefCounted<net::HttpResponseHeaders>(
|
||||
head->headers = base::MakeRefCounted<net::HttpResponseHeaders>(
|
||||
net::HttpUtil::AssembleRawHeaders(headers));
|
||||
head.encoded_data_length = 0;
|
||||
head->encoded_data_length = 0;
|
||||
|
||||
current_response_ = head;
|
||||
current_response_ = std::move(head);
|
||||
ContinueToBeforeRedirect(redirect_info, net::OK);
|
||||
}
|
||||
|
||||
|
@ -608,14 +613,14 @@ void ProxyingURLLoaderFactory::InProgressRequest::
|
|||
override_headers_ = nullptr;
|
||||
redirect_url_ = GURL();
|
||||
|
||||
info_->AddResponseInfoFromResourceResponse(current_response_);
|
||||
info_->AddResponseInfoFromResourceResponse(*current_response_);
|
||||
|
||||
net::CompletionRepeatingCallback copyable_callback =
|
||||
base::AdaptCallbackForRepeating(std::move(continuation));
|
||||
DCHECK(info_.has_value());
|
||||
int result = factory_->web_request_api()->OnHeadersReceived(
|
||||
&info_.value(), request_, copyable_callback,
|
||||
current_response_.headers.get(), &override_headers_, &redirect_url_);
|
||||
current_response_->headers.get(), &override_headers_, &redirect_url_);
|
||||
if (result == net::ERR_BLOCKED_BY_CLIENT) {
|
||||
OnRequestError(network::URLLoaderCompletionStatus(result));
|
||||
return;
|
||||
|
@ -651,21 +656,23 @@ void ProxyingURLLoaderFactory::InProgressRequest::OnRequestError(
|
|||
ProxyingURLLoaderFactory::ProxyingURLLoaderFactory(
|
||||
WebRequestAPI* web_request_api,
|
||||
const HandlersMap& intercepted_handlers,
|
||||
content::BrowserContext* browser_context,
|
||||
int render_process_id,
|
||||
network::mojom::URLLoaderFactoryRequest loader_request,
|
||||
network::mojom::URLLoaderFactoryPtrInfo target_factory_info,
|
||||
mojo::PendingRemote<network::mojom::URLLoaderFactory> target_factory_remote,
|
||||
mojo::PendingReceiver<network::mojom::TrustedURLLoaderHeaderClient>
|
||||
header_client_receiver,
|
||||
content::ContentBrowserClient::URLLoaderFactoryType loader_factory_type)
|
||||
: web_request_api_(web_request_api),
|
||||
intercepted_handlers_(intercepted_handlers),
|
||||
browser_context_(browser_context),
|
||||
render_process_id_(render_process_id),
|
||||
loader_factory_type_(loader_factory_type) {
|
||||
target_factory_.Bind(std::move(target_factory_info));
|
||||
target_factory_.set_connection_error_handler(base::BindOnce(
|
||||
target_factory_.Bind(std::move(target_factory_remote));
|
||||
target_factory_.set_disconnect_handler(base::BindOnce(
|
||||
&ProxyingURLLoaderFactory::OnTargetFactoryError, base::Unretained(this)));
|
||||
proxy_bindings_.AddBinding(this, std::move(loader_request));
|
||||
proxy_bindings_.set_connection_error_handler(base::BindRepeating(
|
||||
proxy_receivers_.Add(this, std::move(loader_request));
|
||||
proxy_receivers_.set_disconnect_handler(base::BindRepeating(
|
||||
&ProxyingURLLoaderFactory::OnProxyBindingError, base::Unretained(this)));
|
||||
|
||||
if (header_client_receiver)
|
||||
|
@ -727,8 +734,8 @@ void ProxyingURLLoaderFactory::CreateLoaderAndStart(
|
|||
}
|
||||
|
||||
void ProxyingURLLoaderFactory::Clone(
|
||||
network::mojom::URLLoaderFactoryRequest loader_request) {
|
||||
proxy_bindings_.AddBinding(this, std::move(loader_request));
|
||||
mojo::PendingReceiver<network::mojom::URLLoaderFactory> loader_receiver) {
|
||||
proxy_receivers_.Add(this, std::move(loader_receiver));
|
||||
}
|
||||
|
||||
void ProxyingURLLoaderFactory::OnLoaderCreated(
|
||||
|
@ -750,13 +757,13 @@ bool ProxyingURLLoaderFactory::IsForServiceWorkerScript() const {
|
|||
|
||||
void ProxyingURLLoaderFactory::OnTargetFactoryError() {
|
||||
target_factory_.reset();
|
||||
proxy_bindings_.CloseAllBindings();
|
||||
proxy_receivers_.Clear();
|
||||
|
||||
MaybeDeleteThis();
|
||||
}
|
||||
|
||||
void ProxyingURLLoaderFactory::OnProxyBindingError() {
|
||||
if (proxy_bindings_.empty())
|
||||
if (proxy_receivers_.empty())
|
||||
target_factory_.reset();
|
||||
|
||||
MaybeDeleteThis();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue