2015-06-25 06:28:13 +00:00
|
|
|
// Copyright (c) 2015 GitHub, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#ifndef ELECTRON_SHELL_BROWSER_WEB_VIEW_GUEST_DELEGATE_H_
|
|
|
|
#define ELECTRON_SHELL_BROWSER_WEB_VIEW_GUEST_DELEGATE_H_
|
2015-06-25 06:28:13 +00:00
|
|
|
|
2022-09-07 07:46:37 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2023-05-11 20:07:39 +00:00
|
|
|
#include "base/memory/raw_ptr.h"
|
2015-06-25 06:28:13 +00:00
|
|
|
#include "content/public/browser/browser_plugin_guest_delegate.h"
|
2019-06-19 20:46:59 +00:00
|
|
|
#include "shell/browser/web_contents_zoom_controller.h"
|
2023-08-15 01:33:30 +00:00
|
|
|
#include "shell/browser/web_contents_zoom_observer.h"
|
2015-06-25 06:28:13 +00:00
|
|
|
|
|
|
|
namespace electron {
|
|
|
|
|
|
|
|
namespace api {
|
|
|
|
class WebContents;
|
|
|
|
}
|
|
|
|
|
|
|
|
class WebViewGuestDelegate : public content::BrowserPluginGuestDelegate,
|
2024-05-21 19:21:31 +00:00
|
|
|
private WebContentsZoomObserver {
|
2015-06-25 06:28:13 +00:00
|
|
|
public:
|
2018-08-16 22:57:40 +00:00
|
|
|
WebViewGuestDelegate(content::WebContents* embedder,
|
|
|
|
api::WebContents* api_web_contents);
|
2015-06-25 06:28:13 +00:00
|
|
|
~WebViewGuestDelegate() override;
|
|
|
|
|
2021-11-03 11:41:45 +00:00
|
|
|
// disable copy
|
|
|
|
WebViewGuestDelegate(const WebViewGuestDelegate&) = delete;
|
|
|
|
WebViewGuestDelegate& operator=(const WebViewGuestDelegate&) = delete;
|
|
|
|
|
2018-08-16 22:57:40 +00:00
|
|
|
// Attach to the iframe.
|
|
|
|
void AttachToIframe(content::WebContents* embedder_web_contents,
|
|
|
|
int embedder_frame_id);
|
2020-07-28 20:00:44 +00:00
|
|
|
void WillDestroy();
|
2017-06-21 12:17:27 +00:00
|
|
|
|
2015-06-25 06:28:13 +00:00
|
|
|
protected:
|
|
|
|
// content::BrowserPluginGuestDelegate:
|
2019-07-03 01:22:09 +00:00
|
|
|
content::WebContents* GetOwnerWebContents() final;
|
2022-09-07 07:46:37 +00:00
|
|
|
std::unique_ptr<content::WebContents> CreateNewGuestWindow(
|
2018-08-16 22:57:40 +00:00
|
|
|
const content::WebContents::CreateParams& create_params) final;
|
2023-05-23 19:58:58 +00:00
|
|
|
base::WeakPtr<content::BrowserPluginGuestDelegate> GetGuestDelegateWeakPtr()
|
|
|
|
final;
|
2015-06-25 06:28:13 +00:00
|
|
|
|
2023-08-15 01:33:30 +00:00
|
|
|
// WebContentsZoomObserver:
|
|
|
|
void OnZoomControllerDestroyed(
|
|
|
|
WebContentsZoomController* zoom_controller) override;
|
|
|
|
void OnZoomChanged(
|
|
|
|
const WebContentsZoomController::ZoomChangedEventData& data) override;
|
2017-01-30 11:18:40 +00:00
|
|
|
|
2015-06-25 06:28:13 +00:00
|
|
|
private:
|
2017-11-30 15:09:05 +00:00
|
|
|
void ResetZoomController();
|
|
|
|
|
2015-06-25 06:28:13 +00:00
|
|
|
// The WebContents that attaches this guest view.
|
2023-05-11 20:07:39 +00:00
|
|
|
raw_ptr<content::WebContents> embedder_web_contents_ = nullptr;
|
2015-06-25 06:28:13 +00:00
|
|
|
|
2017-01-30 11:18:40 +00:00
|
|
|
// The zoom controller of the embedder that is used
|
|
|
|
// to subscribe for zoom changes.
|
2023-05-11 20:07:39 +00:00
|
|
|
raw_ptr<WebContentsZoomController> embedder_zoom_controller_ = nullptr;
|
2017-01-30 11:18:40 +00:00
|
|
|
|
2023-05-11 20:07:39 +00:00
|
|
|
raw_ptr<api::WebContents> api_web_contents_ = nullptr;
|
2023-05-23 19:58:58 +00:00
|
|
|
|
|
|
|
base::WeakPtrFactory<WebViewGuestDelegate> weak_ptr_factory_{this};
|
2015-06-25 06:28:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace electron
|
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#endif // ELECTRON_SHELL_BROWSER_WEB_VIEW_GUEST_DELEGATE_H_
|