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

Unified Diff: shell/command_line_util.cc

Issue 1905353002: Use a tokenizer to parse the command line for applications. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | shell/command_line_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: shell/command_line_util.cc
diff --git a/shell/command_line_util.cc b/shell/command_line_util.cc
index dfa2986bf3cd2e3b5c1744c3bff4ae39b752b30f..b1288686672bff26ea771aa2f985f398903c541e 100644
--- a/shell/command_line_util.cc
+++ b/shell/command_line_util.cc
@@ -5,10 +5,12 @@
#include "shell/command_line_util.h"
#include <functional>
+#include <string>
+#include <vector>
#include "base/command_line.h"
#include "base/logging.h"
-#include "base/strings/string_split.h"
+#include "base/strings/string_tokenizer.h"
#include "base/strings/utf_string_conversions.h"
#include "shell/context.h"
#include "shell/switches.h"
@@ -46,7 +48,12 @@ GURL GetAppURLAndArgs(Context* context,
const std::string& app_url_and_args,
std::vector<std::string>* args) {
// SplitString() returns empty strings for extra delimeter characters (' ').
- base::SplitString(app_url_and_args, ' ', args);
+ base::StringTokenizer tokenizer =
+ base::StringTokenizer(app_url_and_args, " ");
+ tokenizer.set_quote_chars("'\"");
+ while (tokenizer.GetNext()) {
+ args->push_back(tokenizer.token());
+ }
args->erase(std::remove_if(args->begin(), args->end(),
[](const std::string& a) { return a.empty(); }),
args->end());
« no previous file with comments | « no previous file | shell/command_line_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698