| 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 #include "chrome/test/chromedriver/keycode_text_conversion.h" | 5 #include "chrome/test/chromedriver/keycode_text_conversion.h" |
| 6 | 6 |
| 7 #import <Carbon/Carbon.h> | 7 #import <Carbon/Carbon.h> |
| 8 | 8 |
| 9 #include <cctype> | 9 #include <cctype> |
| 10 | 10 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 base::string16 text16; | 67 base::string16 text16; |
| 68 text16.push_back(character); | 68 text16.push_back(character); |
| 69 *text = base::UTF16ToUTF8(text16); | 69 *text = base::UTF16ToUTF8(text16); |
| 70 return true; | 70 return true; |
| 71 } | 71 } |
| 72 *text = std::string(); | 72 *text = std::string(); |
| 73 return true; | 73 return true; |
| 74 } | 74 } |
| 75 | 75 |
| 76 bool ConvertCharToKeyCode( | 76 bool ConvertCharToKeyCode( |
| 77 char16 key, ui::KeyboardCode* key_code, int *necessary_modifiers, | 77 base::char16 key, ui::KeyboardCode* key_code, int *necessary_modifiers, |
| 78 std::string* error_msg) { | 78 std::string* error_msg) { |
| 79 base::string16 key_string; | 79 base::string16 key_string; |
| 80 key_string.push_back(key); | 80 key_string.push_back(key); |
| 81 std::string key_string_utf8 = base::UTF16ToUTF8(key_string); | 81 std::string key_string_utf8 = base::UTF16ToUTF8(key_string); |
| 82 bool found_code = false; | 82 bool found_code = false; |
| 83 *error_msg = std::string(); | 83 *error_msg = std::string(); |
| 84 // There doesn't seem to be a way to get a mac key code for a given unicode | 84 // There doesn't seem to be a way to get a mac key code for a given unicode |
| 85 // character. So here we check every key code to see if it produces the | 85 // character. So here we check every key code to see if it produces the |
| 86 // right character. We could cache the results and regenerate everytime the | 86 // right character. We could cache the results and regenerate everytime the |
| 87 // language changes, but this brute force technique has negligble performance | 87 // language changes, but this brute force technique has negligble performance |
| (...skipping 15 matching lines...) Expand all Loading... |
| 103 *necessary_modifiers = kShiftKeyModifierMask; | 103 *necessary_modifiers = kShiftKeyModifierMask; |
| 104 found_code = true; | 104 found_code = true; |
| 105 } | 105 } |
| 106 if (found_code) { | 106 if (found_code) { |
| 107 *key_code = code; | 107 *key_code = code; |
| 108 break; | 108 break; |
| 109 } | 109 } |
| 110 } | 110 } |
| 111 return found_code; | 111 return found_code; |
| 112 } | 112 } |
| OLD | NEW |