2016-07-30 21:35:14 +02:00
|
|
|
// Copyright (c) 2016 GitHub, Inc.
|
2016-07-20 11:30:06 +02:00
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2021-11-22 08:34:31 +01:00
|
|
|
#ifndef ELECTRON_SHELL_BROWSER_OSR_OSR_WEB_CONTENTS_VIEW_H_
|
|
|
|
#define ELECTRON_SHELL_BROWSER_OSR_OSR_WEB_CONTENTS_VIEW_H_
|
2016-07-20 11:30:06 +02:00
|
|
|
|
2019-06-19 13:46:59 -07:00
|
|
|
#include "shell/browser/native_window.h"
|
|
|
|
#include "shell/browser/native_window_observer.h"
|
2018-11-29 21:25:02 -08:00
|
|
|
|
2019-04-17 23:10:04 +02:00
|
|
|
#include "content/browser/renderer_host/render_view_host_delegate_view.h" // nogncheck
|
|
|
|
#include "content/browser/web_contents/web_contents_view.h" // nogncheck
|
2016-07-27 14:36:22 +02:00
|
|
|
#include "content/public/browser/web_contents.h"
|
2019-06-19 13:46:59 -07:00
|
|
|
#include "shell/browser/osr/osr_render_widget_host_view.h"
|
2020-10-15 18:30:41 -07:00
|
|
|
#include "third_party/blink/public/common/page/drag_mojom_traits.h"
|
2016-07-20 11:30:06 +02:00
|
|
|
|
2022-02-09 18:58:52 -08:00
|
|
|
#if BUILDFLAG(IS_MAC)
|
2016-08-04 15:34:29 +09:00
|
|
|
#ifdef __OBJC__
|
|
|
|
@class OffScreenView;
|
|
|
|
#else
|
|
|
|
class OffScreenView;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2016-07-20 11:30:06 +02:00
|
|
|
namespace electron {
|
|
|
|
|
2016-07-25 15:55:00 +02:00
|
|
|
class OffScreenWebContentsView : public content::WebContentsView,
|
2018-11-29 21:25:02 -08:00
|
|
|
public content::RenderViewHostDelegateView,
|
|
|
|
public NativeWindowObserver {
|
2016-07-31 12:19:56 +02:00
|
|
|
public:
|
2016-08-04 13:03:24 +09:00
|
|
|
OffScreenWebContentsView(bool transparent, const OnPaintCallback& callback);
|
2018-05-03 23:45:12 -07:00
|
|
|
~OffScreenWebContentsView() override;
|
2016-07-29 14:50:27 +02:00
|
|
|
|
2016-07-27 14:36:22 +02:00
|
|
|
void SetWebContents(content::WebContents*);
|
2018-11-29 21:25:02 -08:00
|
|
|
void SetNativeWindow(NativeWindow* window);
|
|
|
|
|
|
|
|
// NativeWindowObserver:
|
|
|
|
void OnWindowResize() override;
|
|
|
|
void OnWindowClosed() override;
|
|
|
|
|
|
|
|
gfx::Size GetSize();
|
2016-07-20 11:30:06 +02:00
|
|
|
|
2016-08-04 13:03:24 +09:00
|
|
|
// content::WebContentsView:
|
2016-07-20 11:30:06 +02:00
|
|
|
gfx::NativeView GetNativeView() const override;
|
|
|
|
gfx::NativeView GetContentNativeView() const override;
|
|
|
|
gfx::NativeWindow GetTopLevelNativeWindow() const override;
|
2020-05-26 13:06:26 -07:00
|
|
|
gfx::Rect GetContainerBounds() const override;
|
2016-07-20 11:30:06 +02:00
|
|
|
void Focus() override;
|
|
|
|
void SetInitialFocus() override;
|
|
|
|
void StoreFocus() override;
|
|
|
|
void RestoreFocus() override;
|
2018-05-15 03:59:22 +02:00
|
|
|
void FocusThroughTabTraversal(bool reverse) override;
|
2016-07-20 11:30:06 +02:00
|
|
|
content::DropData* GetDropData() const override;
|
|
|
|
gfx::Rect GetViewBounds() const override;
|
2019-09-18 15:58:00 -04:00
|
|
|
void CreateView(gfx::NativeView context) override;
|
2016-07-20 11:30:06 +02:00
|
|
|
content::RenderWidgetHostViewBase* CreateViewForWidget(
|
2019-12-10 16:22:35 -08:00
|
|
|
content::RenderWidgetHost* render_widget_host) override;
|
2019-01-30 09:33:32 -08:00
|
|
|
content::RenderWidgetHostViewBase* CreateViewForChildWidget(
|
2016-07-20 11:30:06 +02:00
|
|
|
content::RenderWidgetHost* render_widget_host) override;
|
2021-03-16 12:18:45 -04:00
|
|
|
void SetPageTitle(const std::u16string& title) override;
|
2018-10-11 06:14:01 -07:00
|
|
|
void RenderViewReady() override;
|
|
|
|
void RenderViewHostChanged(content::RenderViewHost* old_host,
|
|
|
|
content::RenderViewHost* new_host) override;
|
2016-07-20 11:30:06 +02:00
|
|
|
void SetOverscrollControllerEnabled(bool enabled) override;
|
2021-11-24 09:45:59 +01:00
|
|
|
void OnCapturerCountChanged() override;
|
2016-07-20 11:30:06 +02:00
|
|
|
|
2022-02-09 18:58:52 -08:00
|
|
|
#if BUILDFLAG(IS_MAC)
|
2019-04-17 23:10:04 +02:00
|
|
|
bool CloseTabAfterEventTrackingIfNeeded() override;
|
2016-07-20 11:30:06 +02:00
|
|
|
#endif
|
|
|
|
|
2016-07-30 00:51:19 +02:00
|
|
|
// content::RenderViewHostDelegateView
|
2017-01-24 14:06:48 +09:00
|
|
|
void StartDragging(const content::DropData& drop_data,
|
2020-10-15 18:30:41 -07:00
|
|
|
blink::DragOperationsMask allowed_ops,
|
2017-01-24 14:06:48 +09:00
|
|
|
const gfx::ImageSkia& image,
|
|
|
|
const gfx::Vector2d& image_offset,
|
2020-09-21 01:00:36 -07:00
|
|
|
const blink::mojom::DragEventSourceInfo& event_info,
|
2017-01-24 14:06:48 +09:00
|
|
|
content::RenderWidgetHostImpl* source_rwh) override;
|
2021-01-12 15:31:23 -08:00
|
|
|
void UpdateDragCursor(ui::mojom::DragOperation operation) override;
|
2018-01-25 14:46:30 +01:00
|
|
|
void SetPainting(bool painting);
|
|
|
|
bool IsPainting() const;
|
|
|
|
void SetFrameRate(int frame_rate);
|
|
|
|
int GetFrameRate() const;
|
|
|
|
|
2016-07-31 12:19:56 +02:00
|
|
|
private:
|
2022-02-09 18:58:52 -08:00
|
|
|
#if BUILDFLAG(IS_MAC)
|
2016-08-04 15:34:29 +09:00
|
|
|
void PlatformCreate();
|
|
|
|
void PlatformDestroy();
|
|
|
|
#endif
|
|
|
|
|
2017-03-04 03:09:16 +01:00
|
|
|
OffScreenRenderWidgetHostView* GetView() const;
|
|
|
|
|
2021-01-26 19:16:21 +01:00
|
|
|
NativeWindow* native_window_ = nullptr;
|
2018-11-29 21:25:02 -08:00
|
|
|
|
2016-08-01 13:27:39 +02:00
|
|
|
const bool transparent_;
|
2018-05-22 00:18:38 +02:00
|
|
|
bool painting_ = true;
|
|
|
|
int frame_rate_ = 60;
|
2016-08-04 13:03:24 +09:00
|
|
|
OnPaintCallback callback_;
|
2016-08-01 13:27:39 +02:00
|
|
|
|
2016-08-03 13:46:34 +09:00
|
|
|
// Weak refs.
|
2018-05-22 00:18:38 +02:00
|
|
|
content::WebContents* web_contents_ = nullptr;
|
2016-08-04 15:34:29 +09:00
|
|
|
|
2022-02-09 18:58:52 -08:00
|
|
|
#if BUILDFLAG(IS_MAC)
|
2016-08-04 15:34:29 +09:00
|
|
|
OffScreenView* offScreenView_;
|
|
|
|
#endif
|
2016-07-20 11:30:06 +02:00
|
|
|
};
|
2016-07-20 11:32:59 +02:00
|
|
|
|
2016-07-20 11:30:06 +02:00
|
|
|
} // namespace electron
|
|
|
|
|
2021-11-22 08:34:31 +01:00
|
|
|
#endif // ELECTRON_SHELL_BROWSER_OSR_OSR_WEB_CONTENTS_VIEW_H_
|