• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 The Chromium Embedded Framework Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef CEF_LIBCEF_BROWSER_VIEWS_BROWSER_PLATFORM_DELEGATE_VIEWS_H_
6 #define CEF_LIBCEF_BROWSER_VIEWS_BROWSER_PLATFORM_DELEGATE_VIEWS_H_
7 
8 #include "libcef/browser/alloy/browser_platform_delegate_alloy.h"
9 #include "libcef/browser/native/browser_platform_delegate_native.h"
10 #include "libcef/browser/views/browser_view_impl.h"
11 
12 // Implementation of Views-based browser functionality.
13 class CefBrowserPlatformDelegateViews
14     : public CefBrowserPlatformDelegateAlloy,
15       public CefBrowserPlatformDelegateNative::WindowlessHandler {
16  public:
17   // Platform-specific behaviors will be delegated to |native_delegate|.
18   // |browser_view_getter| may be initially empty for popup browsers.
19   CefBrowserPlatformDelegateViews(
20       std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate,
21       CefRefPtr<CefBrowserViewImpl> browser_view);
22 
23   // CefBrowserPlatformDelegate methods:
24   void WebContentsCreated(content::WebContents* web_contents,
25                           bool owned) override;
26   void WebContentsDestroyed(content::WebContents* web_contents) override;
27   void BrowserCreated(CefBrowserHostBase* browser) override;
28   void NotifyBrowserCreated() override;
29   void NotifyBrowserDestroyed() override;
30   void BrowserDestroyed(CefBrowserHostBase* browser) override;
31   bool CreateHostWindow() override;
32   void CloseHostWindow() override;
33   CefWindowHandle GetHostWindowHandle() const override;
34   views::Widget* GetWindowWidget() const override;
35   CefRefPtr<CefBrowserView> GetBrowserView() const override;
36   void PopupWebContentsCreated(
37       const CefBrowserSettings& settings,
38       CefRefPtr<CefClient> client,
39       content::WebContents* new_web_contents,
40       CefBrowserPlatformDelegate* new_platform_delegate,
41       bool is_devtools) override;
42   void PopupBrowserCreated(CefBrowserHostBase* new_browser,
43                            bool is_devtools) override;
44   SkColor GetBackgroundColor() const override;
45   void WasResized() override;
46   void SendKeyEvent(const CefKeyEvent& event) override;
47   void SendMouseClickEvent(const CefMouseEvent& event,
48                            CefBrowserHost::MouseButtonType type,
49                            bool mouseUp,
50                            int clickCount) override;
51   void SendMouseMoveEvent(const CefMouseEvent& event, bool mouseLeave) override;
52   void SendMouseWheelEvent(const CefMouseEvent& event,
53                            int deltaX,
54                            int deltaY) override;
55   void SendTouchEvent(const CefTouchEvent& event) override;
56   void SetFocus(bool setFocus) override;
57   gfx::Point GetScreenPoint(const gfx::Point& view) const override;
58   void ViewText(const std::string& text) override;
59   bool HandleKeyboardEvent(
60       const content::NativeWebKeyboardEvent& event) override;
61   CefEventHandle GetEventHandle(
62       const content::NativeWebKeyboardEvent& event) const override;
63   std::unique_ptr<CefFileDialogRunner> CreateFileDialogRunner() override;
64   std::unique_ptr<CefJavaScriptDialogRunner> CreateJavaScriptDialogRunner()
65       override;
66   std::unique_ptr<CefMenuRunner> CreateMenuRunner() override;
67   bool IsViewsHosted() const override;
68   gfx::Point GetDialogPosition(const gfx::Size& size) override;
69   gfx::Size GetMaximumDialogSize() override;
70 
71   // CefBrowserPlatformDelegateNative::WindowlessHandler methods:
72   CefWindowHandle GetParentWindowHandle() const override;
73   gfx::Point GetParentScreenPoint(const gfx::Point& view) const override;
74 
75  private:
76   void SetBrowserView(CefRefPtr<CefBrowserViewImpl> browser_view);
77 
78   std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate_;
79   CefRefPtr<CefBrowserViewImpl> browser_view_;
80 };
81 
82 #endif  // CEF_LIBCEF_BROWSER_VIEWS_BROWSER_PLATFORM_DELEGATE_VIEWS_H_
83