| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "base/process/kill.h" | 13 #include "base/process/kill.h" |
| 14 #include "base/process/launch.h" | 14 #include "base/process/launch.h" |
| 15 #include "base/process/process_handle.h" | 15 #include "base/process/process_handle.h" |
| 16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 17 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
| 18 #include "base/sys_info.h" | 18 #include "base/sys_info.h" |
| 19 #include "base/task_runner.h" | 19 #include "base/task_runner.h" |
| 20 #include "base/threading/sequenced_worker_pool.h" | 20 #include "base/threading/sequenced_worker_pool.h" |
| 21 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
| 22 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 22 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 23 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" | 23 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" |
| 24 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
| 25 #include "chromeos/system/statistics_provider.h" | 25 #include "chromeos/system/statistics_provider.h" |
| 26 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
| 27 #include "ui/events/ozone/event_factory_ozone.h" |
| 28 #include "ui/ozone/ozone_platform.h" |
| 29 |
| 30 #include "base/debug/stack_trace.h" |
| 27 | 31 |
| 28 namespace chromeos { | 32 namespace chromeos { |
| 29 namespace system { | 33 namespace system { |
| 30 | 34 |
| 31 namespace { | 35 namespace { |
| 32 | 36 |
| 33 InputDeviceSettings* g_instance_; | 37 InputDeviceSettings* g_instance_; |
| 34 InputDeviceSettings* g_test_instance_; | 38 InputDeviceSettings* g_test_instance_; |
| 35 | 39 |
| 36 const char kDeviceTypeTouchpad[] = "touchpad"; | 40 //const char kDeviceTypeTouchpad[] = "touchpad"; |
| 37 const char kDeviceTypeMouse[] = "mouse"; | 41 //const char kDeviceTypeMouse[] = "mouse"; |
| 38 const char kInputControl[] = "/opt/google/input/inputcontrol"; | 42 //const char kInputControl[] = "/opt/google/input/inputcontrol"; |
| 43 |
| 44 const char kRemoraRequisition[] = "remora"; |
| 39 | 45 |
| 40 typedef base::RefCountedData<bool> RefCountedBool; | 46 typedef base::RefCountedData<bool> RefCountedBool; |
| 41 | 47 |
| 42 bool ScriptExists(const std::string& script) { | 48 //bool ScriptExists(const std::string& script) { |
| 43 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); | 49 // DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()
); |
| 44 return base::PathExists(base::FilePath(script)); | 50 // return base::PathExists(base::FilePath(script)); |
| 45 } | 51 //} |
| 46 | 52 |
| 47 // Executes the input control script asynchronously, if it exists. | 53 // Executes the input control script asynchronously, if it exists. |
| 48 void ExecuteScriptOnFileThread(const std::vector<std::string>& argv) { | 54 //void ExecuteScriptOnFileThread(const std::vector<std::string>& argv) { |
| 49 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); | 55 // DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()
); |
| 50 DCHECK(!argv.empty()); | 56 // DCHECK(!argv.empty()); |
| 51 const std::string& script(argv[0]); | 57 // const std::string& script(argv[0]); |
| 58 // |
| 59 // // Script must exist on device. |
| 60 // DCHECK(!base::SysInfo::IsRunningOnChromeOS() || ScriptExists(script)); |
| 61 // |
| 62 // if (!ScriptExists(script)) |
| 63 // return; |
| 64 // |
| 65 // base::ProcessHandle handle; |
| 66 // base::LaunchProcess(CommandLine(argv), base::LaunchOptions(), &handle); |
| 67 // base::EnsureProcessGetsReaped(handle); |
| 68 //} |
| 52 | 69 |
| 53 // Script must exist on device. | 70 //void ExecuteScript(const std::vector<std::string>& argv) { |
| 54 DCHECK(!base::SysInfo::IsRunningOnChromeOS() || ScriptExists(script)); | 71 // DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 72 // |
| 73 // if (argv.size() == 1) |
| 74 // return; |
| 75 // |
| 76 // VLOG(1) << "About to launch: \"" |
| 77 // << CommandLine(argv).GetCommandLineString() << "\""; |
| 78 // |
| 79 // // Control scripts can take long enough to cause SIGART during shutdown |
| 80 // // (http://crbug.com/261426). Run the blocking pool task with |
| 81 // // CONTINUE_ON_SHUTDOWN so it won't be joined when Chrome shuts down. |
| 82 // base::SequencedWorkerPool* pool = content::BrowserThread::GetBlockingPool(); |
| 83 // scoped_refptr<base::TaskRunner> runner = |
| 84 // pool->GetTaskRunnerWithShutdownBehavior( |
| 85 // base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); |
| 86 // runner->PostTask(FROM_HERE, base::Bind(&ExecuteScriptOnFileThread, argv)); |
| 87 //} |
| 55 | 88 |
| 56 if (!ScriptExists(script)) | 89 //void AddSensitivityArguments(const char* device_type, int value, |
| 57 return; | 90 // std::vector<std::string>* argv) { |
| 91 // DCHECK(value >= kMinPointerSensitivity && value <= kMaxPointerSensitivity); |
| 92 // argv->push_back(base::StringPrintf("--%s_sensitivity=%d", |
| 93 // device_type, value)); |
| 94 //} |
| 95 // |
| 96 //void AddTPControlArguments(const char* control, |
| 97 // bool enabled, |
| 98 // std::vector<std::string>* argv) { |
| 99 // argv->push_back(base::StringPrintf("--%s=%d", control, enabled ? 1 : 0)); |
| 100 //} |
| 101 // |
| 102 //void DeviceExistsBlockingPool(const char* device_type, |
| 103 // scoped_refptr<RefCountedBool> exists) { |
| 104 // DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()
); |
| 105 // exists->data = false; |
| 106 // if (!ScriptExists(kInputControl)) |
| 107 // return; |
| 108 // |
| 109 // std::vector<std::string> argv; |
| 110 // argv.push_back(kInputControl); |
| 111 // argv.push_back(base::StringPrintf("--type=%s", device_type)); |
| 112 // argv.push_back("--list"); |
| 113 // std::string output; |
| 114 // // Output is empty if the device is not found. |
| 115 // exists->data = base::GetAppOutput(CommandLine(argv), &output) && |
| 116 // !output.empty(); |
| 117 // DVLOG(1) << "DeviceExistsBlockingPool:" << device_type << "=" << exists->dat
a; |
| 118 //} |
| 119 // |
| 120 //void RunCallbackUIThread( |
| 121 // scoped_refptr<RefCountedBool> exists, |
| 122 // const InputDeviceSettings::DeviceExistsCallback& callback) { |
| 123 // DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 124 // DVLOG(1) << "RunCallbackUIThread " << exists->data; |
| 125 // callback.Run(exists->data); |
| 126 //} |
| 58 | 127 |
| 59 base::ProcessHandle handle; | 128 //void DeviceExists(const char* script, |
| 60 base::LaunchProcess(CommandLine(argv), base::LaunchOptions(), &handle); | 129 // const InputDeviceSettings::DeviceExistsCallback& callback) { |
| 61 base::EnsureProcessGetsReaped(handle); | 130 // DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 62 } | 131 // |
| 63 | 132 // // One or both of the control scripts can apparently hang during shutdown |
| 64 void ExecuteScript(const std::vector<std::string>& argv) { | 133 // // (http://crbug.com/255546). Run the blocking pool task with |
| 65 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 134 // // CONTINUE_ON_SHUTDOWN so it won't be joined when Chrome shuts down. |
| 66 | 135 // scoped_refptr<RefCountedBool> exists(new RefCountedBool(false)); |
| 67 if (argv.size() == 1) | 136 // base::SequencedWorkerPool* pool = content::BrowserThread::GetBlockingPool(); |
| 68 return; | 137 // scoped_refptr<base::TaskRunner> runner = |
| 69 | 138 // pool->GetTaskRunnerWithShutdownBehavior( |
| 70 VLOG(1) << "About to launch: \"" | 139 // base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); |
| 71 << CommandLine(argv).GetCommandLineString() << "\""; | 140 // runner->PostTaskAndReply(FROM_HERE, |
| 72 | 141 // base::Bind(&DeviceExistsBlockingPool, script, exists), |
| 73 // Control scripts can take long enough to cause SIGART during shutdown | 142 // base::Bind(&RunCallbackUIThread, exists, callback)); |
| 74 // (http://crbug.com/261426). Run the blocking pool task with | 143 //} |
| 75 // CONTINUE_ON_SHUTDOWN so it won't be joined when Chrome shuts down. | |
| 76 base::SequencedWorkerPool* pool = content::BrowserThread::GetBlockingPool(); | |
| 77 scoped_refptr<base::TaskRunner> runner = | |
| 78 pool->GetTaskRunnerWithShutdownBehavior( | |
| 79 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); | |
| 80 runner->PostTask(FROM_HERE, base::Bind(&ExecuteScriptOnFileThread, argv)); | |
| 81 } | |
| 82 | |
| 83 void AddSensitivityArguments(const char* device_type, int value, | |
| 84 std::vector<std::string>* argv) { | |
| 85 DCHECK(value >= kMinPointerSensitivity && value <= kMaxPointerSensitivity); | |
| 86 argv->push_back(base::StringPrintf("--%s_sensitivity=%d", | |
| 87 device_type, value)); | |
| 88 } | |
| 89 | |
| 90 void AddTPControlArguments(const char* control, | |
| 91 bool enabled, | |
| 92 std::vector<std::string>* argv) { | |
| 93 argv->push_back(base::StringPrintf("--%s=%d", control, enabled ? 1 : 0)); | |
| 94 } | |
| 95 | |
| 96 void DeviceExistsBlockingPool(const char* device_type, | |
| 97 scoped_refptr<RefCountedBool> exists) { | |
| 98 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); | |
| 99 exists->data = false; | |
| 100 if (!ScriptExists(kInputControl)) | |
| 101 return; | |
| 102 | |
| 103 std::vector<std::string> argv; | |
| 104 argv.push_back(kInputControl); | |
| 105 argv.push_back(base::StringPrintf("--type=%s", device_type)); | |
| 106 argv.push_back("--list"); | |
| 107 std::string output; | |
| 108 // Output is empty if the device is not found. | |
| 109 exists->data = base::GetAppOutput(CommandLine(argv), &output) && | |
| 110 !output.empty(); | |
| 111 DVLOG(1) << "DeviceExistsBlockingPool:" << device_type << "=" << exists->data; | |
| 112 } | |
| 113 | |
| 114 void RunCallbackUIThread( | |
| 115 scoped_refptr<RefCountedBool> exists, | |
| 116 const InputDeviceSettings::DeviceExistsCallback& callback) { | |
| 117 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | |
| 118 DVLOG(1) << "RunCallbackUIThread " << exists->data; | |
| 119 callback.Run(exists->data); | |
| 120 } | |
| 121 | |
| 122 void DeviceExists(const char* script, | |
| 123 const InputDeviceSettings::DeviceExistsCallback& callback) { | |
| 124 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | |
| 125 | |
| 126 // One or both of the control scripts can apparently hang during shutdown | |
| 127 // (http://crbug.com/255546). Run the blocking pool task with | |
| 128 // CONTINUE_ON_SHUTDOWN so it won't be joined when Chrome shuts down. | |
| 129 scoped_refptr<RefCountedBool> exists(new RefCountedBool(false)); | |
| 130 base::SequencedWorkerPool* pool = content::BrowserThread::GetBlockingPool(); | |
| 131 scoped_refptr<base::TaskRunner> runner = | |
| 132 pool->GetTaskRunnerWithShutdownBehavior( | |
| 133 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); | |
| 134 runner->PostTaskAndReply(FROM_HERE, | |
| 135 base::Bind(&DeviceExistsBlockingPool, script, exists), | |
| 136 base::Bind(&RunCallbackUIThread, exists, callback)); | |
| 137 } | |
| 138 | 144 |
| 139 class InputDeviceSettingsImpl : public InputDeviceSettings { | 145 class InputDeviceSettingsImpl : public InputDeviceSettings { |
| 140 public: | 146 public: |
| 141 InputDeviceSettingsImpl(); | 147 InputDeviceSettingsImpl(); |
| 142 | 148 |
| 143 private: | 149 private: |
| 144 // Overridden from InputDeviceSettings. | 150 // Overridden from InputDeviceSettings. |
| 145 virtual void TouchpadExists(const DeviceExistsCallback& callback) OVERRIDE; | 151 virtual void TouchpadExists(const DeviceExistsCallback& callback) OVERRIDE; |
| 146 virtual void UpdateTouchpadSettings(const TouchpadSettings& settings) | 152 virtual void UpdateTouchpadSettings(const TouchpadSettings& settings) |
| 147 OVERRIDE; | 153 OVERRIDE; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 162 TouchpadSettings current_touchpad_settings_; | 168 TouchpadSettings current_touchpad_settings_; |
| 163 MouseSettings current_mouse_settings_; | 169 MouseSettings current_mouse_settings_; |
| 164 | 170 |
| 165 DISALLOW_COPY_AND_ASSIGN(InputDeviceSettingsImpl); | 171 DISALLOW_COPY_AND_ASSIGN(InputDeviceSettingsImpl); |
| 166 }; | 172 }; |
| 167 | 173 |
| 168 InputDeviceSettingsImpl::InputDeviceSettingsImpl() {} | 174 InputDeviceSettingsImpl::InputDeviceSettingsImpl() {} |
| 169 | 175 |
| 170 void InputDeviceSettingsImpl::TouchpadExists( | 176 void InputDeviceSettingsImpl::TouchpadExists( |
| 171 const DeviceExistsCallback& callback) { | 177 const DeviceExistsCallback& callback) { |
| 172 DeviceExists(kDeviceTypeTouchpad, callback); | 178 |
| 179 |
| 180 » DLOG(INFO) << "<<\n<<\nInputDeviceSettingsImpl::TouchpadExists\n"; |
| 181 |
| 182 » if (ui::OzonePlatform::GetInstance()->GetEventFactoryOzone()->HasIndirec
tTouch()) { |
| 183 |
| 184 » DLOG(INFO) << "<<\n<<\nInputDeviceSettingsImpl::TouchpadExists check!!\n
"; |
| 185 |
| 186 » » callback.Run(true); |
| 187 » } |
| 173 } | 188 } |
| 174 | 189 |
| 175 void InputDeviceSettingsImpl::UpdateTouchpadSettings( | 190 void InputDeviceSettingsImpl::UpdateTouchpadSettings( |
| 176 const TouchpadSettings& settings) { | 191 const TouchpadSettings& settings) { |
| 177 std::vector<std::string> argv; | 192 » current_touchpad_settings_.Update(settings); |
| 178 if (current_touchpad_settings_.Update(settings, &argv)) | |
| 179 ExecuteScript(argv); | |
| 180 } | 193 } |
| 181 | 194 |
| 182 void InputDeviceSettingsImpl::SetTouchpadSensitivity(int value) { | 195 void InputDeviceSettingsImpl::SetTouchpadSensitivity(int value) { |
| 183 TouchpadSettings settings; | 196 TouchpadSettings settings; |
| 184 settings.SetSensitivity(value); | 197 settings.SetSensitivity(value); |
| 185 UpdateTouchpadSettings(settings); | 198 UpdateTouchpadSettings(settings); |
| 186 } | 199 } |
| 187 | 200 |
| 188 void InputDeviceSettingsImpl::SetNaturalScroll(bool enabled) { | 201 void InputDeviceSettingsImpl::SetNaturalScroll(bool enabled) { |
| 189 TouchpadSettings settings; | 202 TouchpadSettings settings; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 205 } | 218 } |
| 206 | 219 |
| 207 void InputDeviceSettingsImpl::SetTapDragging(bool enabled) { | 220 void InputDeviceSettingsImpl::SetTapDragging(bool enabled) { |
| 208 TouchpadSettings settings; | 221 TouchpadSettings settings; |
| 209 settings.SetTapDragging(enabled); | 222 settings.SetTapDragging(enabled); |
| 210 UpdateTouchpadSettings(settings); | 223 UpdateTouchpadSettings(settings); |
| 211 } | 224 } |
| 212 | 225 |
| 213 void InputDeviceSettingsImpl::MouseExists( | 226 void InputDeviceSettingsImpl::MouseExists( |
| 214 const DeviceExistsCallback& callback) { | 227 const DeviceExistsCallback& callback) { |
| 215 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 228 // DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 216 DeviceExists(kDeviceTypeMouse, callback); | 229 // DeviceExists(kDeviceTypeMouse, callback); |
| 230 |
| 231 » // DOH! |
| 232 » if (ui::OzonePlatform::GetInstance()->GetEventFactoryOzone()->HasRelXY()
) { |
| 233 » » callback.Run(true); |
| 234 » } |
| 217 } | 235 } |
| 218 | 236 |
| 219 void InputDeviceSettingsImpl::UpdateMouseSettings(const MouseSettings& update) { | 237 void InputDeviceSettingsImpl::UpdateMouseSettings(const MouseSettings& update) { |
| 220 std::vector<std::string> argv; | 238 |
| 221 if (current_mouse_settings_.Update(update, &argv)) | 239 » base::debug::StackTrace st; |
| 222 ExecuteScript(argv); | 240 » st.Print(); |
| 241 |
| 242 » NOTIMPLEMENTED(); |
| 243 // std::vector<std::string> argv; |
| 244 // if (current_mouse_settings_.Update(update, &argv)) |
| 245 // ExecuteScript(argv); |
| 223 } | 246 } |
| 224 | 247 |
| 225 void InputDeviceSettingsImpl::SetMouseSensitivity(int value) { | 248 void InputDeviceSettingsImpl::SetMouseSensitivity(int value) { |
| 226 MouseSettings settings; | 249 MouseSettings settings; |
| 227 settings.SetSensitivity(value); | 250 settings.SetSensitivity(value); |
| 228 UpdateMouseSettings(settings); | 251 UpdateMouseSettings(settings); |
| 229 } | 252 } |
| 230 | 253 |
| 231 void InputDeviceSettingsImpl::SetPrimaryButtonRight(bool right) { | 254 void InputDeviceSettingsImpl::SetPrimaryButtonRight(bool right) { |
| 232 MouseSettings settings; | 255 MouseSettings settings; |
| 233 settings.SetPrimaryButtonRight(right); | 256 settings.SetPrimaryButtonRight(right); |
| 234 UpdateMouseSettings(settings); | 257 UpdateMouseSettings(settings); |
| 235 } | 258 } |
| 236 | 259 |
| 237 bool InputDeviceSettingsImpl::ForceKeyboardDrivenUINavigation() { | 260 bool InputDeviceSettingsImpl::ForceKeyboardDrivenUINavigation() { |
| 238 policy::BrowserPolicyConnectorChromeOS* connector = | 261 policy::BrowserPolicyConnectorChromeOS* connector = |
| 239 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 262 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
| 240 if (!connector) | 263 if (!connector) |
| 241 return false; | 264 return false; |
| 242 | 265 |
| 243 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = | 266 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = |
| 244 connector->GetDeviceCloudPolicyManager(); | 267 connector->GetDeviceCloudPolicyManager(); |
| 245 if (!policy_manager) | 268 if (!policy_manager) |
| 246 return false; | 269 return false; |
| 247 | 270 |
| 248 if (policy_manager->IsRemoraRequisition() || | 271 if (base::strcasecmp(policy_manager->GetDeviceRequisition().c_str(), |
| 249 policy_manager->IsSharkRequisition()) { | 272 kRemoraRequisition) == 0) { |
| 250 return true; | 273 return true; |
| 251 } | 274 } |
| 252 | 275 |
| 253 bool keyboard_driven = false; | 276 bool keyboard_driven = false; |
| 254 if (chromeos::system::StatisticsProvider::GetInstance()->GetMachineFlag( | 277 if (chromeos::system::StatisticsProvider::GetInstance()->GetMachineFlag( |
| 255 kOemKeyboardDrivenOobeKey, &keyboard_driven)) { | 278 kOemKeyboardDrivenOobeKey, &keyboard_driven)) { |
| 256 return keyboard_driven; | 279 return keyboard_driven; |
| 257 } | 280 } |
| 258 | 281 |
| 259 return false; | 282 return false; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 } | 342 } |
| 320 | 343 |
| 321 void TouchpadSettings::SetTapDragging(bool enabled) { | 344 void TouchpadSettings::SetTapDragging(bool enabled) { |
| 322 tap_dragging_.Set(enabled); | 345 tap_dragging_.Set(enabled); |
| 323 } | 346 } |
| 324 | 347 |
| 325 bool TouchpadSettings::GetTapDragging() const { | 348 bool TouchpadSettings::GetTapDragging() const { |
| 326 return tap_dragging_.value(); | 349 return tap_dragging_.value(); |
| 327 } | 350 } |
| 328 | 351 |
| 329 bool TouchpadSettings::Update(const TouchpadSettings& settings, | 352 bool TouchpadSettings::Update(const TouchpadSettings& settings) { |
| 330 std::vector<std::string>* argv) { | 353 |
| 331 if (argv) | 354 » ui::EventFactoryOzone::IndirectTouchConfiguration conf, mask; |
| 332 argv->push_back(kInputControl); | |
| 333 bool updated = false; | 355 bool updated = false; |
| 334 if (sensitivity_.Update(settings.sensitivity_)) { | 356 if (sensitivity_.Update(settings.sensitivity_)) { |
| 335 updated = true; | 357 updated = true; |
| 336 if (argv) | 358 » conf.sensitivity_ = sensitivity_.value(); |
| 337 AddSensitivityArguments(kDeviceTypeTouchpad, sensitivity_.value(), argv); | 359 » mask.sensitivity_ = 1; |
| 338 } | 360 } |
| 361 |
| 339 if (tap_to_click_.Update(settings.tap_to_click_)) { | 362 if (tap_to_click_.Update(settings.tap_to_click_)) { |
| 340 updated = true; | 363 updated = true; |
| 341 if (argv) | 364 » conf.tap_to_click_ = tap_to_click_.value(); |
| 342 AddTPControlArguments("tapclick", tap_to_click_.value(), argv); | 365 » mask.tap_to_click_ = 1; |
| 343 } | 366 } |
| 344 if (three_finger_click_.Update(settings.three_finger_click_)) { | 367 if (three_finger_click_.Update(settings.three_finger_click_)) { |
| 345 updated = true; | 368 updated = true; |
| 346 if (argv) | 369 » conf.three_finger_click_ = three_finger_click_.value(); |
| 347 AddTPControlArguments("t5r2_three_finger_click", | 370 » mask.three_finger_click_ = 1; |
| 348 three_finger_click_.value(), | |
| 349 argv); | |
| 350 } | 371 } |
| 351 if (tap_dragging_.Update(settings.tap_dragging_)) { | 372 if (tap_dragging_.Update(settings.tap_dragging_)) { |
| 352 updated = true; | 373 updated = true; |
| 353 if (argv) | 374 » conf.tap_dragging_ = tap_dragging_.value(); |
| 354 AddTPControlArguments("tapdrag", tap_dragging_.value(), argv); | 375 » mask.tap_dragging_ = 1; |
| 355 } | 376 } |
| 356 if (natural_scroll_.Update(settings.natural_scroll_)) { | 377 if (natural_scroll_.Update(settings.natural_scroll_)) { |
| 357 updated = true; | 378 updated = true; |
| 358 if (argv) | 379 » conf.natural_scroll_ = natural_scroll_.value(); |
| 359 AddTPControlArguments("australian_scrolling", natural_scroll_.value(), | 380 » mask.natural_scroll_ = 1; |
| 360 argv); | |
| 361 } | 381 } |
| 362 return updated; | 382 » ui::OzonePlatform::GetInstance()->GetEventFactoryOzone()->ConfigureIndir
ectTouchEventConverters(conf, mask); |
| 383 » return updated; |
| 363 } | 384 } |
| 364 | 385 |
| 365 MouseSettings::MouseSettings() {} | 386 MouseSettings::MouseSettings() {} |
| 366 | 387 |
| 367 MouseSettings& MouseSettings::operator=(const MouseSettings& other) { | 388 MouseSettings& MouseSettings::operator=(const MouseSettings& other) { |
| 368 if (&other != this) { | 389 if (&other != this) { |
| 369 sensitivity_ = other.sensitivity_; | 390 sensitivity_ = other.sensitivity_; |
| 370 primary_button_right_ = other.primary_button_right_; | 391 primary_button_right_ = other.primary_button_right_; |
| 371 } | 392 } |
| 372 return *this; | 393 return *this; |
| 373 } | 394 } |
| 374 | 395 |
| 375 void MouseSettings::SetSensitivity(int value) { | 396 void MouseSettings::SetSensitivity(int value) { |
| 376 sensitivity_.Set(value); | 397 sensitivity_.Set(value); |
| 377 } | 398 } |
| 378 | 399 |
| 379 int MouseSettings::GetSensitivity() const { | 400 int MouseSettings::GetSensitivity() const { |
| 380 return sensitivity_.value(); | 401 return sensitivity_.value(); |
| 381 } | 402 } |
| 382 | 403 |
| 383 void MouseSettings::SetPrimaryButtonRight(bool right) { | 404 void MouseSettings::SetPrimaryButtonRight(bool right) { |
| 384 primary_button_right_.Set(right); | 405 primary_button_right_.Set(right); |
| 385 } | 406 } |
| 386 | 407 |
| 387 bool MouseSettings::GetPrimaryButtonRight() const { | 408 bool MouseSettings::GetPrimaryButtonRight() const { |
| 388 return primary_button_right_.value(); | 409 return primary_button_right_.value(); |
| 389 } | 410 } |
| 390 | 411 |
| 391 bool MouseSettings::Update(const MouseSettings& settings, | 412 bool MouseSettings::Update(const MouseSettings& settings) { |
| 392 std::vector<std::string>* argv) { | 413 » ui::EventFactoryOzone::RelXYConfiguration conf, mask; |
| 393 if (argv) | |
| 394 argv->push_back(kInputControl); | |
| 395 bool updated = false; | 414 bool updated = false; |
| 396 if (sensitivity_.Update(settings.sensitivity_)) { | 415 if (sensitivity_.Update(settings.sensitivity_)) { |
| 397 updated = true; | 416 updated = true; |
| 398 if (argv) | 417 » conf.sensitivity_ = sensitivity_.value(); |
| 399 AddSensitivityArguments(kDeviceTypeMouse, sensitivity_.value(), argv); | 418 » mask.sensitivity_ = 1; |
| 400 } | 419 } |
| 401 if (primary_button_right_.Update(settings.primary_button_right_)) { | 420 if (primary_button_right_.Update(settings.primary_button_right_)) { |
| 402 updated = true; | 421 updated = true; |
| 403 if (argv) { | 422 » conf.primary_button_right_ = primary_button_right_.value(); |
| 404 AddTPControlArguments("mouse_swap_lr", primary_button_right_.value(), | 423 » mask.primary_button_right_ = 1; |
| 405 argv); | |
| 406 } | |
| 407 } | 424 } |
| 408 return updated; | 425 » ui::OzonePlatform::GetInstance()->GetEventFactoryOzone()->ConfigureRelXY
EventConverters(conf, mask); |
| 426 » return updated; |
| 409 } | 427 } |
| 410 | 428 |
| 411 // static | 429 // static |
| 412 InputDeviceSettings* InputDeviceSettings::Get() { | 430 InputDeviceSettings* InputDeviceSettings::Get() { |
| 413 if (g_test_instance_) | 431 if (g_test_instance_) |
| 414 return g_test_instance_; | 432 return g_test_instance_; |
| 415 if (!g_instance_) | 433 if (!g_instance_) |
| 416 g_instance_ = new InputDeviceSettingsImpl; | 434 g_instance_ = new InputDeviceSettingsImpl; |
| 417 return g_instance_; | 435 return g_instance_; |
| 418 } | 436 } |
| 419 | 437 |
| 420 // static | 438 // static |
| 421 void InputDeviceSettings::SetSettingsForTesting( | 439 void InputDeviceSettings::SetSettingsForTesting( |
| 422 InputDeviceSettings* test_settings) { | 440 InputDeviceSettings* test_settings) { |
| 423 if (g_test_instance_ == test_settings) | 441 if (g_test_instance_ == test_settings) |
| 424 return; | 442 return; |
| 425 delete g_test_instance_; | 443 delete g_test_instance_; |
| 426 g_test_instance_ = test_settings; | 444 g_test_instance_ = test_settings; |
| 427 } | 445 } |
| 428 | 446 |
| 429 } // namespace system | 447 } // namespace system |
| 430 } // namespace chromeos | 448 } // namespace chromeos |
| OLD | NEW |