• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 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_NATIVE_BROWSER_PLATFORM_DELEGATE_NATIVE_AURA_H_
6 #define CEF_LIBCEF_BROWSER_NATIVE_BROWSER_PLATFORM_DELEGATE_NATIVE_AURA_H_
7 
8 #include "libcef/browser/native/browser_platform_delegate_native.h"
9 
10 #include "ui/events/event.h"
11 
12 namespace content {
13 class RenderWidgetHostViewAura;
14 }
15 
16 namespace gfx {
17 class Vector2d;
18 }
19 
20 // Windowed browser implementation for Aura platforms.
21 class CefBrowserPlatformDelegateNativeAura
22     : public CefBrowserPlatformDelegateNative {
23  public:
24   CefBrowserPlatformDelegateNativeAura(const CefWindowInfo& window_info,
25                                        SkColor background_color);
26 
27   // CefBrowserPlatformDelegate methods:
28   void SendKeyEvent(const CefKeyEvent& event) override;
29   void SendMouseClickEvent(const CefMouseEvent& event,
30                            CefBrowserHost::MouseButtonType type,
31                            bool mouseUp,
32                            int clickCount) override;
33   void SendMouseMoveEvent(const CefMouseEvent& event, bool mouseLeave) override;
34   void SendMouseWheelEvent(const CefMouseEvent& event,
35                            int deltaX,
36                            int deltaY) override;
37   void SendTouchEvent(const CefTouchEvent& event) override;
38 
39   // CefBrowserPlatformDelegateNative methods:
40   content::NativeWebKeyboardEvent TranslateWebKeyEvent(
41       const CefKeyEvent& key_event) const override;
42   blink::WebMouseEvent TranslateWebClickEvent(
43       const CefMouseEvent& mouse_event,
44       CefBrowserHost::MouseButtonType type,
45       bool mouseUp,
46       int clickCount) const override;
47   blink::WebMouseEvent TranslateWebMoveEvent(const CefMouseEvent& mouse_event,
48                                              bool mouseLeave) const override;
49   blink::WebMouseWheelEvent TranslateWebWheelEvent(
50       const CefMouseEvent& mouse_event,
51       int deltaX,
52       int deltaY) const override;
53 
54   // Translate CEF events to Chromium UI events.
55   virtual ui::KeyEvent TranslateUiKeyEvent(
56       const CefKeyEvent& key_event) const = 0;
57   virtual ui::MouseEvent TranslateUiClickEvent(
58       const CefMouseEvent& mouse_event,
59       CefBrowserHost::MouseButtonType type,
60       bool mouseUp,
61       int clickCount) const;
62   virtual ui::MouseEvent TranslateUiMoveEvent(const CefMouseEvent& mouse_event,
63                                               bool mouseLeave) const;
64   virtual ui::MouseWheelEvent TranslateUiWheelEvent(
65       const CefMouseEvent& mouse_event,
66       int deltaX,
67       int deltaY) const;
68   virtual gfx::Vector2d GetUiWheelEventOffset(int deltaX, int deltaY) const;
69 
70  protected:
71   static base::TimeTicks GetEventTimeStamp();
72   static int TranslateUiEventModifiers(uint32 cef_modifiers);
73   static int TranslateUiChangedButtonFlags(uint32 cef_modifiers);
74 
75  private:
76   content::RenderWidgetHostViewAura* GetHostView() const;
77 };
78 
79 #endif  // CEF_LIBCEF_BROWSER_NATIVE_BROWSER_PLATFORM_DELEGATE_NATIVE_AURA_H_
80