OLD | NEW |
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 "shell/context.h" | 5 #include "shell/context.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 // 'parameters' key on the intent, which we specify during 'am shell start' | 131 // 'parameters' key on the intent, which we specify during 'am shell start' |
132 // via --esa, however that expects comma-separated values and says: | 132 // via --esa, however that expects comma-separated values and says: |
133 // am shell --help: | 133 // am shell --help: |
134 // [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]] | 134 // [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]] |
135 // (to embed a comma into a string escape it using "\,") | 135 // (to embed a comma into a string escape it using "\,") |
136 // Whatever takes 'parameters' and constructs a CommandLine is failing to | 136 // Whatever takes 'parameters' and constructs a CommandLine is failing to |
137 // un-escape the commas, we need to move this fix to that file. | 137 // un-escape the commas, we need to move this fix to that file. |
138 base::ReplaceSubstringsAfterOffset(&handlers_spec, 0, "\\,", ","); | 138 base::ReplaceSubstringsAfterOffset(&handlers_spec, 0, "\\,", ","); |
139 #endif | 139 #endif |
140 | 140 |
141 std::vector<std::string> parts; | 141 std::vector<std::string> parts = base::SplitString( |
142 base::SplitString(handlers_spec, ',', &parts); | 142 handlers_spec, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
143 if (parts.size() % 2 != 0) { | 143 if (parts.size() % 2 != 0) { |
144 LOG(ERROR) << "Invalid value for switch " << switches::kContentHandlers | 144 LOG(ERROR) << "Invalid value for switch " << switches::kContentHandlers |
145 << ": must be a comma-separated list of mimetype/url pairs." | 145 << ": must be a comma-separated list of mimetype/url pairs." |
146 << " Value was: " << handlers_spec; | 146 << " Value was: " << handlers_spec; |
147 return; | 147 return; |
148 } | 148 } |
149 | 149 |
150 for (size_t i = 0; i < parts.size(); i += 2) { | 150 for (size_t i = 0; i < parts.size(); i += 2) { |
151 GURL url(parts[i + 1]); | 151 GURL url(parts[i + 1]); |
152 if (!url.is_valid()) { | 152 if (!url.is_valid()) { |
153 LOG(ERROR) << "Invalid value for switch " << switches::kContentHandlers | 153 LOG(ERROR) << "Invalid value for switch " << switches::kContentHandlers |
154 << ": '" << parts[i + 1] << "' is not a valid URL."; | 154 << ": '" << parts[i + 1] << "' is not a valid URL."; |
155 return; | 155 return; |
156 } | 156 } |
157 // TODO(eseidel): We should also validate that the mimetype is valid | 157 // TODO(eseidel): We should also validate that the mimetype is valid |
158 // net/base/mime_util.h could do this, but we don't want to depend on net. | 158 // net/base/mime_util.h could do this, but we don't want to depend on net. |
159 manager->RegisterContentHandler(parts[i], url); | 159 manager->RegisterContentHandler(parts[i], url); |
160 } | 160 } |
161 } | 161 } |
162 | 162 |
163 void InitNativeOptions(ApplicationManager* manager, | 163 void InitNativeOptions(ApplicationManager* manager, |
164 const base::CommandLine& command_line) { | 164 const base::CommandLine& command_line) { |
165 std::vector<std::string> force_in_process_url_list; | 165 std::vector<std::string> force_in_process_url_list = base::SplitString( |
166 base::SplitString(command_line.GetSwitchValueASCII(switches::kForceInProcess), | 166 command_line.GetSwitchValueASCII(switches::kForceInProcess), ",", |
167 ',', &force_in_process_url_list); | 167 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
168 for (const auto& force_in_process_url : force_in_process_url_list) { | 168 for (const auto& force_in_process_url : force_in_process_url_list) { |
169 GURL url(force_in_process_url); | 169 GURL url(force_in_process_url); |
170 if (!url.is_valid()) { | 170 if (!url.is_valid()) { |
171 LOG(ERROR) << "Invalid value for switch " << switches::kForceInProcess | 171 LOG(ERROR) << "Invalid value for switch " << switches::kForceInProcess |
172 << ": '" << force_in_process_url << "'is not a valid URL."; | 172 << ": '" << force_in_process_url << "'is not a valid URL."; |
173 return; | 173 return; |
174 } | 174 } |
175 | 175 |
176 manager->GetNativeApplicationOptionsForURL(url)->force_in_process = true; | 176 manager->GetNativeApplicationOptionsForURL(url)->force_in_process = true; |
177 } | 177 } |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 if (app_urls_.find(url) != app_urls_.end()) { | 368 if (app_urls_.find(url) != app_urls_.end()) { |
369 app_urls_.erase(url); | 369 app_urls_.erase(url); |
370 if (app_urls_.empty() && base::MessageLoop::current()->is_running()) { | 370 if (app_urls_.empty() && base::MessageLoop::current()->is_running()) { |
371 DCHECK(task_runners_->shell_runner()->RunsTasksOnCurrentThread()); | 371 DCHECK(task_runners_->shell_runner()->RunsTasksOnCurrentThread()); |
372 base::MessageLoop::current()->Quit(); | 372 base::MessageLoop::current()->Quit(); |
373 } | 373 } |
374 } | 374 } |
375 } | 375 } |
376 | 376 |
377 } // namespace shell | 377 } // namespace shell |
OLD | NEW |