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

Side by Side Diff: chrome/test/chromedriver/keycode_text_conversion_mac.mm

Issue 94013004: Add base:: to string16s in chrome/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: try again Created 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 static_cast<UInt16>(mac_key_code), 57 static_cast<UInt16>(mac_key_code),
58 kUCKeyActionDown, 58 kUCKeyActionDown,
59 modifier_key_state, 59 modifier_key_state,
60 LMGetKbdLast(), 60 LMGetKbdLast(),
61 kUCKeyTranslateNoDeadKeysBit, 61 kUCKeyTranslateNoDeadKeysBit,
62 &dead_key_state, 62 &dead_key_state,
63 1, 63 1,
64 &char_count, 64 &char_count,
65 &character); 65 &character);
66 if (status == noErr && char_count == 1 && !std::iscntrl(character)) { 66 if (status == noErr && char_count == 1 && !std::iscntrl(character)) {
67 string16 text16; 67 base::string16 text16;
68 text16.push_back(character); 68 text16.push_back(character);
69 *text = UTF16ToUTF8(text16); 69 *text = 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 char16 key, ui::KeyboardCode* key_code, int *necessary_modifiers,
78 std::string* error_msg) { 78 std::string* error_msg) {
79 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 = UTF16ToUTF8(key_string); 81 std::string key_string_utf8 = 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
88 // effects (on my laptop it is a submillisecond difference). 88 // effects (on my laptop it is a submillisecond difference).
89 for (int i = 0; i < 256; ++i) { 89 for (int i = 0; i < 256; ++i) {
(...skipping 13 matching lines...) Expand all
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 }
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/key_converter_unittest.cc ('k') | chrome/test/chromedriver/keycode_text_conversion_x.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698