fix: crash when doing redirect navigation with webRequest listener (#21838)
* fix: pass navigation_ui_data to proxying factory * fix: clone response instead of move in redirect
This commit is contained in:
parent
36fac7bfec
commit
fbc2f8344f
4 changed files with 33 additions and 6 deletions
|
@ -95,7 +95,9 @@ void ProxyingURLLoaderFactory::InProgressRequest::UpdateRequestInfo() {
|
|||
request_for_info.request_initiator = original_initiator_;
|
||||
info_.emplace(extensions::WebRequestInfoInitParams(
|
||||
request_id_, factory_->render_process_id_, request_.render_frame_id,
|
||||
nullptr, routing_id_, request_for_info, false,
|
||||
factory_->navigation_ui_data_ ? factory_->navigation_ui_data_->DeepCopy()
|
||||
: nullptr,
|
||||
routing_id_, request_for_info, false,
|
||||
!(options_ & network::mojom::kURLLoadOptionSynchronous),
|
||||
factory_->IsForServiceWorkerScript(), factory_->navigation_id_));
|
||||
|
||||
|
@ -304,7 +306,7 @@ void ProxyingURLLoaderFactory::InProgressRequest::OnBeforeSendHeaders(
|
|||
|
||||
void ProxyingURLLoaderFactory::InProgressRequest::OnHeadersReceived(
|
||||
const std::string& headers,
|
||||
const net::IPEndPoint& endpoint,
|
||||
const net::IPEndPoint& remote_endpoint,
|
||||
OnHeadersReceivedCallback callback) {
|
||||
if (!current_request_uses_header_client_) {
|
||||
std::move(callback).Run(net::OK, base::nullopt, GURL());
|
||||
|
@ -315,6 +317,7 @@ void ProxyingURLLoaderFactory::InProgressRequest::OnHeadersReceived(
|
|||
current_response_ = network::mojom::URLResponseHead::New();
|
||||
current_response_->headers =
|
||||
base::MakeRefCounted<net::HttpResponseHeaders>(headers);
|
||||
current_response_->remote_endpoint = remote_endpoint;
|
||||
HandleResponseOrRedirectHeaders(
|
||||
base::BindOnce(&InProgressRequest::ContinueToHandleOverrideHeaders,
|
||||
weak_factory_.GetWeakPtr()));
|
||||
|
@ -520,7 +523,7 @@ void ProxyingURLLoaderFactory::InProgressRequest::ContinueToResponseStarted(
|
|||
proxied_client_receiver_.Resume();
|
||||
|
||||
factory_->web_request_api()->OnResponseStarted(&info_.value(), request_);
|
||||
target_client_->OnReceiveResponse(std::move(current_response_));
|
||||
target_client_->OnReceiveResponse(current_response_.Clone());
|
||||
}
|
||||
|
||||
void ProxyingURLLoaderFactory::InProgressRequest::ContinueToBeforeRedirect(
|
||||
|
@ -538,8 +541,7 @@ void ProxyingURLLoaderFactory::InProgressRequest::ContinueToBeforeRedirect(
|
|||
|
||||
factory_->web_request_api()->OnBeforeRedirect(&info_.value(), request_,
|
||||
redirect_info.new_url);
|
||||
target_client_->OnReceiveRedirect(redirect_info,
|
||||
std::move(current_response_));
|
||||
target_client_->OnReceiveRedirect(redirect_info, current_response_.Clone());
|
||||
request_.url = redirect_info.new_url;
|
||||
request_.method = redirect_info.new_method;
|
||||
request_.site_for_cookies = redirect_info.new_site_for_cookies;
|
||||
|
@ -675,6 +677,7 @@ ProxyingURLLoaderFactory::ProxyingURLLoaderFactory(
|
|||
const HandlersMap& intercepted_handlers,
|
||||
content::BrowserContext* browser_context,
|
||||
int render_process_id,
|
||||
std::unique_ptr<extensions::ExtensionNavigationUIData> navigation_ui_data,
|
||||
base::Optional<int64_t> navigation_id,
|
||||
network::mojom::URLLoaderFactoryRequest loader_request,
|
||||
mojo::PendingRemote<network::mojom::URLLoaderFactory> target_factory_remote,
|
||||
|
@ -685,6 +688,7 @@ ProxyingURLLoaderFactory::ProxyingURLLoaderFactory(
|
|||
intercepted_handlers_(intercepted_handlers),
|
||||
browser_context_(browser_context),
|
||||
render_process_id_(render_process_id),
|
||||
navigation_ui_data_(std::move(navigation_ui_data)),
|
||||
navigation_id_(std::move(navigation_id)),
|
||||
loader_factory_type_(loader_factory_type) {
|
||||
target_factory_.Bind(std::move(target_factory_remote));
|
||||
|
|
|
@ -210,6 +210,7 @@ class ProxyingURLLoaderFactory
|
|||
const HandlersMap& intercepted_handlers,
|
||||
content::BrowserContext* browser_context,
|
||||
int render_process_id,
|
||||
std::unique_ptr<extensions::ExtensionNavigationUIData> navigation_ui_data,
|
||||
base::Optional<int64_t> navigation_id,
|
||||
network::mojom::URLLoaderFactoryRequest loader_request,
|
||||
mojo::PendingRemote<network::mojom::URLLoaderFactory>
|
||||
|
@ -268,6 +269,7 @@ class ProxyingURLLoaderFactory
|
|||
|
||||
content::BrowserContext* const browser_context_;
|
||||
const int render_process_id_;
|
||||
std::unique_ptr<extensions::ExtensionNavigationUIData> navigation_ui_data_;
|
||||
base::Optional<int64_t> navigation_id_;
|
||||
mojo::ReceiverSet<network::mojom::URLLoaderFactory> proxy_receivers_;
|
||||
mojo::Remote<network::mojom::URLLoaderFactory> target_factory_;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue