Commit 7fcc4606 authored by Gijs Kruitbosch's avatar Gijs Kruitbosch
Browse files

Bug 1165321 - focus existing window if Firefox is already open in tablet mode, r=jaws

--HG--
extra : commitid : E96QcAy8k5s
extra : rebase_source : b79523b4d46f8b4a91015bab28226f3bae014794
parent 6edc7021
......@@ -37,10 +37,13 @@ XPIDL_MODULE = 'browsercompsbase'
EXTRA_PP_COMPONENTS += [
'BrowserComponents.manifest',
'nsBrowserContentHandler.js',
'nsBrowserGlue.js',
]
EXTRA_COMPONENTS += [
'nsBrowserContentHandler.js',
]
EXTRA_JS_MODULES += [
'distribution.js',
]
......
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("resource://gre/modules/AppConstants.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
"resource://gre/modules/PrivateBrowsingUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "RecentWindow",
"resource:///modules/RecentWindow.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "WindowsUIUtils",
"@mozilla.org/windows-ui-utils;1", "nsIWindowsUIUtils");
const nsISupports = Components.interfaces.nsISupports;
......@@ -452,31 +455,35 @@ nsBrowserContentHandler.prototype = {
cmdLine.preventDefault = true;
}
#ifdef XP_WIN
// Handle "? searchterm" for Windows Vista start menu integration
for (var i = cmdLine.length - 1; i >= 0; --i) {
var param = cmdLine.getArgument(i);
if (param.match(/^\? /)) {
cmdLine.removeArguments(i, i);
cmdLine.preventDefault = true;
if (AppConstants.platform == "win") {
// Handle "? searchterm" for Windows Vista start menu integration
for (var i = cmdLine.length - 1; i >= 0; --i) {
var param = cmdLine.getArgument(i);
if (param.match(/^\? /)) {
cmdLine.removeArguments(i, i);
cmdLine.preventDefault = true;
searchParam = param.substr(2);
doSearch(searchParam, cmdLine);
searchParam = param.substr(2);
doSearch(searchParam, cmdLine);
}
}
}
#endif
},
helpInfo : " --browser Open a browser window.\n" +
" --new-window <url> Open <url> in a new window.\n" +
" --new-tab <url> Open <url> in a new tab.\n" +
" --private-window <url> Open <url> in a new private window.\n" +
#ifdef XP_WIN
" --preferences Open Options dialog.\n" +
#else
" --preferences Open Preferences dialog.\n" +
#endif
" --search <term> Search <term> with your default search engine.\n",
get helpInfo() {
let info =
" --browser Open a browser window.\n" +
" --new-window <url> Open <url> in a new window.\n" +
" --new-tab <url> Open <url> in a new tab.\n" +
" --private-window <url> Open <url> in a new private window.\n";
if (AppConstants.platform == "win") {
info += " --preferences Open Options dialog.\n";
} else {
info += " --preferences Open Preferences dialog.\n";
}
info += " --search <term> Search <term> with your default search engine.\n";
return info;
},
/* nsIBrowserHandler */
......@@ -687,35 +694,33 @@ nsDefaultCommandLineHandler.prototype = {
return this;
},
#ifdef XP_WIN
_haveProfile: false,
#endif
/* nsICommandLineHandler */
handle : function dch_handle(cmdLine) {
var urilist = [];
#ifdef XP_WIN
// If we don't have a profile selected yet (e.g. the Profile Manager is
// displayed) we will crash if we open an url and then select a profile. To
// prevent this handle all url command line flags and set the command line's
// preventDefault to true to prevent the display of the ui. The initial
// command line will be retained when nsAppRunner calls LaunchChild though
// urls launched after the initial launch will be lost.
if (!this._haveProfile) {
try {
// This will throw when a profile has not been selected.
var fl = Components.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties);
var dir = fl.get("ProfD", Components.interfaces.nsILocalFile);
this._haveProfile = true;
}
catch (e) {
while ((ar = cmdLine.handleFlagWithParam("url", false))) { }
cmdLine.preventDefault = true;
if (AppConstants.platform == "win") {
// If we don't have a profile selected yet (e.g. the Profile Manager is
// displayed) we will crash if we open an url and then select a profile. To
// prevent this handle all url command line flags and set the command line's
// preventDefault to true to prevent the display of the ui. The initial
// command line will be retained when nsAppRunner calls LaunchChild though
// urls launched after the initial launch will be lost.
if (!this._haveProfile) {
try {
// This will throw when a profile has not been selected.
var fl = Components.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties);
var dir = fl.get("ProfD", Components.interfaces.nsILocalFile);
this._haveProfile = true;
}
catch (e) {
while ((ar = cmdLine.handleFlagWithParam("url", false))) { }
cmdLine.preventDefault = true;
}
}
}
#endif
try {
var ar;
......@@ -767,6 +772,16 @@ nsDefaultCommandLineHandler.prototype = {
}
else if (!cmdLine.preventDefault) {
if (AppConstants.isPlatformAndVersionAtLeast("win", "10") &&
cmdLine.state != nsICommandLine.STATE_INITIAL_LAUNCH &&
WindowsUIUtils.inTabletMode) {
// In windows 10 tablet mode, do not create a new window, but reuse the existing one.
let win = RecentWindow.getMostRecentBrowserWindow();
if (win) {
win.focus();
return;
}
}
// Passing defaultArgs, so use NO_EXTERNAL_URIS
openWindow(null, gBrowserContentHandler.chromeURL, "_blank",
"chrome,dialog=no,all" + gBrowserContentHandler.getFeatures(cmdLine),
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment