| Index: chrome/browser/chromeos/system/input_device_settings_ozone.cc
|
| diff --git a/chrome/browser/chromeos/system/input_device_settings.cc b/chrome/browser/chromeos/system/input_device_settings_ozone.cc
|
| similarity index 56%
|
| copy from chrome/browser/chromeos/system/input_device_settings.cc
|
| copy to chrome/browser/chromeos/system/input_device_settings_ozone.cc
|
| index 744c92634aa75f4ec8f318a9b90b82085ac53252..a80627a9fa5c1df93c8016b56937f74115899055 100644
|
| --- a/chrome/browser/chromeos/system/input_device_settings.cc
|
| +++ b/chrome/browser/chromeos/system/input_device_settings_ozone.cc
|
| @@ -24,6 +24,10 @@
|
| #include "chrome/common/pref_names.h"
|
| #include "chromeos/system/statistics_provider.h"
|
| #include "content/public/browser/browser_thread.h"
|
| +#include "ui/events/ozone/event_factory_ozone.h"
|
| +#include "ui/ozone/ozone_platform.h"
|
| +
|
| +#include "base/debug/stack_trace.h"
|
|
|
| namespace chromeos {
|
| namespace system {
|
| @@ -33,108 +37,110 @@ namespace {
|
| InputDeviceSettings* g_instance_;
|
| InputDeviceSettings* g_test_instance_;
|
|
|
| -const char kDeviceTypeTouchpad[] = "touchpad";
|
| -const char kDeviceTypeMouse[] = "mouse";
|
| -const char kInputControl[] = "/opt/google/input/inputcontrol";
|
| +//const char kDeviceTypeTouchpad[] = "touchpad";
|
| +//const char kDeviceTypeMouse[] = "mouse";
|
| +//const char kInputControl[] = "/opt/google/input/inputcontrol";
|
| +
|
| +const char kRemoraRequisition[] = "remora";
|
|
|
| typedef base::RefCountedData<bool> RefCountedBool;
|
|
|
| -bool ScriptExists(const std::string& script) {
|
| - DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
|
| - return base::PathExists(base::FilePath(script));
|
| -}
|
| +//bool ScriptExists(const std::string& script) {
|
| +// DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
|
| +// return base::PathExists(base::FilePath(script));
|
| +//}
|
|
|
| // Executes the input control script asynchronously, if it exists.
|
| -void ExecuteScriptOnFileThread(const std::vector<std::string>& argv) {
|
| - DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
|
| - DCHECK(!argv.empty());
|
| - const std::string& script(argv[0]);
|
| -
|
| - // Script must exist on device.
|
| - DCHECK(!base::SysInfo::IsRunningOnChromeOS() || ScriptExists(script));
|
| -
|
| - if (!ScriptExists(script))
|
| - return;
|
| -
|
| - base::ProcessHandle handle;
|
| - base::LaunchProcess(CommandLine(argv), base::LaunchOptions(), &handle);
|
| - base::EnsureProcessGetsReaped(handle);
|
| -}
|
| -
|
| -void ExecuteScript(const std::vector<std::string>& argv) {
|
| - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
|
| -
|
| - if (argv.size() == 1)
|
| - return;
|
| -
|
| - VLOG(1) << "About to launch: \""
|
| - << CommandLine(argv).GetCommandLineString() << "\"";
|
| -
|
| - // Control scripts can take long enough to cause SIGART during shutdown
|
| - // (http://crbug.com/261426). Run the blocking pool task with
|
| - // CONTINUE_ON_SHUTDOWN so it won't be joined when Chrome shuts down.
|
| - base::SequencedWorkerPool* pool = content::BrowserThread::GetBlockingPool();
|
| - scoped_refptr<base::TaskRunner> runner =
|
| - pool->GetTaskRunnerWithShutdownBehavior(
|
| - base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN);
|
| - runner->PostTask(FROM_HERE, base::Bind(&ExecuteScriptOnFileThread, argv));
|
| -}
|
| -
|
| -void AddSensitivityArguments(const char* device_type, int value,
|
| - std::vector<std::string>* argv) {
|
| - DCHECK(value >= kMinPointerSensitivity && value <= kMaxPointerSensitivity);
|
| - argv->push_back(base::StringPrintf("--%s_sensitivity=%d",
|
| - device_type, value));
|
| -}
|
| -
|
| -void AddTPControlArguments(const char* control,
|
| - bool enabled,
|
| - std::vector<std::string>* argv) {
|
| - argv->push_back(base::StringPrintf("--%s=%d", control, enabled ? 1 : 0));
|
| -}
|
| -
|
| -void DeviceExistsBlockingPool(const char* device_type,
|
| - scoped_refptr<RefCountedBool> exists) {
|
| - DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
|
| - exists->data = false;
|
| - if (!ScriptExists(kInputControl))
|
| - return;
|
| -
|
| - std::vector<std::string> argv;
|
| - argv.push_back(kInputControl);
|
| - argv.push_back(base::StringPrintf("--type=%s", device_type));
|
| - argv.push_back("--list");
|
| - std::string output;
|
| - // Output is empty if the device is not found.
|
| - exists->data = base::GetAppOutput(CommandLine(argv), &output) &&
|
| - !output.empty();
|
| - DVLOG(1) << "DeviceExistsBlockingPool:" << device_type << "=" << exists->data;
|
| -}
|
| -
|
| -void RunCallbackUIThread(
|
| - scoped_refptr<RefCountedBool> exists,
|
| - const InputDeviceSettings::DeviceExistsCallback& callback) {
|
| - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
|
| - DVLOG(1) << "RunCallbackUIThread " << exists->data;
|
| - callback.Run(exists->data);
|
| -}
|
| -
|
| -void DeviceExists(const char* script,
|
| - const InputDeviceSettings::DeviceExistsCallback& callback) {
|
| - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
|
| -
|
| - // One or both of the control scripts can apparently hang during shutdown
|
| - // (http://crbug.com/255546). Run the blocking pool task with
|
| - // CONTINUE_ON_SHUTDOWN so it won't be joined when Chrome shuts down.
|
| - scoped_refptr<RefCountedBool> exists(new RefCountedBool(false));
|
| - base::SequencedWorkerPool* pool = content::BrowserThread::GetBlockingPool();
|
| - scoped_refptr<base::TaskRunner> runner =
|
| - pool->GetTaskRunnerWithShutdownBehavior(
|
| - base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN);
|
| - runner->PostTaskAndReply(FROM_HERE,
|
| - base::Bind(&DeviceExistsBlockingPool, script, exists),
|
| - base::Bind(&RunCallbackUIThread, exists, callback));
|
| -}
|
| +//void ExecuteScriptOnFileThread(const std::vector<std::string>& argv) {
|
| +// DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
|
| +// DCHECK(!argv.empty());
|
| +// const std::string& script(argv[0]);
|
| +//
|
| +// // Script must exist on device.
|
| +// DCHECK(!base::SysInfo::IsRunningOnChromeOS() || ScriptExists(script));
|
| +//
|
| +// if (!ScriptExists(script))
|
| +// return;
|
| +//
|
| +// base::ProcessHandle handle;
|
| +// base::LaunchProcess(CommandLine(argv), base::LaunchOptions(), &handle);
|
| +// base::EnsureProcessGetsReaped(handle);
|
| +//}
|
| +
|
| +//void ExecuteScript(const std::vector<std::string>& argv) {
|
| +// DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
|
| +//
|
| +// if (argv.size() == 1)
|
| +// return;
|
| +//
|
| +// VLOG(1) << "About to launch: \""
|
| +// << CommandLine(argv).GetCommandLineString() << "\"";
|
| +//
|
| +// // Control scripts can take long enough to cause SIGART during shutdown
|
| +// // (http://crbug.com/261426). Run the blocking pool task with
|
| +// // CONTINUE_ON_SHUTDOWN so it won't be joined when Chrome shuts down.
|
| +// base::SequencedWorkerPool* pool = content::BrowserThread::GetBlockingPool();
|
| +// scoped_refptr<base::TaskRunner> runner =
|
| +// pool->GetTaskRunnerWithShutdownBehavior(
|
| +// base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN);
|
| +// runner->PostTask(FROM_HERE, base::Bind(&ExecuteScriptOnFileThread, argv));
|
| +//}
|
| +
|
| +//void AddSensitivityArguments(const char* device_type, int value,
|
| +// std::vector<std::string>* argv) {
|
| +// DCHECK(value >= kMinPointerSensitivity && value <= kMaxPointerSensitivity);
|
| +// argv->push_back(base::StringPrintf("--%s_sensitivity=%d",
|
| +// device_type, value));
|
| +//}
|
| +//
|
| +//void AddTPControlArguments(const char* control,
|
| +// bool enabled,
|
| +// std::vector<std::string>* argv) {
|
| +// argv->push_back(base::StringPrintf("--%s=%d", control, enabled ? 1 : 0));
|
| +//}
|
| +//
|
| +//void DeviceExistsBlockingPool(const char* device_type,
|
| +// scoped_refptr<RefCountedBool> exists) {
|
| +// DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
|
| +// exists->data = false;
|
| +// if (!ScriptExists(kInputControl))
|
| +// return;
|
| +//
|
| +// std::vector<std::string> argv;
|
| +// argv.push_back(kInputControl);
|
| +// argv.push_back(base::StringPrintf("--type=%s", device_type));
|
| +// argv.push_back("--list");
|
| +// std::string output;
|
| +// // Output is empty if the device is not found.
|
| +// exists->data = base::GetAppOutput(CommandLine(argv), &output) &&
|
| +// !output.empty();
|
| +// DVLOG(1) << "DeviceExistsBlockingPool:" << device_type << "=" << exists->data;
|
| +//}
|
| +//
|
| +//void RunCallbackUIThread(
|
| +// scoped_refptr<RefCountedBool> exists,
|
| +// const InputDeviceSettings::DeviceExistsCallback& callback) {
|
| +// DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
|
| +// DVLOG(1) << "RunCallbackUIThread " << exists->data;
|
| +// callback.Run(exists->data);
|
| +//}
|
| +
|
| +//void DeviceExists(const char* script,
|
| +// const InputDeviceSettings::DeviceExistsCallback& callback) {
|
| +// DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
|
| +//
|
| +// // One or both of the control scripts can apparently hang during shutdown
|
| +// // (http://crbug.com/255546). Run the blocking pool task with
|
| +// // CONTINUE_ON_SHUTDOWN so it won't be joined when Chrome shuts down.
|
| +// scoped_refptr<RefCountedBool> exists(new RefCountedBool(false));
|
| +// base::SequencedWorkerPool* pool = content::BrowserThread::GetBlockingPool();
|
| +// scoped_refptr<base::TaskRunner> runner =
|
| +// pool->GetTaskRunnerWithShutdownBehavior(
|
| +// base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN);
|
| +// runner->PostTaskAndReply(FROM_HERE,
|
| +// base::Bind(&DeviceExistsBlockingPool, script, exists),
|
| +// base::Bind(&RunCallbackUIThread, exists, callback));
|
| +//}
|
|
|
| class InputDeviceSettingsImpl : public InputDeviceSettings {
|
| public:
|
| @@ -169,14 +175,21 @@ InputDeviceSettingsImpl::InputDeviceSettingsImpl() {}
|
|
|
| void InputDeviceSettingsImpl::TouchpadExists(
|
| const DeviceExistsCallback& callback) {
|
| - DeviceExists(kDeviceTypeTouchpad, callback);
|
| +
|
| +
|
| + DLOG(INFO) << "<<\n<<\nInputDeviceSettingsImpl::TouchpadExists\n";
|
| +
|
| + if (ui::OzonePlatform::GetInstance()->GetEventFactoryOzone()->HasIndirectTouch()) {
|
| +
|
| + DLOG(INFO) << "<<\n<<\nInputDeviceSettingsImpl::TouchpadExists check!!\n";
|
| +
|
| + callback.Run(true);
|
| + }
|
| }
|
|
|
| void InputDeviceSettingsImpl::UpdateTouchpadSettings(
|
| const TouchpadSettings& settings) {
|
| - std::vector<std::string> argv;
|
| - if (current_touchpad_settings_.Update(settings, &argv))
|
| - ExecuteScript(argv);
|
| + current_touchpad_settings_.Update(settings);
|
| }
|
|
|
| void InputDeviceSettingsImpl::SetTouchpadSensitivity(int value) {
|
| @@ -212,14 +225,24 @@ void InputDeviceSettingsImpl::SetTapDragging(bool enabled) {
|
|
|
| void InputDeviceSettingsImpl::MouseExists(
|
| const DeviceExistsCallback& callback) {
|
| - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
|
| - DeviceExists(kDeviceTypeMouse, callback);
|
| +// DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
|
| +// DeviceExists(kDeviceTypeMouse, callback);
|
| +
|
| + // DOH!
|
| + if (ui::OzonePlatform::GetInstance()->GetEventFactoryOzone()->HasRelXY()) {
|
| + callback.Run(true);
|
| + }
|
| }
|
|
|
| void InputDeviceSettingsImpl::UpdateMouseSettings(const MouseSettings& update) {
|
| - std::vector<std::string> argv;
|
| - if (current_mouse_settings_.Update(update, &argv))
|
| - ExecuteScript(argv);
|
| +
|
| + base::debug::StackTrace st;
|
| + st.Print();
|
| +
|
| + NOTIMPLEMENTED();
|
| +// std::vector<std::string> argv;
|
| +// if (current_mouse_settings_.Update(update, &argv))
|
| +// ExecuteScript(argv);
|
| }
|
|
|
| void InputDeviceSettingsImpl::SetMouseSensitivity(int value) {
|
| @@ -245,8 +268,8 @@ bool InputDeviceSettingsImpl::ForceKeyboardDrivenUINavigation() {
|
| if (!policy_manager)
|
| return false;
|
|
|
| - if (policy_manager->IsRemoraRequisition() ||
|
| - policy_manager->IsSharkRequisition()) {
|
| + if (base::strcasecmp(policy_manager->GetDeviceRequisition().c_str(),
|
| + kRemoraRequisition) == 0) {
|
| return true;
|
| }
|
|
|
| @@ -326,40 +349,38 @@ bool TouchpadSettings::GetTapDragging() const {
|
| return tap_dragging_.value();
|
| }
|
|
|
| -bool TouchpadSettings::Update(const TouchpadSettings& settings,
|
| - std::vector<std::string>* argv) {
|
| - if (argv)
|
| - argv->push_back(kInputControl);
|
| +bool TouchpadSettings::Update(const TouchpadSettings& settings) {
|
| +
|
| + ui::EventFactoryOzone::IndirectTouchConfiguration conf, mask;
|
| bool updated = false;
|
| if (sensitivity_.Update(settings.sensitivity_)) {
|
| updated = true;
|
| - if (argv)
|
| - AddSensitivityArguments(kDeviceTypeTouchpad, sensitivity_.value(), argv);
|
| + conf.sensitivity_ = sensitivity_.value();
|
| + mask.sensitivity_ = 1;
|
| }
|
| +
|
| if (tap_to_click_.Update(settings.tap_to_click_)) {
|
| updated = true;
|
| - if (argv)
|
| - AddTPControlArguments("tapclick", tap_to_click_.value(), argv);
|
| - }
|
| + conf.tap_to_click_ = tap_to_click_.value();
|
| + mask.tap_to_click_ = 1;
|
| + }
|
| if (three_finger_click_.Update(settings.three_finger_click_)) {
|
| updated = true;
|
| - if (argv)
|
| - AddTPControlArguments("t5r2_three_finger_click",
|
| - three_finger_click_.value(),
|
| - argv);
|
| + conf.three_finger_click_ = three_finger_click_.value();
|
| + mask.three_finger_click_ = 1;
|
| }
|
| if (tap_dragging_.Update(settings.tap_dragging_)) {
|
| updated = true;
|
| - if (argv)
|
| - AddTPControlArguments("tapdrag", tap_dragging_.value(), argv);
|
| + conf.tap_dragging_ = tap_dragging_.value();
|
| + mask.tap_dragging_ = 1;
|
| }
|
| if (natural_scroll_.Update(settings.natural_scroll_)) {
|
| updated = true;
|
| - if (argv)
|
| - AddTPControlArguments("australian_scrolling", natural_scroll_.value(),
|
| - argv);
|
| + conf.natural_scroll_ = natural_scroll_.value();
|
| + mask.natural_scroll_ = 1;
|
| }
|
| - return updated;
|
| + ui::OzonePlatform::GetInstance()->GetEventFactoryOzone()->ConfigureIndirectTouchEventConverters(conf, mask);
|
| + return updated;
|
| }
|
|
|
| MouseSettings::MouseSettings() {}
|
| @@ -388,24 +409,21 @@ bool MouseSettings::GetPrimaryButtonRight() const {
|
| return primary_button_right_.value();
|
| }
|
|
|
| -bool MouseSettings::Update(const MouseSettings& settings,
|
| - std::vector<std::string>* argv) {
|
| - if (argv)
|
| - argv->push_back(kInputControl);
|
| +bool MouseSettings::Update(const MouseSettings& settings) {
|
| + ui::EventFactoryOzone::RelXYConfiguration conf, mask;
|
| bool updated = false;
|
| if (sensitivity_.Update(settings.sensitivity_)) {
|
| updated = true;
|
| - if (argv)
|
| - AddSensitivityArguments(kDeviceTypeMouse, sensitivity_.value(), argv);
|
| + conf.sensitivity_ = sensitivity_.value();
|
| + mask.sensitivity_ = 1;
|
| }
|
| if (primary_button_right_.Update(settings.primary_button_right_)) {
|
| updated = true;
|
| - if (argv) {
|
| - AddTPControlArguments("mouse_swap_lr", primary_button_right_.value(),
|
| - argv);
|
| - }
|
| + conf.primary_button_right_ = primary_button_right_.value();
|
| + mask.primary_button_right_ = 1;
|
| }
|
| - return updated;
|
| + ui::OzonePlatform::GetInstance()->GetEventFactoryOzone()->ConfigureRelXYEventConverters(conf, mask);
|
| + return updated;
|
| }
|
|
|
| // static
|
|
|