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

Side by Side Diff: chrome/common/extensions/command.cc

Issue 1240183002: Update SplitString calls in chrome. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « chrome/common/crash_keys.cc ('k') | chrome/common/importer/firefox_importer_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "chrome/common/extensions/command.h" 5 #include "chrome/common/extensions/command.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/string_split.h" 9 #include "base/strings/string_split.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 platform_key != values::kKeybindingPlatformChromeOs && 67 platform_key != values::kKeybindingPlatformChromeOs &&
68 platform_key != values::kKeybindingPlatformLinux && 68 platform_key != values::kKeybindingPlatformLinux &&
69 platform_key != values::kKeybindingPlatformDefault) { 69 platform_key != values::kKeybindingPlatformDefault) {
70 *error = ErrorUtils::FormatErrorMessageUTF16( 70 *error = ErrorUtils::FormatErrorMessageUTF16(
71 errors::kInvalidKeyBindingUnknownPlatform, 71 errors::kInvalidKeyBindingUnknownPlatform,
72 base::IntToString(index), 72 base::IntToString(index),
73 platform_key); 73 platform_key);
74 return ui::Accelerator(); 74 return ui::Accelerator();
75 } 75 }
76 76
77 std::vector<std::string> tokens; 77 std::vector<std::string> tokens = base::SplitString(
78 base::SplitString(accelerator, '+', &tokens); 78 accelerator, "+", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
79 if (tokens.size() == 0 || 79 if (tokens.size() == 0 ||
80 (tokens.size() == 1 && DoesRequireModifier(accelerator)) || 80 (tokens.size() == 1 && DoesRequireModifier(accelerator)) ||
81 tokens.size() > kMaxTokenSize) { 81 tokens.size() > kMaxTokenSize) {
82 *error = ErrorUtils::FormatErrorMessageUTF16( 82 *error = ErrorUtils::FormatErrorMessageUTF16(
83 errors::kInvalidKeyBinding, 83 errors::kInvalidKeyBinding,
84 base::IntToString(index), 84 base::IntToString(index),
85 platform_key, 85 platform_key,
86 accelerator); 86 accelerator);
87 return ui::Accelerator(); 87 return ui::Accelerator();
88 } 88 }
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 normalize = true; 257 normalize = true;
258 } else if (platform == values::kKeybindingPlatformDefault) { 258 } else if (platform == values::kKeybindingPlatformDefault) {
259 #if defined(OS_MACOSX) 259 #if defined(OS_MACOSX)
260 normalize = true; 260 normalize = true;
261 #endif 261 #endif
262 } 262 }
263 263
264 if (!normalize) 264 if (!normalize)
265 return suggestion; 265 return suggestion;
266 266
267 std::vector<std::string> tokens; 267 std::vector<std::string> tokens = base::SplitString(
268 base::SplitString(suggestion, '+', &tokens); 268 suggestion, "+", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
269 for (size_t i = 0; i < tokens.size(); i++) { 269 for (size_t i = 0; i < tokens.size(); i++) {
270 if (tokens[i] == values::kKeyCtrl) 270 if (tokens[i] == values::kKeyCtrl)
271 tokens[i] = values::kKeyCommand; 271 tokens[i] = values::kKeyCommand;
272 else if (tokens[i] == values::kKeyMacCtrl) 272 else if (tokens[i] == values::kKeyMacCtrl)
273 tokens[i] = values::kKeyCtrl; 273 tokens[i] = values::kKeyCtrl;
274 } 274 }
275 return base::JoinString(tokens, "+"); 275 return base::JoinString(tokens, "+");
276 } 276 }
277 277
278 } // namespace 278 } // namespace
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 accelerator_ = accelerator; 546 accelerator_ = accelerator;
547 command_name_ = command_name; 547 command_name_ = command_name;
548 description_ = description; 548 description_ = description;
549 global_ = global; 549 global_ = global;
550 } 550 }
551 } 551 }
552 return true; 552 return true;
553 } 553 }
554 554
555 } // namespace extensions 555 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/common/crash_keys.cc ('k') | chrome/common/importer/firefox_importer_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698