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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 void Context::Run(const GURL& url) { | 311 void Context::Run(const GURL& url) { |
312 ServiceProviderPtr services; | 312 ServiceProviderPtr services; |
313 ServiceProviderPtr exposed_services; | 313 ServiceProviderPtr exposed_services; |
314 | 314 |
315 app_urls_.insert(url); | 315 app_urls_.insert(url); |
316 application_manager_.ConnectToApplication( | 316 application_manager_.ConnectToApplication( |
317 url, GURL(), GetProxy(&services), exposed_services.Pass(), | 317 url, GURL(), GetProxy(&services), exposed_services.Pass(), |
318 base::Bind(&Context::OnApplicationEnd, base::Unretained(this), url)); | 318 base::Bind(&Context::OnApplicationEnd, base::Unretained(this), url)); |
319 } | 319 } |
320 | 320 |
| 321 void Context::RunCommandLineApplication() { |
| 322 // If an app isn't specified (i.e. for an apptest), run the window manager. |
| 323 GURL app_url("mojo:window_manager"); |
| 324 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 325 base::CommandLine::StringVector args = command_line->GetArgs(); |
| 326 for (size_t i = 0; i < args.size(); ++i) { |
| 327 GURL possible_app(args[i]); |
| 328 if (possible_app.SchemeIs("mojo")) { |
| 329 app_url = possible_app; |
| 330 break; |
| 331 } |
| 332 } |
| 333 Run(app_url); |
| 334 } |
| 335 |
321 void Context::OnApplicationEnd(const GURL& url) { | 336 void Context::OnApplicationEnd(const GURL& url) { |
322 if (app_urls_.find(url) != app_urls_.end()) { | 337 if (app_urls_.find(url) != app_urls_.end()) { |
323 app_urls_.erase(url); | 338 app_urls_.erase(url); |
324 if (app_urls_.empty() && base::MessageLoop::current()->is_running()) { | 339 if (app_urls_.empty() && base::MessageLoop::current()->is_running()) { |
325 DCHECK_EQ(base::MessageLoop::current()->task_runner(), | 340 DCHECK_EQ(base::MessageLoop::current()->task_runner(), |
326 task_runners_->shell_runner()); | 341 task_runners_->shell_runner()); |
327 base::MessageLoop::current()->Quit(); | 342 base::MessageLoop::current()->Quit(); |
328 } | 343 } |
329 } | 344 } |
330 } | 345 } |
331 | 346 |
332 } // namespace runner | 347 } // namespace runner |
333 } // namespace mojo | 348 } // namespace mojo |
OLD | NEW |