Skip to content

Commit

Permalink
refactor: add WebViewGuestDelegate::GetGuestDelegateWeakPtr()
Browse files Browse the repository at this point in the history
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4515455

This approach copied from GuestViewBase::GetGuestDelegateWeakPtr() approach in that same commit.
  • Loading branch information
ckerr committed May 16, 2023
1 parent 9b53f3c commit 3f3ab39
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions shell/browser/web_view_guest_delegate.cc
Expand Up @@ -124,4 +124,9 @@ WebViewGuestDelegate::CreateNewGuestWindow(
return guest_contents;
}

base::WeakPtr<content::BrowserPluginGuestDelegate>
WebViewGuestDelegate::GetGuestDelegateWeakPtr() {
return weak_ptr_factory_.GetWeakPtr();
}

} // namespace electron
4 changes: 4 additions & 0 deletions shell/browser/web_view_guest_delegate.h
Expand Up @@ -38,6 +38,8 @@ class WebViewGuestDelegate : public content::BrowserPluginGuestDelegate,
content::WebContents* GetOwnerWebContents() final;
std::unique_ptr<content::WebContents> CreateNewGuestWindow(
const content::WebContents::CreateParams& create_params) final;
base::WeakPtr<content::BrowserPluginGuestDelegate> GetGuestDelegateWeakPtr()
final;

// WebContentsZoomController::Observer:
void OnZoomLevelChanged(content::WebContents* web_contents,
Expand All @@ -56,6 +58,8 @@ class WebViewGuestDelegate : public content::BrowserPluginGuestDelegate,
raw_ptr<WebContentsZoomController> embedder_zoom_controller_ = nullptr;

raw_ptr<api::WebContents> api_web_contents_ = nullptr;

base::WeakPtrFactory<WebViewGuestDelegate> weak_ptr_factory_{this};
};

} // namespace electron
Expand Down

0 comments on commit 3f3ab39

Please sign in to comment.