summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsheckylin <sheckylin@chromium.org>2014-12-04 00:23:59 -0800
committerCommit bot <commit-bot@chromium.org>2014-12-04 08:24:19 +0000
commitac421dd51ab51be970f47a471baa69b0c8925bee (patch)
tree3a5e70633692c52c4620b23a4d6989887b77c96e
parentdde883097a6c4cb8b4d3c29364fbaa0775626d98 (diff)
downloadchromium_src-ac421dd51ab51be970f47a471baa69b0c8925bee.zip
chromium_src-ac421dd51ab51be970f47a471baa69b0c8925bee.tar.gz
chromium_src-ac421dd51ab51be970f47a471baa69b0c8925bee.tar.bz2
Add input device setting APIs to autotestPrivate
The CL adds APIs in autotestPrivate so that one can set input device settings from an autotest. These settings appears as touchpad/mouse related settings in the user preference page. Contributed by sheckylin@chromium.org BUG=434471,400022 TEST=Manual Review URL: https://codereview.chromium.org/764273002 Cr-Commit-Position: refs/heads/master@{#306785}
-rw-r--r--chrome/browser/chromeos/system/input_device_settings.h3
-rw-r--r--chrome/browser/extensions/api/autotest_private/autotest_private_api.cc97
-rw-r--r--chrome/browser/extensions/api/autotest_private/autotest_private_api.h77
-rw-r--r--chrome/common/extensions/api/autotest_private.idl28
-rw-r--r--chrome/test/data/extensions/api_test/autotest_private/test.js28
-rw-r--r--extensions/browser/extension_function_histogram_value.h7
-rw-r--r--tools/metrics/histograms/histograms.xml7
7 files changed, 246 insertions, 1 deletions
diff --git a/chrome/browser/chromeos/system/input_device_settings.h b/chrome/browser/chromeos/system/input_device_settings.h
index b6f2387..5807e9d 100644
--- a/chrome/browser/chromeos/system/input_device_settings.h
+++ b/chrome/browser/chromeos/system/input_device_settings.h
@@ -7,6 +7,7 @@
#include "base/callback.h"
#include "base/logging.h"
+#include "chromeos/chromeos_export.h"
namespace chromeos {
namespace system {
@@ -146,7 +147,7 @@ class MouseSettings {
};
// Interface for configuring input device settings.
-class InputDeviceSettings {
+class CHROMEOS_EXPORT InputDeviceSettings {
public:
typedef base::Callback<void(bool)> DeviceExistsCallback;
diff --git a/chrome/browser/extensions/api/autotest_private/autotest_private_api.cc b/chrome/browser/extensions/api/autotest_private/autotest_private_api.cc
index 70f540b0..834cda5 100644
--- a/chrome/browser/extensions/api/autotest_private/autotest_private_api.cc
+++ b/chrome/browser/extensions/api/autotest_private/autotest_private_api.cc
@@ -23,6 +23,7 @@
#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/login/lock/screen_locker.h"
+#include "chrome/browser/chromeos/system/input_device_settings.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/session_manager_client.h"
#include "components/user_manager/user.h"
@@ -224,6 +225,102 @@ bool AutotestPrivateSimulateAsanMemoryBugFunction::RunSync() {
return true;
}
+bool AutotestPrivateSetTouchpadSensitivityFunction::RunSync() {
+ scoped_ptr<api::autotest_private::SetTouchpadSensitivity::Params> params(
+ api::autotest_private::SetTouchpadSensitivity::Params::Create(*args_));
+ EXTENSION_FUNCTION_VALIDATE(params.get());
+
+ DVLOG(1) << "AutotestPrivateSetTouchpadSensitivityFunction " << params->value;
+
+#if defined(OS_CHROMEOS)
+ chromeos::system::InputDeviceSettings::Get()->SetTouchpadSensitivity(
+ params->value);
+#endif
+ return true;
+}
+
+bool AutotestPrivateSetTapToClickFunction::RunSync() {
+ scoped_ptr<api::autotest_private::SetTapToClick::Params> params(
+ api::autotest_private::SetTapToClick::Params::Create(*args_));
+ EXTENSION_FUNCTION_VALIDATE(params.get());
+
+ DVLOG(1) << "AutotestPrivateSetTapToClickFunction " << params->enabled;
+
+#if defined(OS_CHROMEOS)
+ chromeos::system::InputDeviceSettings::Get()->SetTapToClick(params->enabled);
+#endif
+ return true;
+}
+
+bool AutotestPrivateSetThreeFingerClickFunction::RunSync() {
+ scoped_ptr<api::autotest_private::SetThreeFingerClick::Params> params(
+ api::autotest_private::SetThreeFingerClick::Params::Create(*args_));
+ EXTENSION_FUNCTION_VALIDATE(params.get());
+
+ DVLOG(1) << "AutotestPrivateSetThreeFingerClickFunction " << params->enabled;
+
+#if defined(OS_CHROMEOS)
+ chromeos::system::InputDeviceSettings::Get()->SetThreeFingerClick(
+ params->enabled);
+#endif
+ return true;
+}
+
+bool AutotestPrivateSetTapDraggingFunction::RunSync() {
+ scoped_ptr<api::autotest_private::SetTapDragging::Params> params(
+ api::autotest_private::SetTapDragging::Params::Create(*args_));
+ EXTENSION_FUNCTION_VALIDATE(params.get());
+
+ DVLOG(1) << "AutotestPrivateSetTapDraggingFunction " << params->enabled;
+
+#if defined(OS_CHROMEOS)
+ chromeos::system::InputDeviceSettings::Get()->SetTapDragging(params->enabled);
+#endif
+ return true;
+}
+
+bool AutotestPrivateSetNaturalScrollFunction::RunSync() {
+ scoped_ptr<api::autotest_private::SetNaturalScroll::Params> params(
+ api::autotest_private::SetNaturalScroll::Params::Create(*args_));
+ EXTENSION_FUNCTION_VALIDATE(params.get());
+
+ DVLOG(1) << "AutotestPrivateSetNaturalScrollFunction " << params->enabled;
+
+#if defined(OS_CHROMEOS)
+ chromeos::system::InputDeviceSettings::Get()->SetNaturalScroll(
+ params->enabled);
+#endif
+ return true;
+}
+
+bool AutotestPrivateSetMouseSensitivityFunction::RunSync() {
+ scoped_ptr<api::autotest_private::SetMouseSensitivity::Params> params(
+ api::autotest_private::SetMouseSensitivity::Params::Create(*args_));
+ EXTENSION_FUNCTION_VALIDATE(params.get());
+
+ DVLOG(1) << "AutotestPrivateSetMouseSensitivityFunction " << params->value;
+
+#if defined(OS_CHROMEOS)
+ chromeos::system::InputDeviceSettings::Get()->SetMouseSensitivity(
+ params->value);
+#endif
+ return true;
+}
+
+bool AutotestPrivateSetPrimaryButtonRightFunction::RunSync() {
+ scoped_ptr<api::autotest_private::SetPrimaryButtonRight::Params> params(
+ api::autotest_private::SetPrimaryButtonRight::Params::Create(*args_));
+ EXTENSION_FUNCTION_VALIDATE(params.get());
+
+ DVLOG(1) << "AutotestPrivateSetPrimaryButtonRightFunction " << params->right;
+
+#if defined(OS_CHROMEOS)
+ chromeos::system::InputDeviceSettings::Get()->SetPrimaryButtonRight(
+ params->right);
+#endif
+ return true;
+}
+
static base::LazyInstance<BrowserContextKeyedAPIFactory<AutotestPrivateAPI> >
g_factory = LAZY_INSTANCE_INITIALIZER;
diff --git a/chrome/browser/extensions/api/autotest_private/autotest_private_api.h b/chrome/browser/extensions/api/autotest_private/autotest_private_api.h
index 37a5c35..089a023 100644
--- a/chrome/browser/extensions/api/autotest_private/autotest_private_api.h
+++ b/chrome/browser/extensions/api/autotest_private/autotest_private_api.h
@@ -83,6 +83,83 @@ class AutotestPrivateSimulateAsanMemoryBugFunction
bool RunSync() override;
};
+class AutotestPrivateSetTouchpadSensitivityFunction
+ : public ChromeSyncExtensionFunction {
+ public:
+ DECLARE_EXTENSION_FUNCTION("autotestPrivate.setTouchpadSensitivity",
+ AUTOTESTPRIVATE_SETTOUCHPADSENSITIVITY)
+
+ private:
+ ~AutotestPrivateSetTouchpadSensitivityFunction() override {}
+ bool RunSync() override;
+};
+
+class AutotestPrivateSetTapToClickFunction
+ : public ChromeSyncExtensionFunction {
+ public:
+ DECLARE_EXTENSION_FUNCTION("autotestPrivate.setTapToClick",
+ AUTOTESTPRIVATE_SETTAPTOCLICK)
+
+ private:
+ ~AutotestPrivateSetTapToClickFunction() override {}
+ bool RunSync() override;
+};
+
+class AutotestPrivateSetThreeFingerClickFunction
+ : public ChromeSyncExtensionFunction {
+ public:
+ DECLARE_EXTENSION_FUNCTION("autotestPrivate.setThreeFingerClick",
+ AUTOTESTPRIVATE_SETTHREEFINGERCLICK)
+
+ private:
+ ~AutotestPrivateSetThreeFingerClickFunction() override {}
+ bool RunSync() override;
+};
+
+class AutotestPrivateSetTapDraggingFunction
+ : public ChromeSyncExtensionFunction {
+ public:
+ DECLARE_EXTENSION_FUNCTION("autotestPrivate.setTapDragging",
+ AUTOTESTPRIVATE_SETTAPDRAGGING)
+
+ private:
+ ~AutotestPrivateSetTapDraggingFunction() override {}
+ bool RunSync() override;
+};
+
+class AutotestPrivateSetNaturalScrollFunction
+ : public ChromeSyncExtensionFunction {
+ public:
+ DECLARE_EXTENSION_FUNCTION("autotestPrivate.setNaturalScroll",
+ AUTOTESTPRIVATE_SETNATURALSCROLL)
+
+ private:
+ ~AutotestPrivateSetNaturalScrollFunction() override {}
+ bool RunSync() override;
+};
+
+class AutotestPrivateSetMouseSensitivityFunction
+ : public ChromeSyncExtensionFunction {
+ public:
+ DECLARE_EXTENSION_FUNCTION("autotestPrivate.setMouseSensitivity",
+ AUTOTESTPRIVATE_SETMOUSESENSITIVITY)
+
+ private:
+ ~AutotestPrivateSetMouseSensitivityFunction() override {}
+ bool RunSync() override;
+};
+
+class AutotestPrivateSetPrimaryButtonRightFunction
+ : public ChromeSyncExtensionFunction {
+ public:
+ DECLARE_EXTENSION_FUNCTION("autotestPrivate.setPrimaryButtonRight",
+ AUTOTESTPRIVATE_SETPRIMARYBUTTONRIGHT)
+
+ private:
+ ~AutotestPrivateSetPrimaryButtonRightFunction() override {}
+ bool RunSync() override;
+};
+
// Don't kill the browser when we're in a browser test.
void SetAutotestPrivateTest();
diff --git a/chrome/common/extensions/api/autotest_private.idl b/chrome/common/extensions/api/autotest_private.idl
index 578d9d3..6933284 100644
--- a/chrome/common/extensions/api/autotest_private.idl
+++ b/chrome/common/extensions/api/autotest_private.idl
@@ -75,5 +75,33 @@
// Simulates a memory access bug for asan testing.
static void simulateAsanMemoryBug();
+
+ // Set the touchpad pointer sensitivity setting.
+ // |value|: the pointer sensitivity setting index.
+ static void setTouchpadSensitivity(long value);
+
+ // Turn on/off tap-to-click for the touchpad.
+ // |enabled|: if set, enable tap-to-click.
+ static void setTapToClick(boolean enabled);
+
+ // Turn on/off three finger click for the touchpad.
+ // |enabled|: if set, enable three finger click.
+ static void setThreeFingerClick(boolean enabled);
+
+ // Turn on/off tap dragging for the touchpad.
+ // |enabled|: if set, enable tap dragging.
+ static void setTapDragging(boolean enabled);
+
+ // Turn on/off Australian scrolling for devices other than wheel mouse.
+ // |enabled|: if set, enable Australian scrolling.
+ static void setNaturalScroll(boolean enabled);
+
+ // Set the mouse pointer sensitivity setting.
+ // |value|: the pointer sensitivity setting index.
+ static void setMouseSensitivity(long value);
+
+ // Swap the primary mouse button for left click.
+ // |right|: if set, swap the primary mouse button.
+ static void setPrimaryButtonRight(boolean right);
};
};
diff --git a/chrome/test/data/extensions/api_test/autotest_private/test.js b/chrome/test/data/extensions/api_test/autotest_private/test.js
index 035d7c3..142077e 100644
--- a/chrome/test/data/extensions/api_test/autotest_private/test.js
+++ b/chrome/test/data/extensions/api_test/autotest_private/test.js
@@ -76,5 +76,33 @@ chrome.test.runTests([
chrome.test.assertTrue(extension.hasOwnProperty('hasPageAction'));
}
}));
+ },
+ function setTouchpadSensitivity() {
+ chrome.autotestPrivate.setTouchpadSensitivity(3);
+ chrome.test.succeed();
+ },
+ function setTapToClick() {
+ chrome.autotestPrivate.setTapToClick(true);
+ chrome.test.succeed();
+ },
+ function setThreeFingerClick() {
+ chrome.autotestPrivate.setThreeFingerClick(true);
+ chrome.test.succeed();
+ },
+ function setTapDragging() {
+ chrome.autotestPrivate.setTapDragging(false);
+ chrome.test.succeed();
+ },
+ function setNaturalScroll() {
+ chrome.autotestPrivate.setNaturalScroll(true);
+ chrome.test.succeed();
+ },
+ function setMouseSensitivity() {
+ chrome.autotestPrivate.setMouseSensitivity(3);
+ chrome.test.succeed();
+ },
+ function setPrimaryButtonRight() {
+ chrome.autotestPrivate.setPrimaryButtonRight(false);
+ chrome.test.succeed();
}
]);
diff --git a/extensions/browser/extension_function_histogram_value.h b/extensions/browser/extension_function_histogram_value.h
index bd492cc..7bc8e0d 100644
--- a/extensions/browser/extension_function_histogram_value.h
+++ b/extensions/browser/extension_function_histogram_value.h
@@ -988,6 +988,13 @@ enum HistogramValue {
APP_CURRENTWINDOWINTERNAL_SETINTERCEPTALLKEYS,
LAUNCHERPAGE_PUSHSUBPAGE,
LAUNCHERPAGE_SHOW,
+ AUTOTESTPRIVATE_SETTOUCHPADSENSITIVITY,
+ AUTOTESTPRIVATE_SETTAPTOCLICK,
+ AUTOTESTPRIVATE_SETTHREEFINGERCLICK,
+ AUTOTESTPRIVATE_SETTAPDRAGGING,
+ AUTOTESTPRIVATE_SETNATURALSCROLL,
+ AUTOTESTPRIVATE_SETMOUSESENSITIVITY,
+ AUTOTESTPRIVATE_SETPRIMARYBUTTONRIGHT,
// Last entry: Add new entries above and ensure to update
// tools/metrics/histograms/histograms.xml.
ENUM_BOUNDARY
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml
index cc59106..a1f1bcd 100644
--- a/tools/metrics/histograms/histograms.xml
+++ b/tools/metrics/histograms/histograms.xml
@@ -45504,6 +45504,13 @@ Therefore, the affected-histogram name has to have at least one dot in it.
<int value="927" label="APP_CURRENTWINDOWINTERNAL_SETINTERCEPTALLKEYS"/>
<int value="928" label="LAUNCHERPAGE_PUSHSUBPAGE"/>
<int value="929" label="LAUNCHERPAGE_SHOW"/>
+ <int value="930" label="AUTOTESTPRIVATE_SETTOUCHPADSENSITIVITY"/>
+ <int value="931" label="AUTOTESTPRIVATE_SETTAPTOCLICK"/>
+ <int value="932" label="AUTOTESTPRIVATE_SETTHREEFINGERCLICK"/>
+ <int value="933" label="AUTOTESTPRIVATE_SETTAPDRAGGING"/>
+ <int value="934" label="AUTOTESTPRIVATE_SETNATURALSCROLL"/>
+ <int value="935" label="AUTOTESTPRIVATE_SETMOUSESENSITIVITY"/>
+ <int value="936" label="AUTOTESTPRIVATE_SETPRIMARYBUTTONRIGHT"/>
</enum>
<enum name="ExtensionInstallCause" type="int">