mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 00:32:11 +00:00
fix for bug #333734. protect (warn) against opening too many tabs at once.
r=ben, UI and strings r=beltzner
This commit is contained in:
parent
198c904434
commit
3af66c6e0d
@ -1327,6 +1327,56 @@ var PlacesController = {
|
||||
* See: https://bugzilla.mozilla.org/show_bug.cgi?id=331908
|
||||
*/
|
||||
openLinksInTabs: function PC_openLinksInTabs() {
|
||||
var pref =
|
||||
Components.classes["@mozilla.org/preferences-service;1"].
|
||||
getService(Components.interfaces.nsIPrefBranch);
|
||||
|
||||
const kWarnOnOpenPref = "browser.tabs.warnOnOpen";
|
||||
if (pref.getBoolPref(kWarnOnOpenPref))
|
||||
{
|
||||
var reallyOpen = true;
|
||||
|
||||
// determine how many tabs we are attempting to open
|
||||
var node = this._activeView.selectedNode;
|
||||
asFolder(node);
|
||||
var wasOpen = node.containerOpen;
|
||||
node.containerOpen = true;
|
||||
var tabsToOpen = node.childCount;
|
||||
node.containerOpen = wasOpen;
|
||||
|
||||
if (tabsToOpen >= pref.getIntPref("browser.tabs.maxOpenBeforeWarn"))
|
||||
{
|
||||
var promptService =
|
||||
Components.classes["@mozilla.org/embedcomp/prompt-service;1"].
|
||||
getService(Components.interfaces.nsIPromptService);
|
||||
|
||||
// default to true: if it were false, we wouldn't get this far
|
||||
var warnOnOpen = { value: true };
|
||||
|
||||
var messageKey = "tabs.openWarningMultiple";
|
||||
var openKey = "tabs.openButtonMultiple";
|
||||
var strings = document.getElementById("placeBundle");
|
||||
|
||||
var buttonPressed = promptService.confirmEx(window,
|
||||
strings.getString("tabs.openWarningTitle"),
|
||||
strings.getFormattedString(messageKey, [tabsToOpen]),
|
||||
(promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_0)
|
||||
+ (promptService.BUTTON_TITLE_CANCEL * promptService.BUTTON_POS_1),
|
||||
strings.getString(openKey),
|
||||
null, null,
|
||||
strings.getString("tabs.openWarningPromptMe"),
|
||||
warnOnOpen);
|
||||
|
||||
reallyOpen = (buttonPressed == 0);
|
||||
// don't set the pref unless they press OK and it's false
|
||||
if (reallyOpen && !warnOnOpen.value)
|
||||
pref.setBoolPref(kWarnOnOpen, false);
|
||||
}
|
||||
|
||||
if (!reallyOpen)
|
||||
return;
|
||||
}
|
||||
|
||||
var node = this._activeView.selectedNode;
|
||||
if (this._activeView.hasSingleSelection && this.nodeIsFolder(node)) {
|
||||
// Check prefs to see whether to open over existing tabs.
|
||||
|
@ -55,6 +55,7 @@
|
||||
<preference id="browser.tabs.autoHide" name="browser.tabs.autoHide" type="bool"/>
|
||||
<preference id="browser.tabs.loadInBackground" name="browser.tabs.loadInBackground" type="bool" inverted="true"/>
|
||||
<preference id="browser.tabs.warnOnClose" name="browser.tabs.warnOnClose" type="bool"/>
|
||||
<preference id="browser.tabs.warnOnOpen" name="browser.tabs.warnOnOpen" type="bool"/>
|
||||
</preferences>
|
||||
|
||||
<script type="application/x-javascript" src="chrome://browser/content/preferences/tabs.js"/>
|
||||
@ -79,6 +80,9 @@
|
||||
<checkbox id="warnOnClose" label="&warnOnClose.label;"
|
||||
accesskey="&warnOnClose.accesskey;"
|
||||
preference="browser.tabs.warnOnClose"/>
|
||||
<checkbox id="warnOnOpen" label="&warnOnOpen.label;"
|
||||
accesskey="&warnOnOpen.accesskey;"
|
||||
preference="browser.tabs.warnOnOpen"/>
|
||||
</vbox>
|
||||
</prefpane>
|
||||
|
||||
|
@ -63,3 +63,8 @@ sortByPrefix=Sort by %S
|
||||
searchDefault=Search in Bookmarks & History
|
||||
searchCurrentDefault=Search in '%S'
|
||||
findInPrefix=Find in '%S'...
|
||||
|
||||
tabs.openWarningTitle=Confirm open
|
||||
tabs.openWarningMultiple=You have asked to open %S tabs at once. This might slow down your system while the pages are loading.
|
||||
tabs.openButtonMultiple=Open tabs
|
||||
tabs.openWarningPromptMe=Warn me when I attempt to open a lot of tabs at once
|
||||
|
@ -11,5 +11,9 @@
|
||||
<!ENTITY loadInBackground.accesskey "l">
|
||||
<!ENTITY loadBookmarksInBackground.label "Select new tabs opened from bookmarks or history">
|
||||
<!ENTITY loadBookmarksInBackground.accesskey "b">
|
||||
|
||||
<!ENTITY warnOnClose.label "Warn when closing multiple tabs">
|
||||
<!ENTITY warnOnClose.accesskey "m">
|
||||
|
||||
<!ENTITY warnOnOpen.label "Warn when opening a lot of tabs at once">
|
||||
<!ENTITY warnOnOpen.accesskey "o">
|
||||
|
@ -153,6 +153,8 @@ pref("browser.tabs.autoHide", true);
|
||||
pref("browser.tabs.forceHide", false);
|
||||
pref("browser.tabs.warnOnClose", true);
|
||||
pref("browser.tabs.warnOnCloseOther", true);
|
||||
pref("browser.tabs.warnOnOpen", true);
|
||||
pref("browser.tabs.maxOpenBeforeWarn", 15);
|
||||
// 0 = append, 1 = replace
|
||||
pref("browser.tabs.loadGroup", 1);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user