| 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 <stdarg.h> | 7 #include <stdarg.h> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/chromeos/chromeos_version.h" |
| 12 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 13 #include "base/file_path.h" | 14 #include "base/file_path.h" |
| 14 #include "base/file_util.h" | 15 #include "base/file_util.h" |
| 15 #include "base/message_loop.h" | 16 #include "base/message_loop.h" |
| 16 #include "base/process_util.h" | 17 #include "base/process_util.h" |
| 17 #include "base/stringprintf.h" | 18 #include "base/stringprintf.h" |
| 18 #include "chrome/browser/chromeos/system/runtime_environment.h" | |
| 19 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
| 20 | 20 |
| 21 using content::BrowserThread; | 21 using content::BrowserThread; |
| 22 | 22 |
| 23 namespace chromeos { | 23 namespace chromeos { |
| 24 namespace system { | 24 namespace system { |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 const char kTpControl[] = "/opt/google/touchpad/tpcontrol"; | 27 const char kTpControl[] = "/opt/google/touchpad/tpcontrol"; |
| 28 const char kMouseControl[] = "/opt/google/mouse/mousecontrol"; | 28 const char kMouseControl[] = "/opt/google/mouse/mousecontrol"; |
| 29 | 29 |
| 30 bool ScriptExists(const std::string& script) { | 30 bool ScriptExists(const std::string& script) { |
| 31 return file_util::PathExists(FilePath(script)); | 31 return file_util::PathExists(FilePath(script)); |
| 32 } | 32 } |
| 33 | 33 |
| 34 // Executes the input control script asynchronously, if it exists. | 34 // Executes the input control script asynchronously, if it exists. |
| 35 void ExecuteScriptOnFileThread(const std::vector<std::string>& argv) { | 35 void ExecuteScriptOnFileThread(const std::vector<std::string>& argv) { |
| 36 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 36 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 37 DCHECK(!argv.empty()); | 37 DCHECK(!argv.empty()); |
| 38 const std::string& script(argv[0]); | 38 const std::string& script(argv[0]); |
| 39 | 39 |
| 40 // Script must exist on device. | 40 // Script must exist on device. |
| 41 DCHECK(!runtime_environment::IsRunningOnChromeOS() || ScriptExists(script)); | 41 DCHECK(!base::chromeos::IsRunningOnChromeOS() || ScriptExists(script)); |
| 42 | 42 |
| 43 if (!ScriptExists(script)) | 43 if (!ScriptExists(script)) |
| 44 return; | 44 return; |
| 45 | 45 |
| 46 base::LaunchOptions options; | 46 base::LaunchOptions options; |
| 47 options.wait = true; | 47 options.wait = true; |
| 48 base::LaunchProcess(CommandLine(argv), options, NULL); | 48 base::LaunchProcess(CommandLine(argv), options, NULL); |
| 49 } | 49 } |
| 50 | 50 |
| 51 void ExecuteScript(int argc, ...) { | 51 void ExecuteScript(int argc, ...) { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 } | 120 } |
| 121 | 121 |
| 122 void SetPrimaryButtonRight(bool right) { | 122 void SetPrimaryButtonRight(bool right) { |
| 123 ExecuteScript(3, kMouseControl, "swap_left_right", right ? "1" : "0"); | 123 ExecuteScript(3, kMouseControl, "swap_left_right", right ? "1" : "0"); |
| 124 } | 124 } |
| 125 | 125 |
| 126 } // namespace mouse_settings | 126 } // namespace mouse_settings |
| 127 | 127 |
| 128 } // namespace system | 128 } // namespace system |
| 129 } // namespace chromeos | 129 } // namespace chromeos |
| OLD | NEW |