• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2012 The Chromium Embedded Framework Authors.
2 // Portions copyright (c) 2011 The Chromium Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 
6 #ifndef CEF_LIBCEF_BROWSER_OSR_WEB_CONTENTS_VIEW_OSR_H_
7 #define CEF_LIBCEF_BROWSER_OSR_WEB_CONTENTS_VIEW_OSR_H_
8 
9 #include "content/browser/renderer_host/render_view_host_delegate_view.h"
10 #include "content/browser/web_contents/web_contents_view.h"
11 #include "third_party/skia/include/core/SkColor.h"
12 
13 namespace content {
14 class BrowserPluginGuest;
15 class WebContents;
16 class WebContentsViewDelegate;
17 }  // namespace content
18 
19 class AlloyBrowserHostImpl;
20 class CefRenderWidgetHostViewOSR;
21 
22 // An implementation of WebContentsView for off-screen rendering.
23 class CefWebContentsViewOSR : public content::WebContentsView,
24                               public content::RenderViewHostDelegateView {
25  public:
26   explicit CefWebContentsViewOSR(SkColor background_color,
27                                  bool use_shared_texture,
28                                  bool use_external_begin_frame);
29 
30   CefWebContentsViewOSR(const CefWebContentsViewOSR&) = delete;
31   CefWebContentsViewOSR& operator=(const CefWebContentsViewOSR&) = delete;
32 
33   ~CefWebContentsViewOSR() override;
34 
35   void WebContentsCreated(content::WebContents* web_contents);
web_contents()36   content::WebContents* web_contents() const { return web_contents_; }
37 
38   void RenderViewCreated();
39 
40   // WebContentsView methods.
41   gfx::NativeView GetNativeView() const override;
42   gfx::NativeView GetContentNativeView() const override;
43   gfx::NativeWindow GetTopLevelNativeWindow() const override;
44   gfx::Rect GetContainerBounds() const override;
45   void Focus() override;
46   void SetInitialFocus() override;
47   void StoreFocus() override;
48   void RestoreFocus() override;
49   void FocusThroughTabTraversal(bool reverse) override;
50   content::DropData* GetDropData() const override;
51   gfx::Rect GetViewBounds() const override;
52   void CreateView(gfx::NativeView context) override;
53   content::RenderWidgetHostViewBase* CreateViewForWidget(
54       content::RenderWidgetHost* render_widget_host) override;
55   content::RenderWidgetHostViewBase* CreateViewForChildWidget(
56       content::RenderWidgetHost* render_widget_host) override;
57   void SetPageTitle(const std::u16string& title) override;
58   void RenderViewReady() override;
59   void RenderViewHostChanged(content::RenderViewHost* old_host,
60                              content::RenderViewHost* new_host) override;
61   void SetOverscrollControllerEnabled(bool enabled) override;
62   void OnCapturerCountChanged() override;
63 
64 #if BUILDFLAG(IS_MAC)
65   bool CloseTabAfterEventTrackingIfNeeded() override;
66 #endif
67 
68   // RenderViewHostDelegateView methods.
69   void StartDragging(const content::DropData& drop_data,
70                      blink::DragOperationsMask allowed_ops,
71                      const gfx::ImageSkia& image,
72                      const gfx::Vector2d& image_offset,
73                      const blink::mojom::DragEventSourceInfo& event_info,
74                      content::RenderWidgetHostImpl* source_rwh) override;
75   void UpdateDragCursor(ui::mojom::DragOperation operation) override;
76   virtual void GotFocus(
77       content::RenderWidgetHostImpl* render_widget_host) override;
78   virtual void LostFocus(
79       content::RenderWidgetHostImpl* render_widget_host) override;
80   virtual void TakeFocus(bool reverse) override;
81 
82  private:
83   CefRenderWidgetHostViewOSR* GetView() const;
84   AlloyBrowserHostImpl* GetBrowser() const;
85 
86   const SkColor background_color_;
87   const bool use_shared_texture_;
88   const bool use_external_begin_frame_;
89 
90   content::WebContents* web_contents_;
91 };
92 
93 #endif  // CEF_LIBCEF_BROWSER_OSR_WEB_CONTENTS_VIEW_OSR_H_
94