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

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: cleanup 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 "chrome/browser/chromeos/system/fake_input_device_settings.h"
8 #include "content/public/browser/browser_thread.h" 9 #include "content/public/browser/browser_thread.h"
9 #include "ui/ozone/public/input_controller.h" 10 #include "ui/ozone/public/input_controller.h"
10 #include "ui/ozone/public/ozone_platform.h" 11 #include "ui/ozone/public/ozone_platform.h"
11 12
12 #if defined(MOJO_SHELL_CLIENT) 13 #if defined(MOJO_SHELL_CLIENT)
13 #include "services/shell/runner/common/client_util.h" 14 #include "services/shell/runner/common/client_util.h"
14 #endif 15 #endif
15 16
16 namespace chromeos { 17 namespace chromeos {
17 namespace system { 18 namespace system {
18 19
19 namespace { 20 namespace {
20 21
21 InputDeviceSettings* g_instance = nullptr; 22 InputDeviceSettings* g_instance = nullptr;
22 InputDeviceSettings* g_test_instance = nullptr; 23 FakeInputDeviceSettings* 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 // static 164 // static
164 InputDeviceSettings* InputDeviceSettings::Get() { 165 InputDeviceSettings* InputDeviceSettings::Get() {
165 if (g_test_instance) 166 if (g_test_instance)
166 return g_test_instance; 167 return g_test_instance;
167 if (!g_instance) 168 if (!g_instance)
168 g_instance = new InputDeviceSettingsImplOzone; 169 g_instance = new InputDeviceSettingsImplOzone;
169 return g_instance; 170 return g_instance;
170 } 171 }
171 172
172 // static 173 // static
174 FakeInputDeviceSettings* InputDeviceSettings::GetForTesting() {
175 if (!g_test_instance)
176 g_test_instance = new FakeInputDeviceSettings();
177 return g_test_instance;
178 }
179
180 // static
173 void InputDeviceSettings::SetSettingsForTesting( 181 void InputDeviceSettings::SetSettingsForTesting(
174 InputDeviceSettings* test_settings) { 182 FakeInputDeviceSettings* test_settings) {
175 if (g_test_instance == test_settings) 183 if (g_test_instance == test_settings)
176 return; 184 return;
177 delete g_test_instance; 185 delete g_test_instance;
178 g_test_instance = test_settings; 186 g_test_instance = test_settings;
179 } 187 }
stevenjb 2016/06/30 00:17:30 So all of this logic should just be in input_devic
180 188
181 } // namespace system 189 } // namespace system
182 } // namespace chromeos 190 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698