Bug 961157 - Don't append "metrobrowser" to our command lines and don't expect "metrobrowser" on our command lines. r=jimm, a=metro-only
authorTim Abraldes <tabraldes@mozilla.com>
Thu, 30 Jan 2014 12:29:12 -0800
changeset 176187 40473fad5b7888d4e8ee7eb211ffcc5dc14d0ce2
parent 176186 9c7ef252fdbbb4af31e1272931a9554db4a8dc8f
child 176188 e9224caee6bbf5257cebb70c132390118fbcad4c
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm, metro-only
bugs961157
milestone28.0a2
Bug 961157 - Don't append "metrobrowser" to our command lines and don't expect "metrobrowser" on our command lines. r=jimm, a=metro-only
browser/metro/base/content/browser.js
widget/windows/winrt/MetroContracts.cpp
--- a/browser/metro/base/content/browser.js
+++ b/browser/metro/base/content/browser.js
@@ -729,17 +729,17 @@ var Browser = {
     file.append("tileresources");
     file.append("VisualElements_logo.png");
     var ios = Components.classes["@mozilla.org/network/io-service;1"].
               getService(Components.interfaces.nsIIOService);
     var uriSpec = ios.newFileURI(file).spec;
     Services.metro.pinTileAsync(this._currentPageTileID,
                                 Browser.selectedBrowser.contentTitle, // short name
                                 Browser.selectedBrowser.contentTitle, // display name
-                                "metrobrowser -url " + Browser.selectedBrowser.currentURI.spec,
+                                "-url " + Browser.selectedBrowser.currentURI.spec,
                             uriSpec, uriSpec);
   },
 
   get _currentPageTileID() {
     // We use a unique ID per URL, so just use an MD5 hash of the URL as the ID.
     let hasher = Cc["@mozilla.org/security/hash;1"].
                  createInstance(Ci.nsICryptoHash);
     hasher.init(Ci.nsICryptoHash.MD5);
--- a/widget/windows/winrt/MetroContracts.cpp
+++ b/widget/windows/winrt/MetroContracts.cpp
@@ -99,18 +99,18 @@ FrameworkView::LaunchActivated(ComPtr<IL
     return;
 
   // If we're being launched from a secondary tile then we have a 2nd command line param of -url
   // and a third of the secondary tile.  We want it in mActivationURI so that browser.js will
   // load it in without showing the start UI.
   int argc;
   unsigned int length;
   LPWSTR* argv = CommandLineToArgvW(data.GetRawBuffer(&length), &argc);
-  if (aStartup && argc == 3 && !wcsicmp(argv[1], L"-url")) {
-    mActivationURI = argv[2];
+  if (aStartup && argc == 2 && !wcsicmp(argv[0], L"-url")) {
+    mActivationURI = argv[1];
   } else {
     // Some other command line or this is not a startup.
     // If it is startup we process it later when XPCOM is initialilzed.
     mActivationCommandLine = data.GetRawBuffer(&length);
     if (!aStartup) {
       ProcessLaunchArguments();
     }
   }
@@ -268,17 +268,21 @@ FrameworkView::PerformURILoad(HString& a
   nsCOMPtr<nsICommandLineRunner> cmdLine =
     (do_CreateInstance("@mozilla.org/toolkit/command-line;1"));
   if (!cmdLine) {
     NS_WARNING("Unable to instantiate command line runner.");
     return;
   }
 
   nsAutoCString utf8data(NS_ConvertUTF16toUTF8(aURI.GetRawBuffer(&length)));
-  const char *argv[] = { "metrobrowser",
+
+  // NB: The first argument gets stripped by nsICommandLineRunner::Init,
+  //     so it doesn't matter what we pass as the first argument, but we
+  //     have to pass something.
+  const char *argv[] = { "", // This argument gets stripped
                          "-url",
                          utf8data.BeginReading() };
   nsresult rv = cmdLine->Init(ArrayLength(argv),
                               const_cast<char **>(argv), nullptr,
                               nsICommandLine::STATE_REMOTE_EXPLICIT);
   if (NS_FAILED(rv)) {
     NS_WARNING("cmdLine->Init failed.");
     return;
@@ -299,17 +303,20 @@ FrameworkView::PerformSearch(HString& aQ
   }
 
   nsAutoCString parameter;
   parameter.AppendLiteral("\"");
   unsigned int length;
   parameter.Append(NS_ConvertUTF16toUTF8(aQuery.GetRawBuffer(&length)));
   parameter.AppendLiteral("\"");
 
-  const char *argv[] = { "metrobrowser",
+  // NB: The first argument gets stripped by nsICommandLineRunner::Init,
+  //     so it doesn't matter what we pass as the first argument, but we
+  //     have to pass something.
+  const char *argv[] = { "", // This argument gets stripped
                          "-search",
                          parameter.BeginReading() };
   nsresult rv = cmdLine->Init(ArrayLength(argv),
                               const_cast<char **>(argv), nullptr,
                               nsICommandLine::STATE_REMOTE_EXPLICIT);
   if (NS_FAILED(rv)) {
     NS_WARNING("cmdLine->Init failed.");
     return;