Bug 1134106 - handle -url command line argument. r=fabrice
☠☠ backed out by 44eea0b902ec ☠ ☠
authorPaul Rouget <paul@mozilla.com>
Fri, 15 May 2015 06:18:04 +0200
changeset 243987 a7a4747bdc4ead4bbead2fa280580b59b46fcc0d
parent 243986 7b2518da658d01c61e3bcfdee3f7d1483d328565
child 243988 44eea0b902ec5a6424655493dd7d0d083e761aa2
push id28761
push usercbook@mozilla.com
push dateFri, 15 May 2015 14:50:10 +0000
treeherdermozilla-central@c0e709a5baca [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfabrice
bugs1134106
milestone41.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1134106 - handle -url command line argument. r=fabrice
b2g/chrome/content/shell.js
b2g/components/CommandLine.js
--- a/b2g/chrome/content/shell.js
+++ b/b2g/chrome/content/shell.js
@@ -631,17 +631,35 @@ var shell = {
       Services.obs.notifyObservers(null, "browser-ui-startup-complete", "");
 
       SystemAppProxy.setIsReady();
       if ('pendingChromeEvents' in shell) {
         shell.pendingChromeEvents.forEach((shell.sendChromeEvent).bind(shell));
       }
       delete shell.pendingChromeEvents;
     });
-  }
+
+    shell.handleCmdLine();
+  },
+
+  handleCmdLine: function shell_handleCmdLine() {
+    let b2gcmds = Cc["@mozilla.org/commandlinehandler/general-startup;1?type=b2gcmds"]
+                    .getService(Ci.nsISupports);
+    let args = b2gcmds.wrappedJSObject.cmdLine;
+    try {
+      // Returns null if -url is not present
+      let url = args.handleFlagWithParam("url", false);
+      if (url) {
+        this.sendChromeEvent({type: "mozbrowseropenwindow", url});
+        args.preventDefault = true;
+      }
+    } catch(e) {
+      // Throws if -url is present with no params
+    }
+  },
 };
 
 Services.obs.addObserver(function onFullscreenOriginChange(subject, topic, data) {
   shell.sendChromeEvent({ type: "fullscreenoriginchange",
                           fullscreenorigin: data });
 }, "fullscreen-origin-change", false);
 
 DOMApplicationRegistry.registryStarted.then(function () {
--- a/b2g/components/CommandLine.js
+++ b/b2g/components/CommandLine.js
@@ -10,16 +10,20 @@ XPCOMUtils.defineLazyModuleGetter(this, 
 
 function CommandlineHandler() {
   this.wrappedJSObject = this;
 }
 
 CommandlineHandler.prototype = {
     handle: function(cmdLine) {
       this.cmdLine = cmdLine;
+      let win = Services.wm.getMostRecentWindow("navigator:browser");
+      if (win && win.shell) {
+        win.shell.handleCmdLine();
+      }
     },
 
     helpInfo: "",
     classID: Components.ID("{385993fe-8710-4621-9fb1-00a09d8bec37}"),
     QueryInterface: XPCOMUtils.generateQI([Ci.nsICommandLineHandler]),
 };
 
 this.NSGetFactory = XPCOMUtils.generateNSGetFactory([CommandlineHandler]);