mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Include WebViewId
into EmbedderMsg variants where possible (#35211)
`EmbedderMsg` was previously paired with an implicit `Option<WebViewId>`, even though almost all variants were either always `Some` or always `None`, depending on whether there was a `WebView involved. This patch adds the `WebViewId` to as many `EmbedderMsg` variants as possible, so we can call their associated `WebView` delegate methods without needing to check and unwrap the `Option`. In many cases, this required more changes to plumb through the `WebViewId`. Notably, all `Request`s now explicitly need a `WebView` or not, in order to ensure that it is passed when appropriate. Signed-off-by: Delan Azabani <dazabani@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
9eeb602f7a
commit
5e9de2cb61
70 changed files with 809 additions and 753 deletions
|
@ -9,7 +9,7 @@ use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
|||
|
||||
use async_recursion::async_recursion;
|
||||
use base::cross_process_instant::CrossProcessInstant;
|
||||
use base::id::{HistoryStateId, PipelineId, TopLevelBrowsingContextId};
|
||||
use base::id::{HistoryStateId, PipelineId, WebViewId};
|
||||
use crossbeam_channel::Sender;
|
||||
use devtools_traits::{
|
||||
ChromeToDevtoolsControlMsg, DevtoolsControlMsg, HttpRequest as DevtoolsHttpRequest,
|
||||
|
@ -1583,10 +1583,12 @@ async fn http_network_or_cache_fetch(
|
|||
|
||||
// Step 14.3 If request’s use-URL-credentials flag is unset or isAuthenticationFetch is true, then:
|
||||
if !http_request.use_url_credentials || authentication_fetch_flag {
|
||||
let Some(credentials) = prompt_user_for_credentials(
|
||||
&context.state.embedder_proxy,
|
||||
http_request.target_browsing_context_id,
|
||||
) else {
|
||||
let Some(webview_id) = http_request.target_webview_id else {
|
||||
return response;
|
||||
};
|
||||
let Some(credentials) =
|
||||
prompt_user_for_credentials(&context.state.embedder_proxy, webview_id)
|
||||
else {
|
||||
return response;
|
||||
};
|
||||
let Some(username) = credentials.username else {
|
||||
|
@ -1639,10 +1641,12 @@ async fn http_network_or_cache_fetch(
|
|||
|
||||
// Step 15.4 Prompt the end user as appropriate in request’s window
|
||||
// window and store the result as a proxy-authentication entry.
|
||||
let Some(credentials) = prompt_user_for_credentials(
|
||||
&context.state.embedder_proxy,
|
||||
http_request.target_browsing_context_id,
|
||||
) else {
|
||||
let Some(webview_id) = http_request.target_webview_id else {
|
||||
return response;
|
||||
};
|
||||
let Some(credentials) =
|
||||
prompt_user_for_credentials(&context.state.embedder_proxy, webview_id)
|
||||
else {
|
||||
return response;
|
||||
};
|
||||
let Some(user_name) = credentials.username else {
|
||||
|
@ -1779,18 +1783,16 @@ impl Drop for ResponseEndTimer {
|
|||
|
||||
fn prompt_user_for_credentials(
|
||||
embedder_proxy: &Mutex<EmbedderProxy>,
|
||||
top_level_browsing_context_id: Option<TopLevelBrowsingContextId>,
|
||||
webview_id: WebViewId,
|
||||
) -> Option<PromptCredentialsInput> {
|
||||
let proxy = embedder_proxy.lock().unwrap();
|
||||
|
||||
let (ipc_sender, ipc_receiver) = ipc::channel().unwrap();
|
||||
|
||||
proxy.send((
|
||||
top_level_browsing_context_id,
|
||||
EmbedderMsg::Prompt(
|
||||
PromptDefinition::Credentials(ipc_sender),
|
||||
PromptOrigin::Trusted,
|
||||
),
|
||||
proxy.send(EmbedderMsg::Prompt(
|
||||
webview_id,
|
||||
PromptDefinition::Credentials(ipc_sender),
|
||||
PromptOrigin::Trusted,
|
||||
));
|
||||
|
||||
let Ok(credentials) = ipc_receiver.recv() else {
|
||||
|
@ -2100,21 +2102,25 @@ async fn cors_preflight_fetch(
|
|||
context: &FetchContext,
|
||||
) -> Response {
|
||||
// Step 1
|
||||
let mut preflight = RequestBuilder::new(request.current_url(), request.referrer.clone())
|
||||
.method(Method::OPTIONS)
|
||||
.origin(match &request.origin {
|
||||
Origin::Client => {
|
||||
unreachable!("We shouldn't get Client origin in cors_preflight_fetch.")
|
||||
},
|
||||
Origin::Origin(origin) => origin.clone(),
|
||||
})
|
||||
.pipeline_id(request.pipeline_id)
|
||||
.initiator(request.initiator)
|
||||
.destination(request.destination)
|
||||
.referrer_policy(request.referrer_policy)
|
||||
.mode(RequestMode::CorsMode)
|
||||
.response_tainting(ResponseTainting::CorsTainting)
|
||||
.build();
|
||||
let mut preflight = RequestBuilder::new(
|
||||
request.target_webview_id,
|
||||
request.current_url(),
|
||||
request.referrer.clone(),
|
||||
)
|
||||
.method(Method::OPTIONS)
|
||||
.origin(match &request.origin {
|
||||
Origin::Client => {
|
||||
unreachable!("We shouldn't get Client origin in cors_preflight_fetch.")
|
||||
},
|
||||
Origin::Origin(origin) => origin.clone(),
|
||||
})
|
||||
.pipeline_id(request.pipeline_id)
|
||||
.initiator(request.initiator)
|
||||
.destination(request.destination)
|
||||
.referrer_policy(request.referrer_policy)
|
||||
.mode(RequestMode::CorsMode)
|
||||
.response_tainting(ResponseTainting::CorsTainting)
|
||||
.build();
|
||||
|
||||
// Step 2
|
||||
preflight
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue