Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: crash when unloading some WebViews #40444

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 7 additions & 8 deletions shell/browser/web_view_guest_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ void WebViewGuestDelegate::AttachToIframe(

content::WebContents* guest_web_contents = api_web_contents_->web_contents();

// Force a refresh of the webPreferences so that OverrideWebkitPrefs runs on
// the new web contents before the renderer process initializes.
// guest_web_contents->NotifyPreferencesChanged();

// Attach this inner WebContents |guest_web_contents| to the outer
// WebContents |embedder_web_contents|. The outer WebContents's
// frame |embedder_frame| hosts the inner WebContents.
Expand Down Expand Up @@ -76,15 +72,18 @@ content::WebContents* WebViewGuestDelegate::GetOwnerWebContents() {
void WebViewGuestDelegate::OnZoomChanged(
const WebContentsZoomController::ZoomChangedEventData& data) {
if (data.web_contents == GetOwnerWebContents()) {
auto* zoom_controller = api_web_contents_->GetZoomController();
if (data.temporary) {
api_web_contents_->GetZoomController()->SetTemporaryZoomLevel(
data.new_zoom_level);
zoom_controller->SetTemporaryZoomLevel(data.new_zoom_level);
} else {
api_web_contents_->GetZoomController()->SetZoomLevel(data.new_zoom_level);
if (blink::PageZoomValuesEqual(data.new_zoom_level,
zoom_controller->GetZoomLevel()))
return;
zoom_controller->SetZoomLevel(data.new_zoom_level);
}
// Change the default zoom factor to match the embedders' new zoom level.
double zoom_factor = blink::PageZoomLevelToZoomFactor(data.new_zoom_level);
api_web_contents_->GetZoomController()->SetDefaultZoomFactor(zoom_factor);
zoom_controller->SetDefaultZoomFactor(zoom_factor);
}
}

Expand Down