| 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 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_XKEYBOARD_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_XKEYBOARD_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_XKEYBOARD_H_ | 6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_XKEYBOARD_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/memory/ref_counted.h" | |
| 13 | |
| 14 namespace base { | |
| 15 class SequencedTaskRunner; | |
| 16 } // namespace base | |
| 17 | 12 |
| 18 namespace chromeos { | 13 namespace chromeos { |
| 19 namespace input_method { | 14 namespace input_method { |
| 20 | 15 |
| 21 struct AutoRepeatRate { | 16 struct AutoRepeatRate { |
| 22 AutoRepeatRate() : initial_delay_in_ms(0), repeat_interval_in_ms(0) {} | 17 AutoRepeatRate() : initial_delay_in_ms(0), repeat_interval_in_ms(0) {} |
| 23 unsigned int initial_delay_in_ms; | 18 unsigned int initial_delay_in_ms; |
| 24 unsigned int repeat_interval_in_ms; | 19 unsigned int repeat_interval_in_ms; |
| 25 }; | 20 }; |
| 26 | 21 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 virtual unsigned int GetNumLockMask() = 0; | 92 virtual unsigned int GetNumLockMask() = 0; |
| 98 | 93 |
| 99 // Set true on |out_caps_lock_enabled| if Caps Lock is enabled. Set true on | 94 // Set true on |out_caps_lock_enabled| if Caps Lock is enabled. Set true on |
| 100 // |out_num_lock_enabled| if Num Lock is enabled. Both out parameters can be | 95 // |out_num_lock_enabled| if Num Lock is enabled. Both out parameters can be |
| 101 // NULL. Do not call the function from non-UI threads. | 96 // NULL. Do not call the function from non-UI threads. |
| 102 virtual void GetLockedModifiers(bool* out_caps_lock_enabled, | 97 virtual void GetLockedModifiers(bool* out_caps_lock_enabled, |
| 103 bool* out_num_lock_enabled) = 0; | 98 bool* out_num_lock_enabled) = 0; |
| 104 | 99 |
| 105 // Turns on and off the auto-repeat of the keyboard. Returns true on success. | 100 // Turns on and off the auto-repeat of the keyboard. Returns true on success. |
| 106 // Do not call the function from non-UI threads. | 101 // Do not call the function from non-UI threads. |
| 107 virtual bool SetAutoRepeatEnabled(bool enabled) = 0; | 102 // TODO(yusukes): Make this function non-static so we can mock it. |
| 103 static bool SetAutoRepeatEnabled(bool enabled); |
| 108 | 104 |
| 109 // Sets the auto-repeat rate of the keyboard, initial delay in ms, and repeat | 105 // Sets the auto-repeat rate of the keyboard, initial delay in ms, and repeat |
| 110 // interval in ms. Returns true on success. Do not call the function from | 106 // interval in ms. Returns true on success. Do not call the function from |
| 111 // non-UI threads. | 107 // non-UI threads. |
| 112 virtual bool SetAutoRepeatRate(const AutoRepeatRate& rate) = 0; | 108 // TODO(yusukes): Make this function non-static so we can mock it. |
| 109 static bool SetAutoRepeatRate(const AutoRepeatRate& rate); |
| 113 | 110 |
| 114 // Returns true if auto repeat is enabled. | 111 // Returns true if auto repeat is enabled. This function is protected: for |
| 112 // testability. |
| 115 static bool GetAutoRepeatEnabledForTesting(); | 113 static bool GetAutoRepeatEnabledForTesting(); |
| 116 | 114 |
| 117 // On success, set current auto repeat rate on |out_rate| and returns true. | 115 // On success, set current auto repeat rate on |out_rate| and returns true. |
| 118 // Returns false otherwise. | 116 // Returns false otherwise. This function is protected: for testability. |
| 119 static bool GetAutoRepeatRateForTesting(AutoRepeatRate* out_rate); | 117 static bool GetAutoRepeatRateForTesting(AutoRepeatRate* out_rate); |
| 120 | 118 |
| 121 // Returns false if |layout_name| contains a bad character. | 119 // Returns false if |layout_name| contains a bad character. |
| 122 static bool CheckLayoutNameForTesting(const std::string& layout_name); | 120 static bool CheckLayoutNameForTesting(const std::string& layout_name); |
| 123 | 121 |
| 124 // Creates an instance of XKeyboard. |default_task_runner| is used to verify | |
| 125 // thread-safe usage (all methods must be invoked in the context of | |
| 126 // default_task_runner). | |
| 127 // Note: At this moment, classes other than InputMethodManager should not | 122 // Note: At this moment, classes other than InputMethodManager should not |
| 128 // instantiate the XKeyboard class. | 123 // instantiate the XKeyboard class. |
| 129 static XKeyboard* Create( | 124 static XKeyboard* Create(const InputMethodUtil& util); |
| 130 const InputMethodUtil& util, | |
| 131 const scoped_refptr<base::SequencedTaskRunner>& default_task_runner); | |
| 132 }; | 125 }; |
| 133 | 126 |
| 134 } // namespace input_method | 127 } // namespace input_method |
| 135 } // namespace chromeos | 128 } // namespace chromeos |
| 136 | 129 |
| 137 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_XKEYBOARD_H_ | 130 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_XKEYBOARD_H_ |
| OLD | NEW |