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.

(cherry picked from commit 3f3ab39)
  • Loading branch information
ckerr authored and jkleinsc committed May 18, 2023
1 parent bd7dd69 commit c7cdb59
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 @@ -37,6 +37,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 @@ -55,6 +57,8 @@ class WebViewGuestDelegate : public content::BrowserPluginGuestDelegate,
WebContentsZoomController* embedder_zoom_controller_ = nullptr;

api::WebContents* api_web_contents_ = nullptr;

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

} // namespace electron
Expand Down

0 comments on commit c7cdb59

Please sign in to comment.