Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(402)

Side by Side Diff: chrome/browser/chromeos/system/input_device_settings_impl_ozone.cc

Issue 2006083002: Use fake Input Device Settings with chrome://device-emulator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@DevicePageTestsFixes
Patch Set: make dependent on a11y fix Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "chrome/browser/chromeos/system/input_device_settings.h" 5 #include "chrome/browser/chromeos/system/input_device_settings.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/sys_info.h"
9 #include "chrome/browser/chromeos/system/fake_input_device_settings.h"
8 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
9 #include "ui/ozone/public/input_controller.h" 11 #include "ui/ozone/public/input_controller.h"
10 #include "ui/ozone/public/ozone_platform.h" 12 #include "ui/ozone/public/ozone_platform.h"
11 13
12 #if defined(MOJO_SHELL_CLIENT) 14 #if defined(MOJO_SHELL_CLIENT)
13 #include "services/shell/runner/common/client_util.h" 15 #include "services/shell/runner/common/client_util.h"
14 #endif 16 #endif
15 17
16 namespace chromeos { 18 namespace chromeos {
17 namespace system { 19 namespace system {
18 20
19 namespace { 21 namespace {
20 22
21 InputDeviceSettings* g_instance = nullptr; 23 InputDeviceSettings* g_instance = nullptr;
22 InputDeviceSettings* g_test_instance = nullptr;
23 24
24 std::unique_ptr<ui::InputController> CreateStubInputControllerIfNecessary() { 25 std::unique_ptr<ui::InputController> CreateStubInputControllerIfNecessary() {
25 #if defined(MOJO_SHELL_CLIENT) 26 #if defined(MOJO_SHELL_CLIENT)
26 return shell::ShellIsRemote() ? ui::CreateStubInputController() : nullptr; 27 return shell::ShellIsRemote() ? ui::CreateStubInputController() : nullptr;
27 #else 28 #else
28 return nullptr; 29 return nullptr;
29 #endif 30 #endif
30 } 31 }
31 32
32 // InputDeviceSettings for Linux without X11 (a.k.a. Ozone). 33 // InputDeviceSettings for Linux without X11 (a.k.a. Ozone).
(...skipping 12 matching lines...) Expand all
45 void SetTapToClick(bool enabled) override; 46 void SetTapToClick(bool enabled) override;
46 void SetThreeFingerClick(bool enabled) override; 47 void SetThreeFingerClick(bool enabled) override;
47 void SetTapDragging(bool enabled) override; 48 void SetTapDragging(bool enabled) override;
48 void SetNaturalScroll(bool enabled) override; 49 void SetNaturalScroll(bool enabled) override;
49 void MouseExists(const DeviceExistsCallback& callback) override; 50 void MouseExists(const DeviceExistsCallback& callback) override;
50 void UpdateMouseSettings(const MouseSettings& settings) override; 51 void UpdateMouseSettings(const MouseSettings& settings) override;
51 void SetMouseSensitivity(int value) override; 52 void SetMouseSensitivity(int value) override;
52 void SetPrimaryButtonRight(bool right) override; 53 void SetPrimaryButtonRight(bool right) override;
53 void ReapplyTouchpadSettings() override; 54 void ReapplyTouchpadSettings() override;
54 void ReapplyMouseSettings() override; 55 void ReapplyMouseSettings() override;
56 InputDeviceSettings::FakeInterface* GetFakeInterface() override;
55 void SetInternalTouchpadEnabled(bool enabled) override; 57 void SetInternalTouchpadEnabled(bool enabled) override;
56 void SetTouchscreensEnabled(bool enabled) override; 58 void SetTouchscreensEnabled(bool enabled) override;
57 59
58 // TODO(sad): A stub input controller is used when running inside mus. 60 // TODO(sad): A stub input controller is used when running inside mus.
59 // http://crbug.com/601981 61 // http://crbug.com/601981
60 std::unique_ptr<ui::InputController> stub_controller_; 62 std::unique_ptr<ui::InputController> stub_controller_;
61 63
62 // Cached InputController pointer. It should be fixed throughout the browser 64 // Cached InputController pointer. It should be fixed throughout the browser
63 // session. 65 // session.
64 ui::InputController* input_controller_; 66 ui::InputController* input_controller_;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 } 145 }
144 146
145 void InputDeviceSettingsImplOzone::ReapplyTouchpadSettings() { 147 void InputDeviceSettingsImplOzone::ReapplyTouchpadSettings() {
146 TouchpadSettings::Apply(current_touchpad_settings_, this); 148 TouchpadSettings::Apply(current_touchpad_settings_, this);
147 } 149 }
148 150
149 void InputDeviceSettingsImplOzone::ReapplyMouseSettings() { 151 void InputDeviceSettingsImplOzone::ReapplyMouseSettings() {
150 MouseSettings::Apply(current_mouse_settings_, this); 152 MouseSettings::Apply(current_mouse_settings_, this);
151 } 153 }
152 154
155 InputDeviceSettings::FakeInterface*
156 InputDeviceSettingsImplOzone::GetFakeInterface() {
157 return nullptr;
158 }
159
153 void InputDeviceSettingsImplOzone::SetInternalTouchpadEnabled(bool enabled) { 160 void InputDeviceSettingsImplOzone::SetInternalTouchpadEnabled(bool enabled) {
154 input_controller_->SetInternalTouchpadEnabled(enabled); 161 input_controller_->SetInternalTouchpadEnabled(enabled);
155 } 162 }
156 163
157 void InputDeviceSettingsImplOzone::SetTouchscreensEnabled(bool enabled) { 164 void InputDeviceSettingsImplOzone::SetTouchscreensEnabled(bool enabled) {
158 input_controller_->SetTouchscreensEnabled(enabled); 165 input_controller_->SetTouchscreensEnabled(enabled);
159 } 166 }
160 167
161 } // namespace 168 } // namespace
162 169
163 // static 170 // static
164 InputDeviceSettings* InputDeviceSettings::Get() { 171 InputDeviceSettings* InputDeviceSettings::Get() {
165 if (g_test_instance) 172 if (!g_instance) {
166 return g_test_instance; 173 if (base::SysInfo::IsRunningOnChromeOS())
167 if (!g_instance) 174 g_instance = new InputDeviceSettingsImplOzone;
168 g_instance = new InputDeviceSettingsImplOzone; 175 else
176 g_instance = new FakeInputDeviceSettings();
177 }
169 return g_instance; 178 return g_instance;
170 } 179 }
171 180
172 // static
173 void InputDeviceSettings::SetSettingsForTesting(
174 InputDeviceSettings* test_settings) {
175 if (g_test_instance == test_settings)
176 return;
177 delete g_test_instance;
178 g_test_instance = test_settings;
179 }
180
181 } // namespace system 181 } // namespace system
182 } // namespace chromeos 182 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698