| 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 "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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 LOG(ERROR) << "Invalid value for switch " << switches::kContentHandlers | 100 LOG(ERROR) << "Invalid value for switch " << switches::kContentHandlers |
| 101 << ": '" << parts[i + 1] << "' is not a valid URL."; | 101 << ": '" << parts[i + 1] << "' is not a valid URL."; |
| 102 return; | 102 return; |
| 103 } | 103 } |
| 104 // TODO(eseidel): We should also validate that the mimetype is valid | 104 // TODO(eseidel): We should also validate that the mimetype is valid |
| 105 // net/base/mime_util.h could do this, but we don't want to depend on net. | 105 // net/base/mime_util.h could do this, but we don't want to depend on net. |
| 106 manager->RegisterContentHandler(parts[i], url); | 106 manager->RegisterContentHandler(parts[i], url); |
| 107 } | 107 } |
| 108 } | 108 } |
| 109 | 109 |
| 110 void InitNativeOptions(shell::ApplicationManager* manager, | |
| 111 const base::CommandLine& command_line) { | |
| 112 std::vector<std::string> force_in_process_url_list = base::SplitString( | |
| 113 command_line.GetSwitchValueASCII(switches::kForceInProcess), ",", | |
| 114 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | |
| 115 for (const auto& force_in_process_url : force_in_process_url_list) { | |
| 116 GURL gurl(force_in_process_url); | |
| 117 if (!gurl.is_valid()) { | |
| 118 LOG(ERROR) << "Invalid value for switch " << switches::kForceInProcess | |
| 119 << ": '" << force_in_process_url << "'is not a valid URL."; | |
| 120 return; | |
| 121 } | |
| 122 | |
| 123 shell::NativeRunnerFactory::Options options; | |
| 124 options.force_in_process = true; | |
| 125 manager->SetNativeOptionsForURL(options, gurl); | |
| 126 } | |
| 127 } | |
| 128 | |
| 129 void InitDevToolsServiceIfNeeded(shell::ApplicationManager* manager, | 110 void InitDevToolsServiceIfNeeded(shell::ApplicationManager* manager, |
| 130 const base::CommandLine& command_line) { | 111 const base::CommandLine& command_line) { |
| 131 if (!command_line.HasSwitch(devtools_service::kRemoteDebuggingPort)) | 112 if (!command_line.HasSwitch(devtools_service::kRemoteDebuggingPort)) |
| 132 return; | 113 return; |
| 133 | 114 |
| 134 std::string port_str = | 115 std::string port_str = |
| 135 command_line.GetSwitchValueASCII(devtools_service::kRemoteDebuggingPort); | 116 command_line.GetSwitchValueASCII(devtools_service::kRemoteDebuggingPort); |
| 136 unsigned port; | 117 unsigned port; |
| 137 if (!base::StringToUint(port_str, &port) || port > 65535) { | 118 if (!base::StringToUint(port_str, &port) || port > 65535) { |
| 138 LOG(ERROR) << "Invalid value for switch " | 119 LOG(ERROR) << "Invalid value for switch " |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 | 192 |
| 212 scoped_ptr<shell::NativeRunnerFactory> runner_factory; | 193 scoped_ptr<shell::NativeRunnerFactory> runner_factory; |
| 213 if (command_line.HasSwitch(switches::kEnableMultiprocess)) | 194 if (command_line.HasSwitch(switches::kEnableMultiprocess)) |
| 214 runner_factory.reset(new OutOfProcessNativeRunnerFactory(this)); | 195 runner_factory.reset(new OutOfProcessNativeRunnerFactory(this)); |
| 215 else | 196 else |
| 216 runner_factory.reset(new InProcessNativeRunnerFactory(this)); | 197 runner_factory.reset(new InProcessNativeRunnerFactory(this)); |
| 217 application_manager_->set_blocking_pool(task_runners_->blocking_pool()); | 198 application_manager_->set_blocking_pool(task_runners_->blocking_pool()); |
| 218 application_manager_->set_native_runner_factory(runner_factory.Pass()); | 199 application_manager_->set_native_runner_factory(runner_factory.Pass()); |
| 219 | 200 |
| 220 InitContentHandlers(application_manager_.get(), command_line); | 201 InitContentHandlers(application_manager_.get(), command_line); |
| 221 InitNativeOptions(application_manager_.get(), command_line); | |
| 222 | 202 |
| 223 ServiceProviderPtr service_provider_ptr; | 203 ServiceProviderPtr service_provider_ptr; |
| 224 ServiceProviderPtr tracing_service_provider_ptr; | 204 ServiceProviderPtr tracing_service_provider_ptr; |
| 225 new TracingServiceProvider(GetProxy(&tracing_service_provider_ptr)); | 205 new TracingServiceProvider(GetProxy(&tracing_service_provider_ptr)); |
| 226 mojo::URLRequestPtr request(mojo::URLRequest::New()); | 206 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
| 227 request->url = mojo::String::From("mojo:tracing"); | 207 request->url = mojo::String::From("mojo:tracing"); |
| 228 application_manager_->ConnectToApplication( | 208 application_manager_->ConnectToApplication( |
| 229 nullptr, request.Pass(), std::string(), GetProxy(&service_provider_ptr), | 209 nullptr, request.Pass(), std::string(), GetProxy(&service_provider_ptr), |
| 230 tracing_service_provider_ptr.Pass(), | 210 tracing_service_provider_ptr.Pass(), |
| 231 shell::GetPermissiveCapabilityFilter(), base::Closure(), | 211 shell::GetPermissiveCapabilityFilter(), base::Closure(), |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 base::MessageLoop::current()->Quit(); | 291 base::MessageLoop::current()->Quit(); |
| 312 } else { | 292 } else { |
| 313 app_complete_callback_.Run(); | 293 app_complete_callback_.Run(); |
| 314 } | 294 } |
| 315 } | 295 } |
| 316 } | 296 } |
| 317 } | 297 } |
| 318 | 298 |
| 319 } // namespace runner | 299 } // namespace runner |
| 320 } // namespace mojo | 300 } // namespace mojo |
| OLD | NEW |