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