| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_TEST_CHROMEDRIVER_TEST_UTIL_H_ | 5 #ifndef CHROME_TEST_CHROMEDRIVER_TEST_UTIL_H_ |
| 6 #define CHROME_TEST_CHROMEDRIVER_TEST_UTIL_H_ | 6 #define CHROME_TEST_CHROMEDRIVER_TEST_UTIL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 | 11 |
| 12 #if defined(OS_WIN) | 12 #if defined(OS_WIN) |
| 13 #include <windows.h> | 13 #include <windows.h> |
| 14 #elif defined(OS_MACOSX) | 14 #elif defined(OS_MACOSX) |
| 15 #include <Carbon/Carbon.h> | 15 #include <Carbon/Carbon.h> |
| 16 #include "base/mac/scoped_cftyperef.h" | 16 #include "base/mac/scoped_cftyperef.h" |
| 17 #endif | 17 #endif |
| 18 | 18 |
| 19 // Restores the keyboard layout that was active at this object's creation | 19 // Restores the keyboard layout that was active at this object's creation |
| 20 // when this object goes out of scope. | 20 // when this object goes out of scope. |
| 21 class RestoreKeyboardLayoutOnDestruct { | 21 class RestoreKeyboardLayoutOnDestruct { |
| 22 public: | 22 public: |
| 23 RestoreKeyboardLayoutOnDestruct(); | 23 RestoreKeyboardLayoutOnDestruct(); |
| 24 ~RestoreKeyboardLayoutOnDestruct(); | 24 ~RestoreKeyboardLayoutOnDestruct(); |
| 25 | 25 |
| 26 private: | 26 private: |
| 27 #if defined(OS_WIN) | 27 #if defined(OS_WIN) |
| 28 HKL layout_; | 28 HKL layout_; |
| 29 #elif defined(OS_MACOSX) | 29 #elif defined(OS_MACOSX) |
| 30 base::mac::ScopedCFTypeRef<TISInputSourceRef> layout_; | 30 base::ScopedCFTypeRef<TISInputSourceRef> layout_; |
| 31 #endif | 31 #endif |
| 32 | 32 |
| 33 DISALLOW_COPY_AND_ASSIGN(RestoreKeyboardLayoutOnDestruct); | 33 DISALLOW_COPY_AND_ASSIGN(RestoreKeyboardLayoutOnDestruct); |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 #if defined(OS_WIN) | 36 #if defined(OS_WIN) |
| 37 // Loads and activates the given keyboard layout. |input_locale_identifier| | 37 // Loads and activates the given keyboard layout. |input_locale_identifier| |
| 38 // is composed of a device and language ID. Returns true on success. | 38 // is composed of a device and language ID. Returns true on success. |
| 39 // See http://msdn.microsoft.com/en-us/library/dd318693(v=vs.85).aspx | 39 // See http://msdn.microsoft.com/en-us/library/dd318693(v=vs.85).aspx |
| 40 // Example: "00000409" is the default en-us keyboard layout. | 40 // Example: "00000409" is the default en-us keyboard layout. |
| 41 bool SwitchKeyboardLayout(const std::string& input_locale_identifier); | 41 bool SwitchKeyboardLayout(const std::string& input_locale_identifier); |
| 42 #endif // defined(OS_WIN) | 42 #endif // defined(OS_WIN) |
| 43 | 43 |
| 44 #if defined(OS_MACOSX) | 44 #if defined(OS_MACOSX) |
| 45 // Selects the input source for the given input source ID. Returns true on | 45 // Selects the input source for the given input source ID. Returns true on |
| 46 // success. | 46 // success. |
| 47 // Example: "com.apple.keyboardlayout.US" is the default en-us keyboard layout. | 47 // Example: "com.apple.keyboardlayout.US" is the default en-us keyboard layout. |
| 48 bool SwitchKeyboardLayout(const std::string& input_source_id); | 48 bool SwitchKeyboardLayout(const std::string& input_source_id); |
| 49 #endif // defined(OS_MACOSX) | 49 #endif // defined(OS_MACOSX) |
| 50 | 50 |
| 51 #endif // CHROME_TEST_CHROMEDRIVER_TEST_UTIL_H_ | 51 #endif // CHROME_TEST_CHROMEDRIVER_TEST_UTIL_H_ |
| OLD | NEW |