WebView: Ensure AwContentBrowserClient::HandleExternalProtocol is called on UI thread
Before this CL, AwContentBrowserClient::HandleExternalProtocol() assumed that it can be called from the IO thread, but actually this function is always called on the UI thread. This CL removes the unnecessary thread check from the function. Note that the class-level comment of ContentBrowserClient says: "The methods are assumed to be called on the UI thread unless otherwise specified.". The function-level comment of ContentBrowserClient::HandleExternalProtocol() doesn't mention the thread affinity, so it should be valid to assume that this function is always called on the UI thread. Bug: 373474043 Change-Id: Ie087abc4380a281335808902c5b1f075fae260ef Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5933488 Reviewed-by: Richard (Torne) Coles <torne@chromium.org> Commit-Queue: Richard (Torne) Coles <torne@chromium.org> Reviewed-by: Kouhei Ueno <kouhei@chromium.org> Auto-Submit: Hiroki Nakagawa <nhiroki@chromium.org> Cr-Commit-Position: refs/heads/main@{#1373324}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
4182adc432
commit
90ea55e4f9
@ -913,6 +913,8 @@ bool AwContentBrowserClient::HandleExternalProtocol(
|
||||
content::RenderFrameHost* initiator_document,
|
||||
const net::IsolationInfo& isolation_info,
|
||||
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory) {
|
||||
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
||||
|
||||
// Sandbox flags
|
||||
// =============
|
||||
//
|
||||
@ -947,39 +949,28 @@ bool AwContentBrowserClient::HandleExternalProtocol(
|
||||
// be schemes unrelated to the regular network stack so it doesn't make sense
|
||||
// to look for cookies. Providing a nullopt for the cookie manager lets
|
||||
// the AwProxyingURLLoaderFactory know to skip that work.
|
||||
if (content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)) {
|
||||
// Manages its own lifetime.
|
||||
new android_webview::AwProxyingURLLoaderFactory(
|
||||
std::nullopt /* cookie_manager */, nullptr /* cookie_access_policy */,
|
||||
isolation_info, web_contents_key, frame_tree_node_id,
|
||||
std::move(receiver), mojo::NullRemote(), true /* intercept_only */,
|
||||
std::nullopt /* security_options */,
|
||||
nullptr /* xrw_allowlist_matcher */, std::move(browser_context_handle),
|
||||
std::nullopt /* navigation_id */);
|
||||
} else {
|
||||
content::GetIOThreadTaskRunner({})->PostTask(
|
||||
FROM_HERE,
|
||||
base::BindOnce(
|
||||
[](mojo::PendingReceiver<network::mojom::URLLoaderFactory> receiver,
|
||||
std::optional<WebContentsKey> web_contents_key,
|
||||
content::FrameTreeNodeId frame_tree_node_id,
|
||||
scoped_refptr<AwBrowserContextIoThreadHandle>
|
||||
browser_context_handle,
|
||||
const net::IsolationInfo& isolation_info) {
|
||||
// Manages its own lifetime.
|
||||
new android_webview::AwProxyingURLLoaderFactory(
|
||||
std::nullopt /* cookie_manager */,
|
||||
nullptr /* cookie_access_policy */, isolation_info,
|
||||
web_contents_key, frame_tree_node_id, std::move(receiver),
|
||||
mojo::NullRemote(), true /* intercept_only */,
|
||||
std::nullopt /* security_options */,
|
||||
nullptr /* xrw_allowlist_matcher */,
|
||||
std::move(browser_context_handle),
|
||||
std::nullopt /* navigation_id */);
|
||||
},
|
||||
std::move(receiver), web_contents_key, frame_tree_node_id,
|
||||
std::move(browser_context_handle), isolation_info));
|
||||
}
|
||||
content::GetIOThreadTaskRunner({})->PostTask(
|
||||
FROM_HERE,
|
||||
base::BindOnce(
|
||||
[](mojo::PendingReceiver<network::mojom::URLLoaderFactory> receiver,
|
||||
std::optional<WebContentsKey> web_contents_key,
|
||||
content::FrameTreeNodeId frame_tree_node_id,
|
||||
scoped_refptr<AwBrowserContextIoThreadHandle>
|
||||
browser_context_handle,
|
||||
const net::IsolationInfo& isolation_info) {
|
||||
// Manages its own lifetime.
|
||||
new android_webview::AwProxyingURLLoaderFactory(
|
||||
std::nullopt /* cookie_manager */,
|
||||
nullptr /* cookie_access_policy */, isolation_info,
|
||||
web_contents_key, frame_tree_node_id, std::move(receiver),
|
||||
mojo::NullRemote(), true /* intercept_only */,
|
||||
std::nullopt /* security_options */,
|
||||
nullptr /* xrw_allowlist_matcher */,
|
||||
std::move(browser_context_handle),
|
||||
std::nullopt /* navigation_id */);
|
||||
},
|
||||
std::move(receiver), web_contents_key, frame_tree_node_id,
|
||||
std::move(browser_context_handle), isolation_info));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user