| 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_BROWSER_DEVTOOLS_PROTOCOL_EMULATION_HANDLER_H_ | 5 #ifndef CONTENT_BROWSER_DEVTOOLS_PROTOCOL_EMULATION_HANDLER_H_ |
| 6 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_EMULATION_HANDLER_H_ | 6 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_EMULATION_HANDLER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "content/browser/devtools/protocol/devtools_protocol_dispatcher.h" | 9 #include "content/browser/devtools/protocol/emulation.h" |
| 10 #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h" | 10 #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h" |
| 11 | 11 |
| 12 namespace content { | 12 namespace content { |
| 13 | 13 |
| 14 class RenderFrameHostImpl; | 14 class RenderFrameHostImpl; |
| 15 class WebContentsImpl; | 15 class WebContentsImpl; |
| 16 | 16 |
| 17 namespace devtools { | 17 namespace protocol { |
| 18 | 18 |
| 19 namespace page { class PageHandler; } | 19 class EmulationHandler : public Emulation::Backend { |
| 20 | |
| 21 namespace emulation { | |
| 22 | |
| 23 class EmulationHandler { | |
| 24 public: | 20 public: |
| 25 using Response = DevToolsProtocolClient::Response; | |
| 26 | |
| 27 EmulationHandler(); | 21 EmulationHandler(); |
| 28 ~EmulationHandler(); | 22 ~EmulationHandler() override; |
| 29 | 23 |
| 30 void SetRenderFrameHost(RenderFrameHostImpl* host); | 24 void SetRenderFrameHost(RenderFrameHostImpl* host); |
| 31 void SetClient(std::unique_ptr<Client> client) { } | 25 void Wire(UberDispatcher*); |
| 32 void Detached(); | 26 Response Disable() override; |
| 33 | 27 |
| 34 Response SetGeolocationOverride(double* latitude, | 28 Response SetGeolocationOverride(Maybe<double> latitude, |
| 35 double* longitude, | 29 Maybe<double> longitude, |
| 36 double* accuracy); | 30 Maybe<double> accuracy) override; |
| 37 Response ClearGeolocationOverride(); | 31 Response ClearGeolocationOverride() override; |
| 38 | 32 |
| 39 Response SetTouchEmulationEnabled(bool enabled, | 33 Response SetTouchEmulationEnabled(bool enabled, |
| 40 const std::string* configuration); | 34 Maybe<std::string> configuration) override; |
| 41 | 35 |
| 42 Response CanEmulate(bool* result); | 36 Response CanEmulate(bool* result) override; |
| 43 Response SetDeviceMetricsOverride( | 37 Response SetDeviceMetricsOverride( |
| 44 int width, | 38 int width, |
| 45 int height, | 39 int height, |
| 46 double device_scale_factor, | 40 double device_scale_factor, |
| 47 bool mobile, | 41 bool mobile, |
| 48 bool fit_window, | 42 bool fit_window, |
| 49 const double* optional_scale, | 43 Maybe<double> scale, |
| 50 const double* optional_offset_x, | 44 Maybe<double> offset_x, |
| 51 const double* optional_offset_y, | 45 Maybe<double> offset_y, |
| 52 const int* screen_widget, | 46 Maybe<int> screen_widget, |
| 53 const int* screen_height, | 47 Maybe<int> screen_height, |
| 54 const int* position_x, | 48 Maybe<int> position_x, |
| 55 const int* position_y, | 49 Maybe<int> position_y, |
| 56 const std::unique_ptr<base::DictionaryValue>& screen_orientation); | 50 Maybe<Emulation::ScreenOrientation> screen_orientation) override; |
| 57 Response ClearDeviceMetricsOverride(); | 51 Response ClearDeviceMetricsOverride() override; |
| 58 | 52 |
| 59 Response SetVisibleSize(int width, int height); | 53 Response SetVisibleSize(int width, int height) override; |
| 60 | |
| 61 Response ForceViewport(double x, double y, double scale); | |
| 62 Response ResetViewport(); | |
| 63 Response ResetPageScaleFactor(); | |
| 64 Response SetPageScaleFactor(double page_scale_factor); | |
| 65 Response SetScriptExecutionDisabled(bool disabled); | |
| 66 Response SetEmulatedMedia(const std::string& media); | |
| 67 Response SetCPUThrottlingRate(double rate); | |
| 68 Response SetVirtualTimePolicy(const std::string& policy, const int* budget); | |
| 69 | 54 |
| 70 private: | 55 private: |
| 71 WebContentsImpl* GetWebContents(); | 56 WebContentsImpl* GetWebContents(); |
| 72 void UpdateTouchEventEmulationState(); | 57 void UpdateTouchEventEmulationState(); |
| 73 void UpdateDeviceEmulationState(); | 58 void UpdateDeviceEmulationState(); |
| 74 | 59 |
| 75 bool touch_emulation_enabled_; | 60 bool touch_emulation_enabled_; |
| 76 std::string touch_emulation_configuration_; | 61 std::string touch_emulation_configuration_; |
| 77 | 62 |
| 78 bool device_emulation_enabled_; | 63 bool device_emulation_enabled_; |
| 79 blink::WebDeviceEmulationParams device_emulation_params_; | 64 blink::WebDeviceEmulationParams device_emulation_params_; |
| 80 | 65 |
| 81 RenderFrameHostImpl* host_; | 66 RenderFrameHostImpl* host_; |
| 82 | 67 |
| 83 DISALLOW_COPY_AND_ASSIGN(EmulationHandler); | 68 DISALLOW_COPY_AND_ASSIGN(EmulationHandler); |
| 84 }; | 69 }; |
| 85 | 70 |
| 86 } // namespace emulation | 71 } // namespace protocol |
| 87 } // namespace devtools | |
| 88 } // namespace content | 72 } // namespace content |
| 89 | 73 |
| 90 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_EMULATION_HANDLER_H_ | 74 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_EMULATION_HANDLER_H_ |
| OLD | NEW |