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.
|
|
|
|
|
2019-06-19 13:56:58 -07:00
|
|
|
#ifndef SHELL_BROWSER_OSR_OSR_WEB_CONTENTS_VIEW_H_
|
|
|
|
#define 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"
|
2016-07-20 11:30:06 +02:00
|
|
|
|
2016-08-04 15:34:29 +09:00
|
|
|
#if defined(OS_MACOSX)
|
|
|
|
#ifdef __OBJC__
|
|
|
|
@class OffScreenView;
|
|
|
|
#else
|
|
|
|
class OffScreenView;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2019-06-19 14:23:04 -07:00
|
|
|
namespace electron {
|
2016-07-20 11:30:06 +02:00
|
|
|
|
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;
|
|
|
|
void GetContainerBounds(gfx::Rect* out) const override;
|
|
|
|
void SizeContents(const gfx::Size& size) override;
|
|
|
|
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(
|
|
|
|
content::RenderWidgetHost* render_widget_host,
|
|
|
|
bool is_guest_view_hack) 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;
|
|
|
|
void SetPageTitle(const base::string16& title) override;
|
|
|
|
void RenderViewCreated(content::RenderViewHost* host) 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;
|
|
|
|
|
|
|
|
#if defined(OS_MACOSX)
|
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,
|
|
|
|
blink::WebDragOperationsMask allowed_ops,
|
|
|
|
const gfx::ImageSkia& image,
|
|
|
|
const gfx::Vector2d& image_offset,
|
|
|
|
const content::DragEventSourceInfo& event_info,
|
|
|
|
content::RenderWidgetHostImpl* source_rwh) override;
|
2016-07-25 15:55:00 +02:00
|
|
|
void UpdateDragCursor(blink::WebDragOperation 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:
|
2016-08-04 15:34:29 +09:00
|
|
|
#if defined(OS_MACOSX)
|
|
|
|
void PlatformCreate();
|
|
|
|
void PlatformDestroy();
|
|
|
|
#endif
|
|
|
|
|
2017-03-04 03:09:16 +01:00
|
|
|
OffScreenRenderWidgetHostView* GetView() const;
|
|
|
|
|
2018-11-29 21:25:02 -08:00
|
|
|
NativeWindow* native_window_;
|
|
|
|
|
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
|
|
|
|
|
|
|
#if defined(OS_MACOSX)
|
|
|
|
OffScreenView* offScreenView_;
|
|
|
|
#endif
|
2016-07-20 11:30:06 +02:00
|
|
|
};
|
2016-07-20 11:32:59 +02:00
|
|
|
|
2019-06-19 14:23:04 -07:00
|
|
|
} // namespace electron
|
2016-07-20 11:30:06 +02:00
|
|
|
|
2019-06-19 13:56:58 -07:00
|
|
|
#endif // SHELL_BROWSER_OSR_OSR_WEB_CONTENTS_VIEW_H_
|