OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_RENDERER_MUS_RENDER_WIDGET_MUS_CONNECTION_H_ | 5 #ifndef CONTENT_RENDERER_MUS_RENDER_WIDGET_MUS_CONNECTION_H_ |
6 #define CONTENT_RENDERER_MUS_RENDER_WIDGET_MUS_CONNECTION_H_ | 6 #define CONTENT_RENDERER_MUS_RENDER_WIDGET_MUS_CONNECTION_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/threading/thread_checker.h" | 9 #include "base/threading/thread_checker.h" |
10 #include "cc/output/compositor_frame_sink.h" | 10 #include "cc/output/compositor_frame_sink.h" |
11 #include "cc/output/context_provider.h" | 11 #include "cc/output/context_provider.h" |
12 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
13 #include "content/renderer/input/render_widget_input_handler_delegate.h" | 13 #include "services/ui/public/interfaces/window_tree.mojom.h" |
14 #include "content/renderer/mus/compositor_mus_connection.h" | |
15 | 14 |
16 namespace gpu { | 15 namespace gpu { |
17 class GpuMemoryBufferManager; | 16 class GpuMemoryBufferManager; |
18 } | 17 } |
19 | 18 |
| 19 namespace ui { |
| 20 class WindowCompositorFrameSinkBinding; |
| 21 } |
| 22 |
20 namespace content { | 23 namespace content { |
21 | 24 |
22 // Use on main thread. | 25 // This lives in the main-thread, and manages the connection to the mus window |
23 class CONTENT_EXPORT RenderWidgetMusConnection | 26 // server for a RenderWidget. |
24 : public RenderWidgetInputHandlerDelegate { | 27 class CONTENT_EXPORT RenderWidgetMusConnection { |
25 public: | 28 public: |
26 // Bind to a WindowTreeClient request. | 29 // Bind to a WindowTreeClient request. |
27 void Bind(mojo::InterfaceRequest<ui::mojom::WindowTreeClient> request); | 30 void Bind(mojo::InterfaceRequest<ui::mojom::WindowTreeClient> request); |
28 | 31 |
29 // Create a cc output surface. | 32 // Create a cc output surface. |
30 std::unique_ptr<cc::CompositorFrameSink> CreateCompositorFrameSink( | 33 std::unique_ptr<cc::CompositorFrameSink> CreateCompositorFrameSink( |
31 const cc::FrameSinkId& frame_sink_id, | 34 const cc::FrameSinkId& frame_sink_id, |
32 scoped_refptr<cc::ContextProvider> context_provider, | 35 scoped_refptr<cc::ContextProvider> context_provider, |
33 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager); | 36 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager); |
34 | 37 |
35 static RenderWidgetMusConnection* Get(int routing_id); | 38 static RenderWidgetMusConnection* Get(int routing_id); |
36 | 39 |
37 // Get the connection from a routing_id, if the connection doesn't exist, | 40 // Get the connection from a routing_id, if the connection doesn't exist, |
38 // a new connection will be created. | 41 // a new connection will be created. |
39 static RenderWidgetMusConnection* GetOrCreate(int routing_id); | 42 static RenderWidgetMusConnection* GetOrCreate(int routing_id); |
40 | 43 |
41 private: | 44 private: |
42 friend class CompositorMusConnection; | 45 friend class CompositorMusConnection; |
43 friend class CompositorMusConnectionTest; | 46 friend class CompositorMusConnectionTest; |
44 | 47 |
45 explicit RenderWidgetMusConnection(int routing_id); | 48 explicit RenderWidgetMusConnection(int routing_id); |
46 ~RenderWidgetMusConnection() override; | 49 ~RenderWidgetMusConnection(); |
47 | |
48 // RenderWidgetInputHandlerDelegate implementation: | |
49 void FocusChangeComplete() override; | |
50 bool HasTouchEventHandlersAt(const gfx::Point& point) const override; | |
51 void ObserveGestureEventAndResult(const blink::WebGestureEvent& gesture_event, | |
52 const gfx::Vector2dF& gesture_unused_delta, | |
53 bool event_processed) override; | |
54 void OnDidHandleKeyEvent() override; | |
55 void OnDidOverscroll(const ui::DidOverscrollParams& params) override; | |
56 void OnInputEventAck(std::unique_ptr<InputEventAck> input_event_ack) override; | |
57 void NotifyInputEventHandled(blink::WebInputEvent::Type handled_type, | |
58 InputEventAckState ack_result) override; | |
59 void SetInputHandler(RenderWidgetInputHandler* input_handler) override; | |
60 void ShowVirtualKeyboard() override; | |
61 void UpdateTextInputState() override; | |
62 bool WillHandleGestureEvent(const blink::WebGestureEvent& event) override; | |
63 bool WillHandleMouseEvent(const blink::WebMouseEvent& event) override; | |
64 | |
65 void OnConnectionLost(); | |
66 void OnWindowInputEvent( | |
67 blink::WebScopedInputEvent input_event, | |
68 const base::Callback<void(ui::mojom::EventResult)>& ack); | |
69 | 50 |
70 const int routing_id_; | 51 const int routing_id_; |
71 RenderWidgetInputHandler* input_handler_; | |
72 std::unique_ptr<ui::WindowCompositorFrameSinkBinding> | 52 std::unique_ptr<ui::WindowCompositorFrameSinkBinding> |
73 window_compositor_frame_sink_binding_; | 53 window_compositor_frame_sink_binding_; |
74 scoped_refptr<CompositorMusConnection> compositor_mus_connection_; | |
75 | |
76 base::Callback<void(ui::mojom::EventResult)> pending_ack_; | |
77 | |
78 // Used to verify single threaded access. | |
79 base::ThreadChecker thread_checker_; | |
80 | 54 |
81 DISALLOW_COPY_AND_ASSIGN(RenderWidgetMusConnection); | 55 DISALLOW_COPY_AND_ASSIGN(RenderWidgetMusConnection); |
82 }; | 56 }; |
83 | 57 |
84 } // namespace content | 58 } // namespace content |
85 | 59 |
86 #endif // CONTENT_RENDERER_MUS_RENDER_WIDGET_MUS_CONNECTION_H_ | 60 #endif // CONTENT_RENDERER_MUS_RENDER_WIDGET_MUS_CONNECTION_H_ |
OLD | NEW |