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

Unified Diff: mojo/shell/desktop/launcher_process.cc

Issue 1082513002: Revert of Simplify mojo_shell since it's now only used for Mandoline. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync and rebase. Created 5 years, 8 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/shell/context.cc ('k') | mojo/shell/native_application_support.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/shell/desktop/launcher_process.cc
diff --git a/mojo/shell/desktop/launcher_process.cc b/mojo/shell/desktop/launcher_process.cc
index 09f7fc57e60411668e04279fb751f8c8246226c2..f6bb6ded053ce0c9a4185c396cd962e1bb0fdba9 100644
--- a/mojo/shell/desktop/launcher_process.cc
+++ b/mojo/shell/desktop/launcher_process.cc
@@ -15,6 +15,7 @@
#include "base/message_loop/message_loop.h"
#include "base/synchronization/waitable_event.h"
#include "base/trace_event/trace_event.h"
+#include "mojo/shell/command_line_util.h"
#include "mojo/shell/context.h"
#include "mojo/shell/switches.h"
@@ -22,6 +23,29 @@ namespace mojo {
namespace shell {
namespace {
+void Usage() {
+ std::cerr << "Launch Mojo applications.\n";
+ std::cerr
+ << "Usage: mojo_shell"
+ << " [--" << switches::kArgsFor << "=<mojo-app>]"
+ << " [--" << switches::kContentHandlers << "=<handlers>]"
+ << " [--" << switches::kDisableCache << "]"
+ << " [--" << switches::kEnableMultiprocess << "]"
+ << " [--" << switches::kOrigin << "=<url-lib-path>]"
+ << " [--" << switches::kTraceStartup << "]"
+ << " [--" << switches::kURLMappings << "=from1=to1,from2=to2]"
+ << " [--" << switches::kPredictableAppFilenames << "]"
+ << " [--" << switches::kWaitForDebugger << "]"
+ << " <mojo-app> ...\n\n"
+ << "A <mojo-app> is a Mojo URL or a Mojo URL and arguments within "
+ << "quotes.\n"
+ << "Example: mojo_shell \"mojo:js_standalone test.js\".\n"
+ << "<url-lib-path> is searched for shared libraries named by mojo URLs.\n"
+ << "The value of <handlers> is a comma separated list like:\n"
+ << "text/html,mojo:html_viewer,"
+ << "application/javascript,mojo:js_content_handler\n";
+}
+
// Whether we're currently tracing.
bool g_tracing = false;
@@ -75,15 +99,28 @@ void StopTracingAndFlushToDisk() {
flush_complete_event.Wait();
}
-void StartWindowManager(mojo::shell::Context* context) {
- context->Run(GURL("mojo:window_manager"));
-}
-
} // namespace
int LauncherProcessMain(int argc, char** argv) {
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
+
+ const std::set<std::string> all_switches = switches::GetAllSwitches();
+ const base::CommandLine::SwitchMap switches = command_line.GetSwitches();
+ bool found_unknown_switch = false;
+ for (const auto& s : switches) {
+ if (all_switches.find(s.first) == all_switches.end()) {
+ std::cerr << "unknown switch: " << s.first << std::endl;
+ found_unknown_switch = true;
+ }
+ }
+
+ if (found_unknown_switch || command_line.HasSwitch(switches::kHelp) ||
+ command_line.GetArgs().empty()) {
+ Usage();
+ return 0;
+ }
+
if (command_line.HasSwitch(switches::kTraceStartup)) {
g_tracing = true;
base::trace_event::CategoryFilter category_filter(
@@ -99,6 +136,7 @@ int LauncherProcessMain(int argc, char** argv) {
{
base::MessageLoop message_loop;
if (!shell_context.Init()) {
+ Usage();
return 0;
}
if (g_tracing) {
@@ -107,8 +145,16 @@ int LauncherProcessMain(int argc, char** argv) {
base::TimeDelta::FromSeconds(5));
}
- message_loop.PostTask(FROM_HERE,
- base::Bind(&StartWindowManager, &shell_context));
+ // The mojo_shell --args-for command-line switch is handled specially
+ // because it can appear more than once. The base::CommandLine class
+ // collapses multiple occurrences of the same switch.
+ for (int i = 1; i < argc; i++) {
+ ApplyApplicationArgs(&shell_context, argv[i]);
+ }
+
+ message_loop.PostTask(
+ FROM_HERE,
+ base::Bind(&mojo::shell::RunCommandLineApps, &shell_context));
message_loop.Run();
// Must be called before |message_loop| is destroyed.
« no previous file with comments | « mojo/shell/context.cc ('k') | mojo/shell/native_application_support.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698