Skip to content

Commit a77f2e0

Browse files
fix: crash when unloading some WebViews (electron#40445)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
1 parent f739cb1 commit a77f2e0

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

shell/browser/web_view_guest_delegate.cc

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ void WebViewGuestDelegate::AttachToIframe(
4040

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

43-
// Force a refresh of the webPreferences so that OverrideWebkitPrefs runs on
44-
// the new web contents before the renderer process initializes.
45-
// guest_web_contents->NotifyPreferencesChanged();
46-
4743
// Attach this inner WebContents |guest_web_contents| to the outer
4844
// WebContents |embedder_web_contents|. The outer WebContents's
4945
// frame |embedder_frame| hosts the inner WebContents.
@@ -76,15 +72,18 @@ content::WebContents* WebViewGuestDelegate::GetOwnerWebContents() {
7672
void WebViewGuestDelegate::OnZoomChanged(
7773
const WebContentsZoomController::ZoomChangedEventData& data) {
7874
if (data.web_contents == GetOwnerWebContents()) {
75+
auto* zoom_controller = api_web_contents_->GetZoomController();
7976
if (data.temporary) {
80-
api_web_contents_->GetZoomController()->SetTemporaryZoomLevel(
81-
data.new_zoom_level);
77+
zoom_controller->SetTemporaryZoomLevel(data.new_zoom_level);
8278
} else {
83-
api_web_contents_->GetZoomController()->SetZoomLevel(data.new_zoom_level);
79+
if (blink::PageZoomValuesEqual(data.new_zoom_level,
80+
zoom_controller->GetZoomLevel()))
81+
return;
82+
zoom_controller->SetZoomLevel(data.new_zoom_level);
8483
}
8584
// Change the default zoom factor to match the embedders' new zoom level.
8685
double zoom_factor = blink::PageZoomLevelToZoomFactor(data.new_zoom_level);
87-
api_web_contents_->GetZoomController()->SetDefaultZoomFactor(zoom_factor);
86+
zoom_controller->SetDefaultZoomFactor(zoom_factor);
8887
}
8988
}
9089

0 commit comments

Comments
 (0)