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

Side by Side Diff: mojo/runner/context.cc

Issue 1284833004: Remove remaining legacy SplitString calls. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 | « jingle/notifier/communicator/single_login_attempt.cc ('k') | mojo/runner/init.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "mojo/runner/context.h" 5 #include "mojo/runner/context.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 // 'parameters' key on the intent, which we specify during 'am shell start' 126 // 'parameters' key on the intent, which we specify during 'am shell start'
127 // via --esa, however that expects comma-separated values and says: 127 // via --esa, however that expects comma-separated values and says:
128 // am shell --help: 128 // am shell --help:
129 // [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]] 129 // [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]
130 // (to embed a comma into a string escape it using "\,") 130 // (to embed a comma into a string escape it using "\,")
131 // Whatever takes 'parameters' and constructs a CommandLine is failing to 131 // Whatever takes 'parameters' and constructs a CommandLine is failing to
132 // un-escape the commas, we need to move this fix to that file. 132 // un-escape the commas, we need to move this fix to that file.
133 base::ReplaceSubstringsAfterOffset(&handlers_spec, 0, "\\,", ","); 133 base::ReplaceSubstringsAfterOffset(&handlers_spec, 0, "\\,", ",");
134 #endif 134 #endif
135 135
136 std::vector<std::string> parts; 136 std::vector<std::string> parts = base::SplitString(
137 base::SplitString(handlers_spec, ',', &parts); 137 handlers_spec, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
138 if (parts.size() % 2 != 0) { 138 if (parts.size() % 2 != 0) {
139 LOG(ERROR) << "Invalid value for switch " << switches::kContentHandlers 139 LOG(ERROR) << "Invalid value for switch " << switches::kContentHandlers
140 << ": must be a comma-separated list of mimetype/url pairs." 140 << ": must be a comma-separated list of mimetype/url pairs."
141 << handlers_spec; 141 << handlers_spec;
142 return; 142 return;
143 } 143 }
144 144
145 for (size_t i = 0; i < parts.size(); i += 2) { 145 for (size_t i = 0; i < parts.size(); i += 2) {
146 GURL url(parts[i + 1]); 146 GURL url(parts[i + 1]);
147 if (!url.is_valid()) { 147 if (!url.is_valid()) {
148 LOG(ERROR) << "Invalid value for switch " << switches::kContentHandlers 148 LOG(ERROR) << "Invalid value for switch " << switches::kContentHandlers
149 << ": '" << parts[i + 1] << "' is not a valid URL."; 149 << ": '" << parts[i + 1] << "' is not a valid URL.";
150 return; 150 return;
151 } 151 }
152 // TODO(eseidel): We should also validate that the mimetype is valid 152 // TODO(eseidel): We should also validate that the mimetype is valid
153 // net/base/mime_util.h could do this, but we don't want to depend on net. 153 // net/base/mime_util.h could do this, but we don't want to depend on net.
154 manager->RegisterContentHandler(parts[i], url); 154 manager->RegisterContentHandler(parts[i], url);
155 } 155 }
156 } 156 }
157 157
158 void InitNativeOptions(shell::ApplicationManager* manager, 158 void InitNativeOptions(shell::ApplicationManager* manager,
159 const base::CommandLine& command_line) { 159 const base::CommandLine& command_line) {
160 std::vector<std::string> force_in_process_url_list; 160 std::vector<std::string> force_in_process_url_list = base::SplitString(
161 base::SplitString(command_line.GetSwitchValueASCII(switches::kForceInProcess), 161 command_line.GetSwitchValueASCII(switches::kForceInProcess), ",",
162 ',', &force_in_process_url_list); 162 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
163 for (const auto& force_in_process_url : force_in_process_url_list) { 163 for (const auto& force_in_process_url : force_in_process_url_list) {
164 GURL gurl(force_in_process_url); 164 GURL gurl(force_in_process_url);
165 if (!gurl.is_valid()) { 165 if (!gurl.is_valid()) {
166 LOG(ERROR) << "Invalid value for switch " << switches::kForceInProcess 166 LOG(ERROR) << "Invalid value for switch " << switches::kForceInProcess
167 << ": '" << force_in_process_url << "'is not a valid URL."; 167 << ": '" << force_in_process_url << "'is not a valid URL.";
168 return; 168 return;
169 } 169 }
170 170
171 shell::NativeRunnerFactory::Options options; 171 shell::NativeRunnerFactory::Options options;
172 options.force_in_process = true; 172 options.force_in_process = true;
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 base::MessageLoop::current()->Quit(); 391 base::MessageLoop::current()->Quit();
392 } else { 392 } else {
393 app_complete_callback_.Run(); 393 app_complete_callback_.Run();
394 } 394 }
395 } 395 }
396 } 396 }
397 } 397 }
398 398
399 } // namespace runner 399 } // namespace runner
400 } // namespace mojo 400 } // namespace mojo
OLDNEW
« no previous file with comments | « jingle/notifier/communicator/single_login_attempt.cc ('k') | mojo/runner/init.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698