| OLD | NEW | 
|    1 // Copyright 2014 The Chromium Authors. All rights reserved. |    1 // Copyright 2014 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_BROWSER_DEVTOOLS_PROTOCOL_INPUT_HANDLER_H_ |    5 #ifndef CONTENT_BROWSER_DEVTOOLS_PROTOCOL_INPUT_HANDLER_H_ | 
|    6 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_INPUT_HANDLER_H_ |    6 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_INPUT_HANDLER_H_ | 
|    7  |    7  | 
|    8 #include "base/macros.h" |    8 #include "base/macros.h" | 
|    9 #include "base/memory/weak_ptr.h" |    9 #include "base/memory/weak_ptr.h" | 
|   10 #include "content/browser/devtools/protocol/devtools_protocol_dispatcher.h" |   10 #include "content/browser/devtools/protocol/devtools_protocol_dispatcher.h" | 
|   11 #include "content/browser/renderer_host/input/synthetic_gesture.h" |   11 #include "content/browser/renderer_host/input/synthetic_gesture.h" | 
|   12 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h" |   12 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h" | 
 |   13 #include "content/public/browser/render_widget_host.h" | 
|   13 #include "ui/gfx/geometry/size_f.h" |   14 #include "ui/gfx/geometry/size_f.h" | 
|   14  |   15  | 
|   15 namespace cc { |   16 namespace cc { | 
|   16 class CompositorFrameMetadata; |   17 class CompositorFrameMetadata; | 
|   17 } |   18 } | 
|   18  |   19  | 
|   19 namespace gfx { |   20 namespace gfx { | 
|   20 class Point; |   21 class Point; | 
|   21 } |   22 } | 
|   22  |   23  | 
|   23 namespace content { |   24 namespace content { | 
|   24  |   25  | 
|   25 class RenderWidgetHostImpl; |   26 class RenderWidgetHostImpl; | 
|   26  |   27  | 
|   27 namespace devtools { |   28 namespace devtools { | 
|   28 namespace input { |   29 namespace input { | 
|   29  |   30  | 
|   30 class InputHandler { |   31 class InputHandler : public RenderWidgetHost::InputEventObserver { | 
|   31  public: |   32  public: | 
|   32   typedef DevToolsProtocolClient::Response Response; |   33   typedef DevToolsProtocolClient::Response Response; | 
|   33  |   34  | 
|   34   InputHandler(); |   35   InputHandler(); | 
|   35   virtual ~InputHandler(); |   36   ~InputHandler() override; | 
 |   37  | 
 |   38   // InputEventObserver | 
 |   39   void OnInputEvent(const blink::WebInputEvent& event) override {}; | 
 |   40   void OnInputEventAck(const blink::WebInputEvent& event, bool is_synthetic) | 
 |   41       override; | 
|   36  |   42  | 
|   37   void SetRenderWidgetHost(RenderWidgetHostImpl* host); |   43   void SetRenderWidgetHost(RenderWidgetHostImpl* host); | 
|   38   void SetClient(std::unique_ptr<Client> client); |   44   void SetClient(std::unique_ptr<Client> client); | 
|   39   void OnSwapCompositorFrame(const cc::CompositorFrameMetadata& frame_metadata); |   45   void OnSwapCompositorFrame(const cc::CompositorFrameMetadata& frame_metadata); | 
|   40  |   46  | 
|   41   Response DispatchKeyEvent(const std::string& type, |   47   Response DispatchKeyEvent(DevToolsCommandId command_id, | 
 |   48                             const std::string& type, | 
|   42                             const int* modifiers, |   49                             const int* modifiers, | 
|   43                             const double* timestamp, |   50                             const double* timestamp, | 
|   44                             const std::string* text, |   51                             const std::string* text, | 
|   45                             const std::string* unmodified_text, |   52                             const std::string* unmodified_text, | 
|   46                             const std::string* key_identifier, |   53                             const std::string* key_identifier, | 
|   47                             const std::string* code, |   54                             const std::string* code, | 
|   48                             const std::string* key, |   55                             const std::string* key, | 
|   49                             const int* windows_virtual_key_code, |   56                             const int* windows_virtual_key_code, | 
|   50                             const int* native_virtual_key_code, |   57                             const int* native_virtual_key_code, | 
|   51                             const bool* auto_repeat, |   58                             const bool* auto_repeat, | 
|   52                             const bool* is_keypad, |   59                             const bool* is_keypad, | 
|   53                             const bool* is_system_key); |   60                             const bool* is_system_key); | 
|   54  |   61  | 
|   55   Response DispatchMouseEvent(const std::string& type, |   62   Response DispatchMouseEvent(DevToolsCommandId command_id, | 
 |   63                               const std::string& type, | 
|   56                               int x, |   64                               int x, | 
|   57                               int y, |   65                               int y, | 
|   58                               const int* modifiers, |   66                               const int* modifiers, | 
|   59                               const double* timestamp, |   67                               const double* timestamp, | 
|   60                               const std::string* button, |   68                               const std::string* button, | 
|   61                               const int* click_count); |   69                               const int* click_count); | 
|   62  |   70  | 
|   63   Response EmulateTouchFromMouseEvent(const std::string& type, |   71   Response EmulateTouchFromMouseEvent(const std::string& type, | 
|   64                                       int x, |   72                                       int x, | 
|   65                                       int y, |   73                                       int y, | 
| (...skipping 26 matching lines...) Expand all  Loading... | 
|   92                                    const std::string* interaction_marker_name); |  100                                    const std::string* interaction_marker_name); | 
|   93  |  101  | 
|   94   Response SynthesizeTapGesture(DevToolsCommandId command_id, |  102   Response SynthesizeTapGesture(DevToolsCommandId command_id, | 
|   95                                 int x, |  103                                 int x, | 
|   96                                 int y, |  104                                 int y, | 
|   97                                 const int* duration, |  105                                 const int* duration, | 
|   98                                 const int* tap_count, |  106                                 const int* tap_count, | 
|   99                                 const std::string* gesture_source_type); |  107                                 const std::string* gesture_source_type); | 
|  100  |  108  | 
|  101  private: |  109  private: | 
 |  110   void SendDispatchKeyEventResponse(DevToolsCommandId command_id); | 
 |  111   void SendDispatchMouseEventResponse(DevToolsCommandId command_id); | 
 |  112  | 
|  102   void SendSynthesizePinchGestureResponse(DevToolsCommandId command_id, |  113   void SendSynthesizePinchGestureResponse(DevToolsCommandId command_id, | 
|  103                                           SyntheticGesture::Result result); |  114                                           SyntheticGesture::Result result); | 
|  104  |  115  | 
|  105   void SendSynthesizeScrollGestureResponse(DevToolsCommandId command_id, |  116   void SendSynthesizeScrollGestureResponse(DevToolsCommandId command_id, | 
|  106                                            SyntheticGesture::Result result); |  117                                            SyntheticGesture::Result result); | 
|  107  |  118  | 
|  108   void SendSynthesizeTapGestureResponse(DevToolsCommandId command_id, |  119   void SendSynthesizeTapGestureResponse(DevToolsCommandId command_id, | 
|  109                                         bool send_success, |  120                                         bool send_success, | 
|  110                                         SyntheticGesture::Result result); |  121                                         SyntheticGesture::Result result); | 
|  111  |  122  | 
|  112   void SynthesizeRepeatingScroll( |  123   void SynthesizeRepeatingScroll( | 
|  113       SyntheticSmoothScrollGestureParams gesture_params, |  124       SyntheticSmoothScrollGestureParams gesture_params, | 
|  114       int repeat_count, |  125       int repeat_count, | 
|  115       base::TimeDelta repeat_delay, |  126       base::TimeDelta repeat_delay, | 
|  116       std::string interaction_marker_name, |  127       std::string interaction_marker_name, | 
|  117       DevToolsCommandId command_id); |  128       DevToolsCommandId command_id); | 
|  118  |  129  | 
|  119   void OnScrollFinished(SyntheticSmoothScrollGestureParams gesture_params, |  130   void OnScrollFinished(SyntheticSmoothScrollGestureParams gesture_params, | 
|  120                         int repeat_count, |  131                         int repeat_count, | 
|  121                         base::TimeDelta repeat_delay, |  132                         base::TimeDelta repeat_delay, | 
|  122                         std::string interaction_marker_name, |  133                         std::string interaction_marker_name, | 
|  123                         DevToolsCommandId command_id, |  134                         DevToolsCommandId command_id, | 
|  124                         SyntheticGesture::Result result); |  135                         SyntheticGesture::Result result); | 
|  125  |  136  | 
|  126   RenderWidgetHostImpl* host_; |  137   RenderWidgetHostImpl* host_; | 
|  127   std::unique_ptr<Client> client_; |  138   std::unique_ptr<Client> client_; | 
 |  139   // DevToolsCommandIds for calls to Input.dispatchKey/MouseEvent that have been | 
 |  140   // sent to the renderer, but that we haven't yet received an ack for. | 
 |  141   std::deque<DevToolsCommandId> pending_key_event_ids_; | 
 |  142   std::deque<DevToolsCommandId> pending_mouse_event_ids_; | 
|  128   float page_scale_factor_; |  143   float page_scale_factor_; | 
|  129   gfx::SizeF scrollable_viewport_size_; |  144   gfx::SizeF scrollable_viewport_size_; | 
|  130   base::WeakPtrFactory<InputHandler> weak_factory_; |  145   base::WeakPtrFactory<InputHandler> weak_factory_; | 
|  131  |  146  | 
|  132   DISALLOW_COPY_AND_ASSIGN(InputHandler); |  147   DISALLOW_COPY_AND_ASSIGN(InputHandler); | 
|  133 }; |  148 }; | 
|  134  |  149  | 
|  135 }  // namespace input |  150 }  // namespace input | 
|  136 }  // namespace devtools |  151 }  // namespace devtools | 
|  137 }  // namespace content |  152 }  // namespace content | 
|  138  |  153  | 
|  139 #endif  // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_INPUT_HANDLER_H_ |  154 #endif  // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_INPUT_HANDLER_H_ | 
| OLD | NEW |