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

Side by Side Diff: chrome/browser/chromeos/events/event_rewriter.cc

Issue 1197243004: Replace some Tokenize calls with SplitString. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix android Created 5 years, 6 months 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/events/event_rewriter.h" 5 #include "chrome/browser/chromeos/events/event_rewriter.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "ash/sticky_keys/sticky_keys_controller.h" 9 #include "ash/sticky_keys/sticky_keys_controller.h"
10 #include "ash/wm/window_state.h" 10 #include "ash/wm/window_state.h"
11 #include "ash/wm/window_util.h" 11 #include "ash/wm/window_util.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/prefs/pref_service.h" 15 #include "base/prefs/pref_service.h"
16 #include "base/strings/string_split.h"
16 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
17 #include "base/sys_info.h" 18 #include "base/sys_info.h"
18 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" 19 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
19 #include "chrome/browser/extensions/extension_commands_global_registry.h" 20 #include "chrome/browser/extensions/extension_commands_global_registry.h"
20 #include "chrome/browser/profiles/profile_manager.h" 21 #include "chrome/browser/profiles/profile_manager.h"
21 #include "chrome/common/pref_names.h" 22 #include "chrome/common/pref_names.h"
22 #include "chromeos/chromeos_switches.h" 23 #include "chromeos/chromeos_switches.h"
23 #include "components/user_manager/user_manager.h" 24 #include "components/user_manager/user_manager.h"
24 #include "ui/base/ime/chromeos/ime_keyboard.h" 25 #include "ui/base/ime/chromeos/ime_keyboard.h"
25 #include "ui/base/ime/chromeos/input_method_manager.h" 26 #include "ui/base/ime/chromeos/input_method_manager.h"
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 int vendor_id, 185 int vendor_id,
185 int product_id) { 186 int product_id) {
186 if (vendor_id == kHotrodRemoteVendorId && 187 if (vendor_id == kHotrodRemoteVendorId &&
187 product_id == kHotrodRemoteProductId) { 188 product_id == kHotrodRemoteProductId) {
188 return EventRewriter::kDeviceHotrodRemote; 189 return EventRewriter::kDeviceHotrodRemote;
189 } 190 }
190 191
191 if (base::LowerCaseEqualsASCII(device_name, "virtual core keyboard")) 192 if (base::LowerCaseEqualsASCII(device_name, "virtual core keyboard"))
192 return EventRewriter::kDeviceVirtualCoreKeyboard; 193 return EventRewriter::kDeviceVirtualCoreKeyboard;
193 194
194 std::vector<std::string> tokens; 195 std::vector<std::string> tokens = base::SplitString(
195 Tokenize(device_name, " .", &tokens); 196 device_name, " .", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
196 197
197 // If the |device_name| contains the two words, "apple" and "keyboard", treat 198 // If the |device_name| contains the two words, "apple" and "keyboard", treat
198 // it as an Apple keyboard. 199 // it as an Apple keyboard.
199 bool found_apple = false; 200 bool found_apple = false;
200 bool found_keyboard = false; 201 bool found_keyboard = false;
201 for (size_t i = 0; i < tokens.size(); ++i) { 202 for (size_t i = 0; i < tokens.size(); ++i) {
202 if (!found_apple && base::LowerCaseEqualsASCII(tokens[i], "apple")) 203 if (!found_apple && base::LowerCaseEqualsASCII(tokens[i], "apple"))
203 found_apple = true; 204 found_apple = true;
204 if (!found_keyboard && base::LowerCaseEqualsASCII(tokens[i], "keyboard")) 205 if (!found_keyboard && base::LowerCaseEqualsASCII(tokens[i], "keyboard"))
205 found_keyboard = true; 206 found_keyboard = true;
(...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 for (const auto& keyboard : keyboards) { 1170 for (const auto& keyboard : keyboards) {
1170 if (keyboard.id == device_id) { 1171 if (keyboard.id == device_id) {
1171 return KeyboardDeviceAddedInternal( 1172 return KeyboardDeviceAddedInternal(
1172 keyboard.id, keyboard.name, keyboard.vendor_id, keyboard.product_id); 1173 keyboard.id, keyboard.name, keyboard.vendor_id, keyboard.product_id);
1173 } 1174 }
1174 } 1175 }
1175 return kDeviceUnknown; 1176 return kDeviceUnknown;
1176 } 1177 }
1177 1178
1178 } // namespace chromeos 1179 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/in_memory_url_index_unittest.cc ('k') | chrome/browser/chromeos/file_manager/file_tasks.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698