2016-07-30 19:35:14 +00:00
|
|
|
// Copyright (c) 2016 GitHub, Inc.
|
2016-07-20 09:30:06 +00:00
|
|
|
// 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_OSR_OSR_WEB_CONTENTS_VIEW_H_
|
|
|
|
#define ELECTRON_SHELL_BROWSER_OSR_OSR_WEB_CONTENTS_VIEW_H_
|
2016-07-20 09:30:06 +00:00
|
|
|
|
2019-06-19 20:46:59 +00:00
|
|
|
#include "shell/browser/native_window.h"
|
|
|
|
#include "shell/browser/native_window_observer.h"
|
2018-11-30 05:25:02 +00:00
|
|
|
|
2023-05-11 20:07:39 +00:00
|
|
|
#include "base/memory/raw_ptr.h"
|
2023-06-13 18:45:48 +00:00
|
|
|
#include "base/memory/raw_ptr_exclusion.h"
|
2019-04-17 21:10:04 +00: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 12:36:22 +00:00
|
|
|
#include "content/public/browser/web_contents.h"
|
2019-06-19 20:46:59 +00:00
|
|
|
#include "shell/browser/osr/osr_render_widget_host_view.h"
|
2020-10-16 01:30:41 +00:00
|
|
|
#include "third_party/blink/public/common/page/drag_mojom_traits.h"
|
2016-07-20 09:30:06 +00:00
|
|
|
|
2022-02-10 02:58:52 +00:00
|
|
|
#if BUILDFLAG(IS_MAC)
|
2016-08-04 06:34:29 +00:00
|
|
|
#ifdef __OBJC__
|
|
|
|
@class OffScreenView;
|
|
|
|
#else
|
|
|
|
class OffScreenView;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2016-07-20 09:30:06 +00:00
|
|
|
namespace electron {
|
|
|
|
|
2016-07-25 13:55:00 +00:00
|
|
|
class OffScreenWebContentsView : public content::WebContentsView,
|
2018-11-30 05:25:02 +00:00
|
|
|
public content::RenderViewHostDelegateView,
|
|
|
|
public NativeWindowObserver {
|
2016-07-31 10:19:56 +00:00
|
|
|
public:
|
2016-08-04 04:03:24 +00:00
|
|
|
OffScreenWebContentsView(bool transparent, const OnPaintCallback& callback);
|
2018-05-04 06:45:12 +00:00
|
|
|
~OffScreenWebContentsView() override;
|
2016-07-29 12:50:27 +00:00
|
|
|
|
2016-07-27 12:36:22 +00:00
|
|
|
void SetWebContents(content::WebContents*);
|
2018-11-30 05:25:02 +00:00
|
|
|
void SetNativeWindow(NativeWindow* window);
|
|
|
|
|
|
|
|
// NativeWindowObserver:
|
|
|
|
void OnWindowResize() override;
|
|
|
|
void OnWindowClosed() override;
|
|
|
|
|
|
|
|
gfx::Size GetSize();
|
2016-07-20 09:30:06 +00:00
|
|
|
|
2016-08-04 04:03:24 +00:00
|
|
|
// content::WebContentsView:
|
2016-07-20 09:30:06 +00:00
|
|
|
gfx::NativeView GetNativeView() const override;
|
|
|
|
gfx::NativeView GetContentNativeView() const override;
|
|
|
|
gfx::NativeWindow GetTopLevelNativeWindow() const override;
|
2020-05-26 20:06:26 +00:00
|
|
|
gfx::Rect GetContainerBounds() const override;
|
2016-07-20 09:30:06 +00:00
|
|
|
void Focus() override;
|
|
|
|
void SetInitialFocus() override;
|
|
|
|
void StoreFocus() override;
|
|
|
|
void RestoreFocus() override;
|
2018-05-15 01:59:22 +00:00
|
|
|
void FocusThroughTabTraversal(bool reverse) override;
|
2016-07-20 09:30:06 +00:00
|
|
|
content::DropData* GetDropData() const override;
|
2023-09-29 05:26:41 +00:00
|
|
|
void CancelDragDropForPortalActivation() override;
|
2016-07-20 09:30:06 +00:00
|
|
|
gfx::Rect GetViewBounds() const override;
|
2019-09-18 19:58:00 +00:00
|
|
|
void CreateView(gfx::NativeView context) override;
|
2016-07-20 09:30:06 +00:00
|
|
|
content::RenderWidgetHostViewBase* CreateViewForWidget(
|
2019-12-11 00:22:35 +00:00
|
|
|
content::RenderWidgetHost* render_widget_host) override;
|
2019-01-30 17:33:32 +00:00
|
|
|
content::RenderWidgetHostViewBase* CreateViewForChildWidget(
|
2016-07-20 09:30:06 +00:00
|
|
|
content::RenderWidgetHost* render_widget_host) override;
|
2021-03-16 16:18:45 +00:00
|
|
|
void SetPageTitle(const std::u16string& title) override;
|
2018-10-11 13:14:01 +00:00
|
|
|
void RenderViewReady() override;
|
|
|
|
void RenderViewHostChanged(content::RenderViewHost* old_host,
|
|
|
|
content::RenderViewHost* new_host) override;
|
2016-07-20 09:30:06 +00:00
|
|
|
void SetOverscrollControllerEnabled(bool enabled) override;
|
2021-11-24 08:45:59 +00:00
|
|
|
void OnCapturerCountChanged() override;
|
2022-09-07 07:46:37 +00:00
|
|
|
void FullscreenStateChanged(bool is_fullscreen) override;
|
2023-03-10 16:07:42 +00:00
|
|
|
void UpdateWindowControlsOverlay(const gfx::Rect& bounding_rect) override;
|
2016-07-20 09:30:06 +00:00
|
|
|
|
2022-02-10 02:58:52 +00:00
|
|
|
#if BUILDFLAG(IS_MAC)
|
2019-04-17 21:10:04 +00:00
|
|
|
bool CloseTabAfterEventTrackingIfNeeded() override;
|
2016-07-20 09:30:06 +00:00
|
|
|
#endif
|
|
|
|
|
2016-07-29 22:51:19 +00:00
|
|
|
// content::RenderViewHostDelegateView
|
2017-01-24 05:06:48 +00:00
|
|
|
void StartDragging(const content::DropData& drop_data,
|
2023-10-02 22:01:07 +00:00
|
|
|
const url::Origin& source_origin,
|
2020-10-16 01:30:41 +00:00
|
|
|
blink::DragOperationsMask allowed_ops,
|
2017-01-24 05:06:48 +00:00
|
|
|
const gfx::ImageSkia& image,
|
2022-09-07 07:46:37 +00:00
|
|
|
const gfx::Vector2d& cursor_offset,
|
|
|
|
const gfx::Rect& drag_obj_rect,
|
2020-09-21 08:00:36 +00:00
|
|
|
const blink::mojom::DragEventSourceInfo& event_info,
|
2017-01-24 05:06:48 +00:00
|
|
|
content::RenderWidgetHostImpl* source_rwh) override;
|
2023-10-02 22:01:07 +00:00
|
|
|
void UpdateDragOperation(ui::mojom::DragOperation operation,
|
|
|
|
bool document_is_handling_drag) override;
|
2018-01-25 13:46:30 +00:00
|
|
|
void SetPainting(bool painting);
|
|
|
|
bool IsPainting() const;
|
|
|
|
void SetFrameRate(int frame_rate);
|
|
|
|
int GetFrameRate() const;
|
|
|
|
|
2016-07-31 10:19:56 +00:00
|
|
|
private:
|
2022-02-10 02:58:52 +00:00
|
|
|
#if BUILDFLAG(IS_MAC)
|
2016-08-04 06:34:29 +00:00
|
|
|
void PlatformCreate();
|
|
|
|
void PlatformDestroy();
|
|
|
|
#endif
|
|
|
|
|
2017-03-04 02:09:16 +00:00
|
|
|
OffScreenRenderWidgetHostView* GetView() const;
|
|
|
|
|
2023-05-11 20:07:39 +00:00
|
|
|
raw_ptr<NativeWindow> native_window_ = nullptr;
|
2018-11-30 05:25:02 +00:00
|
|
|
|
2016-08-01 11:27:39 +00:00
|
|
|
const bool transparent_;
|
2018-05-21 22:18:38 +00:00
|
|
|
bool painting_ = true;
|
|
|
|
int frame_rate_ = 60;
|
2016-08-04 04:03:24 +00:00
|
|
|
OnPaintCallback callback_;
|
2016-08-01 11:27:39 +00:00
|
|
|
|
2016-08-03 04:46:34 +00:00
|
|
|
// Weak refs.
|
2023-05-11 20:07:39 +00:00
|
|
|
raw_ptr<content::WebContents> web_contents_ = nullptr;
|
2016-08-04 06:34:29 +00:00
|
|
|
|
2022-02-10 02:58:52 +00:00
|
|
|
#if BUILDFLAG(IS_MAC)
|
2023-06-13 18:45:48 +00:00
|
|
|
RAW_PTR_EXCLUSION OffScreenView* offScreenView_;
|
2016-08-04 06:34:29 +00:00
|
|
|
#endif
|
2016-07-20 09:30:06 +00:00
|
|
|
};
|
2016-07-20 09:32:59 +00:00
|
|
|
|
2016-07-20 09:30:06 +00:00
|
|
|
} // namespace electron
|
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#endif // ELECTRON_SHELL_BROWSER_OSR_OSR_WEB_CONTENTS_VIEW_H_
|