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

Side by Side Diff: mojo/shell/desktop/mojo_main.cc

Issue 735863002: Emit an error log line when attempting to connect to an app at an invalid URL. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
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 <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
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()) {
61 LOG(ERROR) << "Error: invalid URL: " << argv[0];
Aaron Boodman 2014/11/20 22:16:02 Add a return here. We don't want to set any args f
azani 2014/11/20 22:18:00 Done.
62 }
60 if (argv.size() > 1) 63 if (argv.size() > 1)
61 context->application_manager()->SetArgsForURL(argv, app_url); 64 context->application_manager()->SetArgsForURL(argv, app_url);
62 return app_url; 65 return app_url;
63 } 66 }
64 67
65 void RunApps(mojo::shell::Context* context) { 68 void RunApps(mojo::shell::Context* context) {
66 const auto& command_line = *base::CommandLine::ForCurrentProcess(); 69 const auto& command_line = *base::CommandLine::ForCurrentProcess();
67 for (const auto& arg : command_line.GetArgs()) 70 for (const auto& arg : command_line.GetArgs()) {
68 context->Run(GetAppURLAndSetArgs(arg, context)); 71 GURL url = GetAppURLAndSetArgs(arg, context);
72 if (!url.is_valid())
73 return;
74 context->Run(url);
75 }
69 } 76 }
70 77
71 void Usage() { 78 void Usage() {
72 std::cerr << "Launch Mojo applications.\n"; 79 std::cerr << "Launch Mojo applications.\n";
73 std::cerr 80 std::cerr
74 << "Usage: mojo_shell" 81 << "Usage: mojo_shell"
75 << " [--" << switches::kArgsFor << "=<mojo-app>]" 82 << " [--" << switches::kArgsFor << "=<mojo-app>]"
76 << " [--" << switches::kContentHandlers << "=<handlers>]" 83 << " [--" << switches::kContentHandlers << "=<handlers>]"
77 << " [--" << switches::kEnableExternalApplications << "]" 84 << " [--" << switches::kEnableExternalApplications << "]"
78 << " [--" << switches::kDisableCache << "]" 85 << " [--" << switches::kDisableCache << "]"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 if (kv.first == switches::kArgsFor) 168 if (kv.first == switches::kArgsFor)
162 GetAppURLAndSetArgs(kv.second, &shell_context); 169 GetAppURLAndSetArgs(kv.second, &shell_context);
163 } 170 }
164 171
165 message_loop.PostTask(FROM_HERE, base::Bind(RunApps, &shell_context)); 172 message_loop.PostTask(FROM_HERE, base::Bind(RunApps, &shell_context));
166 message_loop.Run(); 173 message_loop.Run();
167 } 174 }
168 } 175 }
169 return 0; 176 return 0;
170 } 177 }
OLDNEW
« no previous file with comments | « mojo/application_manager/application_manager.cc ('k') | mojo/shell/dynamic_application_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698