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

Unified Diff: chrome/browser/chromeos/system/input_device_settings.cc

Issue 9004033: Rename touchpad_settings.* to input_device_settings.* (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: review feedback Created 9 years 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/system/input_device_settings.cc
===================================================================
--- chrome/browser/chromeos/system/input_device_settings.cc (revision 0)
+++ chrome/browser/chromeos/system/input_device_settings.cc (revision 0)
@@ -0,0 +1,111 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/system/input_device_settings.h"
+
+#include <string>
+#include <vector>
+
+#include "base/bind.h"
+#include "base/command_line.h"
+#include "base/file_path.h"
+#include "base/file_util.h"
+#include "base/message_loop.h"
+#include "base/process_util.h"
+#include "base/stringprintf.h"
+#include "chrome/browser/chromeos/system/runtime_environment.h"
+#include "content/public/browser/browser_thread.h"
+
+using content::BrowserThread;
+
+namespace chromeos {
+namespace system {
+
+namespace touchpad_settings {
+namespace {
+const char* kTpControl = "/opt/google/touchpad/tpcontrol";
+
+bool TPCtrlExists() {
+ return file_util::PathExists(FilePath(kTpControl));
+}
+
+// Launches the tpcontrol command asynchronously, if it exists.
+void LaunchTpControl(const std::vector<std::string>& argv) {
+ if (!TPCtrlExists())
+ return;
+
+ base::LaunchOptions options;
+ options.wait = true;
+ base::LaunchProcess(CommandLine(argv), options, NULL);
+}
+
+} // namespace
+
+bool TouchpadExists() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
+ static bool init = false;
+ static bool exists = false;
+
+ if (init)
+ return exists;
+
+ init = true;
+ if (!TPCtrlExists())
+ return exists;
+
+ std::vector<std::string> argv;
+ argv.push_back(kTpControl);
+ argv.push_back("status");
+ std::string output;
+ // On devices with no touchpad, output is empty.
+ exists = base::GetAppOutput(CommandLine(argv), &output) && !output.empty();
+ return exists;
+}
+
+void SetSensitivity(int value) {
+ // Run this on the FILE thread.
+ if (!BrowserThread::CurrentlyOn(BrowserThread::FILE)) {
+ BrowserThread::PostTask(
+ BrowserThread::FILE, FROM_HERE,
+ base::Bind(&SetSensitivity, value));
+ return;
+ }
+
+ std::vector<std::string> argv;
+ argv.push_back(kTpControl);
+ argv.push_back("sensitivity");
+ argv.push_back(StringPrintf("%d", value));
+
+ LaunchTpControl(argv);
+}
+
+void SetTapToClick(bool enabled) {
+ // Run this on the FILE thread.
+ if (!BrowserThread::CurrentlyOn(BrowserThread::FILE)) {
+ BrowserThread::PostTask(
+ BrowserThread::FILE, FROM_HERE,
+ base::Bind(&SetTapToClick, enabled));
+ return;
+ }
+
+ std::vector<std::string> argv;
+ argv.push_back(kTpControl);
+ argv.push_back("taptoclick");
+ argv.push_back(enabled ? "on" : "off");
+
+ LaunchTpControl(argv);
+}
+
+} // namespace touchpad_settings
+
+namespace mouse_settings {
+
+void SetPrimaryButtonRight(bool right) {
+ // TODO(achuith, adlr): Call mouse_ctrl when it exists.
+}
+
+} // namespace mouse_settings
+
+} // namespace system
+} // namespace chromeos
Property changes on: chrome/browser/chromeos/system/input_device_settings.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « chrome/browser/chromeos/system/input_device_settings.h ('k') | chrome/browser/chromeos/system/touchpad_settings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698