Bug 1134106 - handle -url command line argument. r=fabrice

This commit is contained in:
Paul Rouget 2015-05-15 06:18:04 +02:00
Родитель 677ad374ba
Коммит 8d9c138354
2 изменённых файлов: 23 добавлений и 1 удалений

Просмотреть файл

@ -636,7 +636,25 @@ var 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) {

Просмотреть файл

@ -15,6 +15,10 @@ function CommandlineHandler() {
CommandlineHandler.prototype = {
handle: function(cmdLine) {
this.cmdLine = cmdLine;
let win = Services.wm.getMostRecentWindow("navigator:browser");
if (win && win.shell) {
win.shell.handleCmdLine();
}
},
helpInfo: "",