Chromium Code Reviews| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <iostream> | 6 #include <iostream> |
| 7 | 7 |
| 8 #include "base/at_exit.h" | 8 #include "base/at_exit.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 50 GURL GetAppURLAndSetArgs(const base::CommandLine::StringType& app_url_and_args, | 50 GURL GetAppURLAndSetArgs(const base::CommandLine::StringType& app_url_and_args, |
| 51 mojo::shell::Context* context) { | 51 mojo::shell::Context* context) { |
| 52 // SplitString() returns empty strings for extra delimeter characters (' '). | 52 // SplitString() returns empty strings for extra delimeter characters (' '). |
| 53 std::vector<std::string> argv; | 53 std::vector<std::string> argv; |
| 54 SplitString(app_url_and_args, &argv); | 54 SplitString(app_url_and_args, &argv); |
| 55 argv.erase(std::remove_if(argv.begin(), argv.end(), is_empty), argv.end()); | 55 argv.erase(std::remove_if(argv.begin(), argv.end(), is_empty), argv.end()); |
| 56 | 56 |
| 57 if (argv.empty()) | 57 if (argv.empty()) |
| 58 return GURL::EmptyGURL(); | 58 return GURL::EmptyGURL(); |
| 59 GURL app_url(argv[0]); | 59 GURL app_url(argv[0]); |
| 60 if (!app_url.is_valid() && app_url.possibly_invalid_spec().size() == 0) { | |
| 61 LOG(ERROR) << "Error: invalid URL: " << argv[0]; | |
|
Aaron Boodman
2014/11/20 21:53:59
same feedback as in other file.
azani
2014/11/20 22:10:03
Done.
| |
| 62 } | |
| 63 DCHECK(app_url.possibly_invalid_spec().size() > 0); | |
| 60 if (argv.size() > 1) | 64 if (argv.size() > 1) |
| 61 context->application_manager()->SetArgsForURL(argv, app_url); | 65 context->application_manager()->SetArgsForURL(argv, app_url); |
| 62 return app_url; | 66 return app_url; |
| 63 } | 67 } |
| 64 | 68 |
| 65 void RunApps(mojo::shell::Context* context) { | 69 void RunApps(mojo::shell::Context* context) { |
| 66 const auto& command_line = *base::CommandLine::ForCurrentProcess(); | 70 const auto& command_line = *base::CommandLine::ForCurrentProcess(); |
| 67 for (const auto& arg : command_line.GetArgs()) | 71 for (const auto& arg : command_line.GetArgs()) |
| 68 context->Run(GetAppURLAndSetArgs(arg, context)); | 72 context->Run(GetAppURLAndSetArgs(arg, context)); |
| 69 } | 73 } |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 161 if (kv.first == switches::kArgsFor) | 165 if (kv.first == switches::kArgsFor) |
| 162 GetAppURLAndSetArgs(kv.second, &shell_context); | 166 GetAppURLAndSetArgs(kv.second, &shell_context); |
| 163 } | 167 } |
| 164 | 168 |
| 165 message_loop.PostTask(FROM_HERE, base::Bind(RunApps, &shell_context)); | 169 message_loop.PostTask(FROM_HERE, base::Bind(RunApps, &shell_context)); |
| 166 message_loop.Run(); | 170 message_loop.Run(); |
| 167 } | 171 } |
| 168 } | 172 } |
| 169 return 0; | 173 return 0; |
| 170 } | 174 } |
| OLD | NEW |