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.
|
|
|
|
|
2019-06-19 20:56:58 +00:00
|
|
|
#ifndef SHELL_BROWSER_WEB_VIEW_GUEST_DELEGATE_H_
|
|
|
|
#define SHELL_BROWSER_WEB_VIEW_GUEST_DELEGATE_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"
|
2015-06-25 06:28:13 +00:00
|
|
|
|
2019-06-19 21:23:04 +00:00
|
|
|
namespace electron {
|
2015-06-25 06:28:13 +00:00
|
|
|
|
|
|
|
namespace api {
|
|
|
|
class WebContents;
|
|
|
|
}
|
|
|
|
|
|
|
|
class WebViewGuestDelegate : public content::BrowserPluginGuestDelegate,
|
2017-01-30 11:18:40 +00:00
|
|
|
public WebContentsZoomController::Observer {
|
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;
|
2017-05-23 20:26:19 +00:00
|
|
|
content::WebContents* CreateNewGuestWindow(
|
2018-08-16 22:57:40 +00:00
|
|
|
const content::WebContents::CreateParams& create_params) final;
|
2015-06-25 06:28:13 +00:00
|
|
|
|
2017-01-30 11:18:40 +00:00
|
|
|
// WebContentsZoomController::Observer:
|
|
|
|
void OnZoomLevelChanged(content::WebContents* web_contents,
|
2017-01-30 17:06:50 +00:00
|
|
|
double level,
|
|
|
|
bool is_temporary) override;
|
2018-08-16 22:57:40 +00:00
|
|
|
void OnZoomControllerWebContentsDestroyed() 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.
|
2017-10-11 08:14:03 +00:00
|
|
|
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.
|
2018-05-21 22:18:38 +00:00
|
|
|
WebContentsZoomController* embedder_zoom_controller_ = nullptr;
|
2017-01-30 11:18:40 +00:00
|
|
|
|
2018-05-21 22:18:38 +00:00
|
|
|
api::WebContents* api_web_contents_ = nullptr;
|
2015-06-25 06:28:13 +00:00
|
|
|
};
|
|
|
|
|
2019-06-19 21:23:04 +00:00
|
|
|
} // namespace electron
|
2015-06-25 06:28:13 +00:00
|
|
|
|
2019-06-19 20:56:58 +00:00
|
|
|
#endif // SHELL_BROWSER_WEB_VIEW_GUEST_DELEGATE_H_
|