Bug 953124 - [Australis] Remove the "Open Location" dialog (openLocation.xul). r=dao

This commit is contained in:
Malintha Fernando 2014-01-25 17:12:20 +01:00
parent e62101c17c
commit c8698209af
13 changed files with 2 additions and 494 deletions

View File

@ -1712,21 +1712,11 @@ function openLocation() {
}
else {
// If there are no open browser windows, open a new one
win = window.openDialog("chrome://browser/content/", "_blank",
"chrome,all,dialog=no", BROWSER_NEW_TAB_URL);
win.addEventListener("load", openLocationCallback, false);
window.openDialog("chrome://browser/content/", "_blank",
"chrome,all,dialog=no", BROWSER_NEW_TAB_URL);
}
return;
}
#endif
openDialog("chrome://browser/content/openLocation.xul", "_blank",
"chrome,modal,titlebar", window);
}
function openLocationCallback()
{
// make sure the DOM is ready
setTimeout(function() { this.openLocation(); }, 0);
}
function BrowserOpenTab()

View File

@ -1,143 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
var browser;
var dialog = {};
var pref = null;
let openLocationModule = {};
try {
pref = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
} catch (ex) {
// not critical, remain silent
}
Components.utils.import("resource:///modules/openLocationLastURL.jsm", openLocationModule);
Components.utils.import("resource://gre/modules/Task.jsm");
let gOpenLocationLastURL = new openLocationModule.OpenLocationLastURL(window.opener);
function onLoad()
{
dialog.input = document.getElementById("dialog.input");
dialog.open = document.documentElement.getButton("accept");
dialog.openWhereList = document.getElementById("openWhereList");
dialog.openTopWindow = document.getElementById("currentWindow");
dialog.bundle = document.getElementById("openLocationBundle");
if ("arguments" in window && window.arguments.length >= 1)
browser = window.arguments[0];
dialog.openWhereList.selectedItem = dialog.openTopWindow;
if (pref) {
try {
var useAutoFill = pref.getBoolPref("browser.urlbar.autoFill");
if (useAutoFill)
dialog.input.setAttribute("completedefaultindex", "true");
} catch (ex) {}
try {
var value = pref.getIntPref("general.open_location.last_window_choice");
var element = dialog.openWhereList.getElementsByAttribute("value", value)[0];
if (element)
dialog.openWhereList.selectedItem = element;
dialog.input.value = gOpenLocationLastURL.value;
}
catch(ex) {
}
if (dialog.input.value)
dialog.input.select(); // XXX should probably be done automatically
}
doEnabling();
}
function doEnabling()
{
dialog.open.disabled = !dialog.input.value;
}
function open()
{
Task.spawn(function() {
let url;
let postData = null;
let mayInheritPrincipal = false;
if (browser) {
let data = yield browser.getShortcutOrURIAndPostData(dialog.input.value);
url = data.url;
postData = data.postData;
mayInheritPrincipal = data.mayInheritPrincipal;
} else {
url = dialog.input.value;
}
try {
// Whichever target we use for the load, we allow third-party services to
// fixup the URI
switch (dialog.openWhereList.value) {
case "0":
var webNav = Components.interfaces.nsIWebNavigation;
var flags = webNav.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP |
webNav.LOAD_FLAGS_FIXUP_SCHEME_TYPOS;
if (!mayInheritPrincipal)
flags |= webNav.LOAD_FLAGS_DISALLOW_INHERIT_OWNER;
browser.gBrowser.loadURIWithFlags(url, flags, null, null, postData);
break;
case "1":
window.opener.delayedOpenWindow(getBrowserURL(), "all,dialog=no",
url, postData, null, null, true);
break;
case "3":
browser.delayedOpenTab(url, null, null, postData, true);
break;
}
}
catch(exception) {
}
if (pref) {
gOpenLocationLastURL.value = dialog.input.value;
pref.setIntPref("general.open_location.last_window_choice", dialog.openWhereList.value);
}
// Delay closing slightly to avoid timing bug on Linux.
window.close();
});
return false;
}
function createInstance(contractid, iidName)
{
var iid = Components.interfaces[iidName];
return Components.classes[contractid].createInstance(iid);
}
const nsIFilePicker = Components.interfaces.nsIFilePicker;
function onChooseFile()
{
try {
let fp = Components.classes["@mozilla.org/filepicker;1"].
createInstance(nsIFilePicker);
let fpCallback = function fpCallback_done(aResult) {
if (aResult == nsIFilePicker.returnOK && fp.fileURL.spec &&
fp.fileURL.spec.length > 0) {
dialog.input.value = fp.fileURL.spec;
}
doEnabling();
};
fp.init(window, dialog.bundle.getString("chooseFileDialogTitle"),
nsIFilePicker.modeOpen);
fp.appendFilters(nsIFilePicker.filterAll | nsIFilePicker.filterText |
nsIFilePicker.filterImages | nsIFilePicker.filterXML |
nsIFilePicker.filterHTML);
fp.open(fpCallback);
} catch (ex) {
}
}

View File

@ -1,57 +0,0 @@
<?xml version="1.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/. -->
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<!DOCTYPE dialog SYSTEM "chrome://browser/locale/openLocation.dtd">
<dialog id="openLocation"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="&caption.label;"
onload="onLoad()"
buttonlabelaccept="&openBtn.label;"
buttoniconaccept="open"
ondialogaccept="open()"
style="width: 40em;"
persist="screenX screenY"
screenX="24" screenY="24">
<script type="application/javascript" src="chrome://global/content/globalOverlay.js"/>
<script type="application/javascript" src="chrome://browser/content/openLocation.js"/>
<script type="application/javascript" src="chrome://browser/content/utilityOverlay.js"/>
<stringbundle id="openLocationBundle" src="chrome://browser/locale/openLocation.properties"/>
<hbox>
<separator orient="vertical" class="thin"/>
<vbox flex="1">
<description>&enter.label;</description>
<separator class="thin"/>
<hbox align="center">
<textbox id="dialog.input" flex="1" type="autocomplete"
completeselectedindex="true"
autocompletesearch="urlinline history"
enablehistory="true"
class="uri-element"
oninput="doEnabling();"/>
<button label="&chooseFile.label;" oncommand="onChooseFile();"/>
</hbox>
<hbox align="center">
<label value="&openWhere.label;"/>
<menulist id="openWhereList">
<menupopup>
<menuitem value="0" id="currentWindow" label="&topTab.label;"/>
<menuitem value="3" label="&newTab.label;"/>
<menuitem value="1" label="&newWindow.label;"/>
</menupopup>
</menulist>
<spacer flex="1"/>
</hbox>
</vbox>
</hbox>
</dialog>

View File

@ -220,14 +220,6 @@ Sanitizer.prototype = {
}
catch (e) { }
// Clear last URL of the Open Web Location dialog
var prefs = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
try {
prefs.clearUserPref("general.open_location.last_url");
}
catch (e) { }
try {
var seer = Components.classes["@mozilla.org/network/seer;1"]
.getService(Components.interfaces.nsINetworkSeer);

View File

@ -102,8 +102,6 @@ browser.jar:
content/browser/sync/progress.js (content/sync/progress.js)
content/browser/sync/progress.xhtml (content/sync/progress.xhtml)
#endif
content/browser/openLocation.js (content/openLocation.js)
content/browser/openLocation.xul (content/openLocation.xul)
content/browser/safeMode.css (content/safeMode.css)
content/browser/safeMode.js (content/safeMode.js)
content/browser/safeMode.xul (content/safeMode.xul)

View File

@ -31,9 +31,7 @@ support-files =
[browser_privatebrowsing_localStorage_before_after.js]
[browser_privatebrowsing_noSessionRestoreMenuOption.js]
[browser_privatebrowsing_nonbrowser.js]
[browser_privatebrowsing_openLocationLastURL.js]
[browser_privatebrowsing_opendir.js]
[browser_privatebrowsing_openlocation.js]
[browser_privatebrowsing_placesTitleNoUpdate.js]
[browser_privatebrowsing_placestitle.js]
[browser_privatebrowsing_popupblocker.js]

View File

@ -1,63 +0,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/. */
function test() {
waitForExplicitFinish();
const URL_1 = "mozilla.org";
const URL_2 = "mozilla.com";
function testURL(aOpenLocation, aTestNumber, aValue) {
is(aOpenLocation.value, aValue,
"Test: " + aTestNumber + ": Validate last url value.");
}
whenNewWindowLoaded({private: false}, function(normalWindow) {
whenNewWindowLoaded({private: true}, function(privateWindow) {
let openLocationLastURL = getLocationModule(normalWindow);
let openLocationLastURLPB = getLocationModule(privateWindow);
// Clean to start testing.
is(typeof openLocationLastURL, "object", "Validate Normal type of last url.");
is(typeof openLocationLastURLPB, "object", "Validate PB type of last url.");
openLocationLastURL.reset();
openLocationLastURLPB.reset();
testURL(openLocationLastURL, 1, "");
// Test without private browsing.
openLocationLastURL.value = URL_1;
testURL(openLocationLastURL, 2, URL_1);
openLocationLastURL.value = "";
testURL(openLocationLastURL, 3, "");
openLocationLastURL.value = URL_2;
testURL(openLocationLastURL, 4, URL_2);
clearHistory();
testURL(openLocationLastURL, 5, "");
// Test changing private browsing.
openLocationLastURL.value = URL_2;
testURL(openLocationLastURLPB, 6, "");
testURL(openLocationLastURL, 7, URL_2);
openLocationLastURLPB.value = URL_1;
testURL(openLocationLastURLPB, 8, URL_1);
testURL(openLocationLastURL, 9, URL_2);
openLocationLastURLPB.value = URL_1;
testURL(openLocationLastURLPB, 10, URL_1);
// Test cleaning history.
clearHistory();
testURL(openLocationLastURLPB, 11, "");
testURL(openLocationLastURL, 12, "");
privateWindow.close();
normalWindow.close();
finish();
});
});
}
function getLocationModule(aWindow) {
let openLocationModule = {};
Cu.import("resource:///modules/openLocationLastURL.jsm", openLocationModule);
return new openLocationModule.OpenLocationLastURL(aWindow);
}

View File

@ -1,100 +0,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/. */
// This test makes sure that Open Location dialog is usable inside the private browsing
// mode without leaving any trace of the URLs visited.
function test() {
// initialization
waitForExplicitFinish();
function openLocation(aWindow, url, autofilled, callback) {
function observer(aSubject, aTopic, aData) {
switch (aTopic) {
case "domwindowopened":
let dialog = aSubject.QueryInterface(Ci.nsIDOMWindow);
dialog.addEventListener("load", function () {
dialog.removeEventListener("load", arguments.callee, false);
let browser = aWindow.gBrowser.selectedBrowser;
browser.addEventListener("load", function() {
// Ignore non-related loads (could be about:privatebrowsing for example, see bug 817932)
if (browser.currentURI.spec != url) {
return;
}
browser.removeEventListener("load", arguments.callee, true);
executeSoon(callback);
}, true);
SimpleTest.waitForFocus(function() {
let input = dialog.document.getElementById("dialog.input");
is(input.value, autofilled, "The input field should be correctly auto-filled");
input.focus();
for (let i = 0; i < url.length; ++i)
EventUtils.synthesizeKey(url[i], {}, dialog);
EventUtils.synthesizeKey("VK_RETURN", {}, dialog);
}, dialog);
}, false);
break;
case "domwindowclosed":
Services.ww.unregisterNotification(arguments.callee);
break;
}
}
executeSoon(function() {
Services.ww.registerNotification(observer);
gPrefService.setIntPref("general.open_location.last_window_choice", 0);
aWindow.openDialog("chrome://browser/content/openLocation.xul", "_blank",
"chrome,titlebar", aWindow);
});
}
let windowsToClose = [];
function testOnWindow(options, callback) {
let win = OpenBrowserWindow(options);
win.addEventListener("load", function onLoad() {
win.removeEventListener("load", onLoad, false);
windowsToClose.push(win);
callback(win);
}, false);
};
registerCleanupFunction(function() {
windowsToClose.forEach(function(win) {
win.close();
});
});
if (gPrefService.prefHasUserValue("general.open_location.last_url"))
gPrefService.clearUserPref("general.open_location.last_url");
testOnWindow({private: false}, function(win) {
openLocation(win, "http://example.com/", "", function() {
testOnWindow({private: false}, function(win) {
openLocation(win, "http://example.org/", "http://example.com/", function() {
testOnWindow({private: true}, function(win) {
openLocation(win, "about:logo", "", function() {
testOnWindow({private: true}, function(win) {
openLocation(win, "about:buildconfig", "about:logo", function() {
testOnWindow({private: false}, function(win) {
openLocation(win, "about:blank", "http://example.org/", function() {
gPrefService.clearUserPref("general.open_location.last_url");
if (gPrefService.prefHasUserValue("general.open_location.last_window_choice"))
gPrefService.clearUserPref("general.open_location.last_window_choice");
finish();
});
});
});
});
});
});
});
});
});
});
}

View File

@ -1,14 +0,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/. -->
<!-- extracted from content/openLocation.xul -->
<!ENTITY enter.label "Enter the web location (URL), or specify the local file you would like to open:">
<!ENTITY chooseFile.label "Choose File…">
<!ENTITY newTab.label "New Tab">
<!ENTITY newWindow.label "New Window">
<!ENTITY topTab.label "Current Tab">
<!ENTITY caption.label "Open Web Location">
<!ENTITY openWhere.label "Open in:">
<!ENTITY openBtn.label "Open">

View File

@ -1,5 +0,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/.
chooseFileDialogTitle=Choose File

View File

@ -59,8 +59,6 @@
locale/browser/devtools/app-manager.properties (%chrome/browser/devtools/app-manager.properties)
locale/browser/newTab.dtd (%chrome/browser/newTab.dtd)
locale/browser/newTab.properties (%chrome/browser/newTab.properties)
locale/browser/openLocation.dtd (%chrome/browser/openLocation.dtd)
locale/browser/openLocation.properties (%chrome/browser/openLocation.properties)
locale/browser/pageInfo.dtd (%chrome/browser/pageInfo.dtd)
locale/browser/pageInfo.properties (%chrome/browser/pageInfo.properties)
locale/browser/quitDialog.properties (%chrome/browser/quitDialog.properties)

View File

@ -12,7 +12,6 @@ EXTRA_JS_MODULES += [
'ContentClick.jsm',
'NetworkPrioritizer.jsm',
'offlineAppCache.jsm',
'openLocationLastURL.jsm',
'SharedFrame.jsm',
'SignInToWebsite.jsm',
'SitePermissions.jsm',

View File

@ -1,85 +0,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/. */
const LAST_URL_PREF = "general.open_location.last_url";
const nsISupportsString = Components.interfaces.nsISupportsString;
const Ci = Components.interfaces;
Components.utils.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
this.EXPORTED_SYMBOLS = [ "OpenLocationLastURL" ];
let prefSvc = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
let gOpenLocationLastURLData = "";
let observer = {
QueryInterface: function (aIID) {
if (aIID.equals(Components.interfaces.nsIObserver) ||
aIID.equals(Components.interfaces.nsISupports) ||
aIID.equals(Components.interfaces.nsISupportsWeakReference))
return this;
throw Components.results.NS_NOINTERFACE;
},
observe: function (aSubject, aTopic, aData) {
switch (aTopic) {
case "last-pb-context-exited":
gOpenLocationLastURLData = "";
break;
case "browser:purge-session-history":
prefSvc.clearUserPref(LAST_URL_PREF);
gOpenLocationLastURLData = "";
break;
}
}
};
let os = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
os.addObserver(observer, "last-pb-context-exited", true);
os.addObserver(observer, "browser:purge-session-history", true);
this.OpenLocationLastURL = function OpenLocationLastURL(aWindow) {
this.window = aWindow;
}
OpenLocationLastURL.prototype = {
isPrivate: function OpenLocationLastURL_isPrivate() {
// Assume not in private browsing mode, unless the browser window is
// in private mode.
if (!this.window)
return false;
return PrivateBrowsingUtils.isWindowPrivate(this.window);
},
get value() {
if (this.isPrivate())
return gOpenLocationLastURLData;
else {
try {
return prefSvc.getComplexValue(LAST_URL_PREF, nsISupportsString).data;
}
catch (e) {
return "";
}
}
},
set value(val) {
if (typeof val != "string")
val = "";
if (this.isPrivate())
gOpenLocationLastURLData = val;
else {
let str = Components.classes["@mozilla.org/supports-string;1"]
.createInstance(Components.interfaces.nsISupportsString);
str.data = val;
prefSvc.setComplexValue(LAST_URL_PREF, nsISupportsString, str);
}
},
reset: function() {
prefSvc.clearUserPref(LAST_URL_PREF);
gOpenLocationLastURLData = "";
}
};