Add mojo_run --embed APP_URL and update wm urls.

This patch adds a flag that makes it easier to run apps embedded in a
wm. It also updates the window manager urls, transitioning away from
mojo: urls, see #356.

R=etiennej@chromium.org

Review URL: https://codereview.chromium.org/1283733002 .

Cr-Mirrored-From: https://github.com/domokit/mojo
Cr-Mirrored-Commit: 4f1253df60a3269dd5525a1de73bbde163301f04
diff --git a/README.md b/README.md
index 5bcd6b9..5367352 100644
--- a/README.md
+++ b/README.md
@@ -39,16 +39,17 @@
 mojo_run --shell-path path/to/shell/binary APP_URL
 ```
 
-Some applications are running embedded inside a window manager. To start such an
-app, you have to first start the window manager app, then have it embed the app
-you are interested in. It is done as follows using the default window manager:
+Some applications are meant to be run embedded in a **window manager**. To run
+these, you can pass the app url using the `--embed` flag. This will run the
+window manager and pass the given url to it:
 
 ```sh
-mojo_run "mojo:window_manager APP_URL"
+mojo_run --embed APP_URL [--android]
 ```
 
-By default, `mojo_run` uses `mojo:kiosk_wm` as the default window manager. It
-can be changed using the `--window-manager` flag.
+By default, `mojo_run` uses https://core.mojoapps.io/kiosk_wm.mojo as the window
+manager. You can pass a different window manager url using the
+`--window-manager` flag to override this.
 
 ### Debugger
 
diff --git a/mojo_run b/mojo_run
index 554eeab..541afb9 100755
--- a/mojo_run
+++ b/mojo_run
@@ -36,7 +36,10 @@
 # Port on which the mojo:debugger http server will be available on the host
 # machine.
 _MOJO_DEBUGGER_PORT = 7777
-_DEFAULT_WINDOW_MANAGER = "mojo:kiosk_wm"
+_DEFAULT_WM = 'https://core.mojoapps.io/kiosk_wm.mojo'
+
+_LEGACY_WM_URL = 'mojo:window_manager'
+_WM_URL = 'https://core.mojoapps.io/window_manager.mojo'
 
 
 def _configure_debugger(shell):
@@ -57,12 +60,14 @@
   parser = argparse.ArgumentParser(usage=_USAGE, description=_DESCRIPTION)
   shell_config.add_shell_arguments(parser)
 
-  parser.add_argument('--no-debugger', action="store_true",
-                      help='Do not spawn mojo:debugger.')
-  parser.add_argument('--window-manager', default=_DEFAULT_WINDOW_MANAGER,
+  parser.add_argument('--embed', type=str,
+                      help='Url to be embedded in the window manager.')
+  parser.add_argument('--window-manager', default=_DEFAULT_WM,
                       help='Window manager app to be mapped as '
                       'mojo:window_manager. By default it is ' +
-                      _DEFAULT_WINDOW_MANAGER)
+                      _DEFAULT_WM)
+  parser.add_argument('--no-debugger', action="store_true",
+                      help='Do not spawn mojo:debugger.')
 
   script_args, shell_args = parser.parse_known_args()
 
@@ -73,6 +78,16 @@
     print e
     return 1
 
+  shell_args = shell_arguments.append_to_argument(shell_args, '--url-mappings=',
+                                                  '%s=%s' % (_LEGACY_WM_URL,
+                                                  script_args.window_manager))
+  shell_args = shell_arguments.append_to_argument(shell_args, '--url-mappings=',
+                                                  '%s=%s' % (_WM_URL,
+                                                  script_args.window_manager))
+
+  if script_args.embed:
+    shell_args.append('%s %s' % (script_args.window_manager, script_args.embed))
+
   if not script_args.no_debugger:
     if script_args.verbose:
       print 'Spawning mojo:debugger, use `mojo_debug` to inspect the shell.'
@@ -80,10 +95,6 @@
       print '  pass --no-debugger to skip spawning mojo:debugger.'
     shell_args.extend(_configure_debugger(shell))
 
-  shell_args = shell_arguments.append_to_argument(shell_args, '--url-mappings=',
-                                                  'mojo:window_manager=%s' %
-                                                  script_args.window_manager)
-
   if script_args.verbose:
     print "Shell arguments: " + str(shell_args)