Files
electron/shell/browser/web_view_guest_delegate.h
electron-roller[bot] 31f5e3c356 chore: bump chromium to 112.0.5615.204 (24-x-y) (#38350)
* chore: bump chromium in DEPS to 112.0.5615.204

* chore: update patches

* refactor: add WebViewGuestDelegate::GetGuestDelegateWeakPtr()

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 3f3ab39e3a1077f71aa90319d7a81d53cfb3c55e)

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2023-05-18 12:15:10 -04:00

67 lines
2.1 KiB
C++

// Copyright (c) 2015 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ELECTRON_SHELL_BROWSER_WEB_VIEW_GUEST_DELEGATE_H_
#define ELECTRON_SHELL_BROWSER_WEB_VIEW_GUEST_DELEGATE_H_
#include <memory>
#include "content/public/browser/browser_plugin_guest_delegate.h"
#include "shell/browser/web_contents_zoom_controller.h"
namespace electron {
namespace api {
class WebContents;
}
class WebViewGuestDelegate : public content::BrowserPluginGuestDelegate,
public WebContentsZoomController::Observer {
public:
WebViewGuestDelegate(content::WebContents* embedder,
api::WebContents* api_web_contents);
~WebViewGuestDelegate() override;
// disable copy
WebViewGuestDelegate(const WebViewGuestDelegate&) = delete;
WebViewGuestDelegate& operator=(const WebViewGuestDelegate&) = delete;
// Attach to the iframe.
void AttachToIframe(content::WebContents* embedder_web_contents,
int embedder_frame_id);
void WillDestroy();
protected:
// 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,
double level,
bool is_temporary) override;
void OnZoomControllerWebContentsDestroyed() override;
private:
void ResetZoomController();
// The WebContents that attaches this guest view.
content::WebContents* embedder_web_contents_ = nullptr;
// The zoom controller of the embedder that is used
// to subscribe for zoom changes.
WebContentsZoomController* embedder_zoom_controller_ = nullptr;
api::WebContents* api_web_contents_ = nullptr;
base::WeakPtrFactory<WebViewGuestDelegate> weak_ptr_factory_{this};
};
} // namespace electron
#endif // ELECTRON_SHELL_BROWSER_WEB_VIEW_GUEST_DELEGATE_H_