Merge --origin and --origin-path in devtools scripts.

It's error prone to expose both --origin and --origin-path. This patch
merges both into just --origin, which will setup the server and port
forwarding if a local destination is passed. This matches what the run scripts do
for --map-origin and --map-url destinations.

R=qsr@chromium.org

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

Cr-Mirrored-From: https://github.com/domokit/mojo
Cr-Mirrored-Commit: cc1b5a8fdf695e0574f443c204ffe3d9f73585b0
diff --git a/devtoolslib/shell_arguments.py b/devtoolslib/shell_arguments.py
index afff975..e23c2f8 100644
--- a/devtoolslib/shell_arguments.py
+++ b/devtoolslib/shell_arguments.py
@@ -21,6 +21,10 @@
 _SKY_SERVER_PORT = 9998
 
 
+def _IsWebUrl(dest):
+  return True if urlparse.urlparse(dest).scheme else False
+
+
 def _HostLocalUrlDestination(shell, dest_file, port):
   """Starts a local server to host |dest_file|.
 
@@ -52,7 +56,7 @@
   if len(parts) != 2:
     raise ValueError('each mapping value should be in format '
                      '"<url>=<url-or-local-path>"')
-  if urlparse.urlparse(parts[1])[0]:
+  if _IsWebUrl(parts[1]):
     # The destination is a web url, do nothing.
     return mapping
 
@@ -188,13 +192,12 @@
   # Arguments indicating paths to binaries and tools.
   parser.add_argument('--adb-path', help='Path of the adb binary.')
   parser.add_argument('--shell-path', help='Path of the Mojo shell binary.')
-  parser.add_argument('--origin-path', help='Path of a directory to be set as '
-                      'the origin for mojo: urls')
 
   # Arguments configuring the shell run.
   parser.add_argument('--android', help='Run on Android',
                       action='store_true')
-  parser.add_argument('--origin', help='Origin for mojo: URLs.')
+  parser.add_argument('--origin', help='Origin for mojo: URLs. This can be a '
+                      'web url or a local directory path.')
   parser.add_argument('--map-url', action='append',
                       help='Define a mapping for a url in the format '
                       '<url>=<url-or-local-file-path>')
@@ -265,9 +268,10 @@
       shell_args.append('--args-for=mojo:native_viewport_service --use-osmesa')
 
   if config_args.origin:
-    shell_args.append('--origin=' + config_args.origin)
-  elif config_args.origin_path:
-    shell_args.extend(ConfigureLocalOrigin(shell, config_args.origin_path,
-                                           fixed_port=True))
+    if _IsWebUrl(config_args.origin):
+      shell_args.append('--origin=' + config_args.origin)
+    else:
+      shell_args.extend(ConfigureLocalOrigin(shell, config_args.origin,
+                                             fixed_port=True))
 
   return shell, shell_args
diff --git a/mojo_run b/mojo_run
index 9c5e52a..b4f82c5 100755
--- a/mojo_run
+++ b/mojo_run
@@ -90,18 +90,18 @@
   if mojo_paths:
     if script_args.android and not script_args.adb_path:
       script_args.adb_path = mojo_paths['adb']
-    if script_args.android and not script_args.origin_path:
-      script_args.origin_path = mojo_paths['build']
+    if script_args.android and not script_args.origin:
+      script_args.origin = mojo_paths['build']
     if not script_args.shell_path:
       script_args.shell_path = mojo_paths['shell']
 
     if script_args.verbose:
       print 'Running within a Chromium-style checkout.'
-      print ' - using the locally built shell at ' + script_args.shell_path
-      if script_args.origin_path:
-        print ' - using the local origin of ' + script_args.origin_path
+      print ' - using the locally built shell at: ' + script_args.shell_path
+      if script_args.origin:
+        print ' - using the origin:  ' + script_args.origin
       if script_args.android:
-        print ' - using adb path of ' + script_args.adb_path
+        print ' - using the adb path: ' + script_args.adb_path
   elif script_args.verbose:
     print 'Running outside a Chromium-style checkout.'