b=445993, r=gavin. target=_blank doesn't load the URL
authorMark Finkle <mfinkle@mozilla.com>
Mon, 21 Jul 2008 17:00:55 -0400
changeset 64763 cafc7e53ba30509a35bf593a65609d4e481a0122
parent 64762 a520403dfbaa20dcd7f3bab1a5ca47bc339439a4
child 64764 39f0d2ca3f1bf00a684bfb897bb91e2c2237b434
push idunknown
push userunknown
push dateunknown
reviewersgavin
bugs445993
b=445993, r=gavin. target=_blank doesn't load the URL
mobile/chrome/content/browser.js
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -102,46 +102,55 @@ var Browser = {
     this._progressController = new ProgressController(this.content);
 
     this._spatialNavigation  = new SpatialNavigation(this.content);
 
     this.setupGeolocationPrompt();
 
     Cc["@mozilla.org/login-manager;1"].getService(Ci.nsILoginManager);
 
-    // Determine the initial launch page
-    var whereURI = null;
-    try {
-      // Use a homepage
-      whereURI = this.prefs.getCharPref("browser.startup.homepage");
-    }
-    catch (e) {
-    }
+    // If this is an intial window launch (was a nsICommandLine passed via window params)
+    // we execute some logic to load the initial launch page
+    if (window.arguments && window.arguments[0]) {
+      var whereURI = null;
+
+      try {
+        // Try to access the commandline
+        var cmdLine = window.arguments[0].QueryInterface(Ci.nsICommandLine);
 
-    // Use a commandline parameter
-    if (window.arguments && window.arguments[0]) {
-      try {
-        var cmdLine = window.arguments[0].QueryInterface(Ci.nsICommandLine);
+        try {
+          // Check for and use a default homepage
+          whereURI = this.prefs.getCharPref("browser.startup.homepage");
+        } catch (e) {}
+
+        // Check for and use a single commandline parameter
         if (cmdLine.length == 1) {
+          // Assume the first arg is a URI if it is not a flag
           var uri = cmdLine.getArgument(0);
           if (uri != "" && uri[0] != '-') {
             whereURI = cmdLine.resolveURI(uri);
             if (whereURI)
               whereURI = whereURI.spec;
           }
         }
-      }
-      catch (e) {
+
+        // Check for the "url" flag
+        uriFlag = cmdLine.handleFlagWithParam("url", false);
+        if (uriFlag) {
+          whereURI = cmdLine.resolveURI(uriFlag);
+          if (whereURI)
+            whereURI = whereURI.spec;
+        }
+      } catch (e) {}
+
+      if (whereURI) {
+        var self = this;
+        setTimeout(function() { self.content.browser.loadURI(whereURI, null, null, false); }, 10);
       }
     }
-
-    if (whereURI) {
-      var self = this;
-      setTimeout(function() { self.content.browser.loadURI(whereURI, null, null, false); }, 10);
-    }
   },
 
   setupGeolocationPrompt: function() {
     var geolocationService = Cc["@mozilla.org/geolocation/service;1"].getService(Ci.nsIGeolocationService);
     geolocationService.prompt = function(request) {
 
       var notificationBox = Browser.getNotificationBox();
       var notification = notificationBox.getNotificationWithValue("geolocation");
@@ -159,17 +168,17 @@ var Browser = {
             callback: function(){request.allowButFuzz()},
           },
           {
             label: bundle_browser.getString("gelocation.nothingLocation"),
             accessKey: bundle_browser.getString("gelocation.nothingLocationKey"),
             callback: function(){request.cancel()},
           }];
 
-        var message = bundle_browser.getFormattedString("geolocation.requestMessage", [request.requestingURI.spec]);      
+        var message = bundle_browser.getFormattedString("geolocation.requestMessage", [request.requestingURI.spec]);
         notificationBox.appendNotification(message,
                                            "geolocation",
                                            null, // todo "chrome://browser/skin/Info.png",
                                            notificationBox.PRIORITY_INFO_HIGH,
                                            buttons);
         return 1;
       }
     };