Bug 1055954 - Popup exceptions menu in Navigator reworked to behave like cookie and image permissions menu. r=Ratty a=Ratty
This commit is contained in:
Родитель
53cd50a8a3
Коммит
a54d4c2eea
|
@ -845,20 +845,25 @@ function GetTypePermFromId(aId)
|
|||
return [type, Components.interfaces.nsICookiePermission[perm]];
|
||||
}
|
||||
|
||||
function CheckForVisibility(aEvent)
|
||||
function CheckForVisibility(aEvent, aNode)
|
||||
{
|
||||
CheckPermissionsMenu("popup", aNode);
|
||||
|
||||
var uri = getBrowser().currentURI;
|
||||
var policy = Services.prefs.getBoolPref("dom.disable_open_during_load");
|
||||
document.getElementById("ManagePopups").hidden = !policy;
|
||||
var allowBlocking = Services.prefs.getBoolPref("dom.disable_open_during_load");
|
||||
|
||||
var element = document.getElementById("AllowPopups");
|
||||
if (policy && (Services.perms.testPermission(uri, "popup") != Services.perms.ALLOW_ACTION))
|
||||
element.removeAttribute("disabled");
|
||||
else
|
||||
element.setAttribute("disabled", "true");
|
||||
// set enabled state for popup_ menu items.
|
||||
var items = aEvent.target.getElementsByAttribute("name", "popup");
|
||||
for (let item of items) {
|
||||
if (allowBlocking)
|
||||
item.removeAttribute("disabled");
|
||||
else
|
||||
item.setAttribute("disabled", "true");
|
||||
}
|
||||
|
||||
document.getElementById("popupMenuSeparator").hidden = !allowBlocking;
|
||||
document.getElementById("menuitem_PopupsManage").hidden = !allowBlocking;
|
||||
|
||||
if (!/Mac/.test(navigator.platform))
|
||||
popupBlockerMenuShowing(aEvent);
|
||||
}
|
||||
|
||||
// Determine current state and check/uncheck the appropriate menu items.
|
||||
|
@ -866,16 +871,15 @@ function CheckPermissionsMenu(aType, aNode)
|
|||
{
|
||||
var currentPerm = Services.perms.testPermission(getBrowser().currentURI, aType);
|
||||
var items = aNode.getElementsByAttribute("name", aType);
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
var item = items[i];
|
||||
for (let item of items) {
|
||||
// Get type and perm from id.
|
||||
var [type, perm] = GetTypePermFromId(item.id);
|
||||
item.setAttribute("checked", perm == currentPerm);
|
||||
}
|
||||
}
|
||||
|
||||
// Perform a Cookie or Image action.
|
||||
function CookieImageAction(aElement)
|
||||
// Perform a Cookie, Image or Popup action.
|
||||
function CookieImagePopupAction(aElement)
|
||||
{
|
||||
var uri = getBrowser().currentURI;
|
||||
// Get type and perm from id.
|
||||
|
@ -888,16 +892,6 @@ function CookieImageAction(aElement)
|
|||
Services.prompt.alert(window, aElement.getAttribute("title"),
|
||||
aElement.getAttribute("msg"));
|
||||
}
|
||||
|
||||
function popupHost()
|
||||
{
|
||||
var hostPort = "";
|
||||
try {
|
||||
hostPort = getBrowser().currentURI.hostPort;
|
||||
} catch (e) {}
|
||||
return hostPort;
|
||||
}
|
||||
|
||||
function OpenSessionHistoryIn(aWhere, aDelta, aTab)
|
||||
{
|
||||
var win = aWhere == "window" ? null : window;
|
||||
|
@ -2002,8 +1996,9 @@ function hiddenWindowStartup()
|
|||
'View:PageSource', 'View:PageInfo', 'menu_translate',
|
||||
'cookie_deny', 'cookie_default', 'View:FullScreen',
|
||||
'cookie_session', 'cookie_allow', 'image_deny',
|
||||
'image_default', 'image_allow', 'AllowPopups',
|
||||
'menu_zoom', 'cmd_minimizeWindow', 'cmd_zoomWindow'];
|
||||
'image_default', 'image_allow', 'popup_deny',
|
||||
'popup_default','popup_allow', 'menu_zoom',
|
||||
'cmd_minimizeWindow', 'cmd_zoomWindow'];
|
||||
var broadcaster;
|
||||
|
||||
for (var id in disabledItems) {
|
||||
|
@ -2402,17 +2397,10 @@ function UpdateStatusBarPopupIcon(aEvent)
|
|||
popupIcon.hidden = !gBrowser.getNotificationBox().popupCount;
|
||||
}
|
||||
}
|
||||
|
||||
function StatusbarViewPopupManager()
|
||||
{
|
||||
var hostPort = "";
|
||||
try {
|
||||
hostPort = getBrowser().selectedBrowser.currentURI.hostPort;
|
||||
}
|
||||
catch(ex) { }
|
||||
|
||||
// Open Data Manager permissions pane site and type prefilled to add.
|
||||
toDataManager(hostPort + "|permissions|add|popup");
|
||||
toDataManager(hostUrl() + "|permissions|add|popup");
|
||||
}
|
||||
|
||||
function popupBlockerMenuShowing(event)
|
||||
|
|
|
@ -529,8 +529,8 @@
|
|||
<menu id="menu_cookieManager"
|
||||
label="&cookieCookieManager.label;"
|
||||
accesskey="&cookieCookieManager.accesskey;"
|
||||
oncommand="if (event.target.id) CookieImageAction(event.target);
|
||||
else toDataManager('|cookies');">
|
||||
oncommand="if (event.target.id.startsWith('cookie_'))
|
||||
CookieImagePopupAction(event.target);">
|
||||
<menupopup id="menupopup_checkPermissions_cookie"
|
||||
onpopupshowing="CheckPermissionsMenu('cookie', this);">
|
||||
<menuitem id="cookie_deny"
|
||||
|
@ -562,17 +562,18 @@
|
|||
type="radio"
|
||||
name="cookie"/>
|
||||
<menuseparator/>
|
||||
<menuitem label="&cookieDisplayCookiesCmd.label;"
|
||||
accesskey="&cookieDisplayCookiesCmd.accesskey;"/>
|
||||
<menuitem id="menuitem_cookieDisplay"
|
||||
label="&cookieDisplayCookiesCmd.label;"
|
||||
accesskey="&cookieDisplayCookiesCmd.accesskey;"
|
||||
oncommand="toDataManager(hostUrl() + '|cookies');
|
||||
event.stopPropagation();"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
<menu id="menu_imageManager"
|
||||
label="&cookieImageManager.label;"
|
||||
accesskey="&cookieImageManager.accesskey;"
|
||||
oncommand="if (event.target.id == 'menuitem_cookieDisplay')
|
||||
toDataManager('|permissions');
|
||||
else
|
||||
CookieImageAction(event.target);">
|
||||
oncommand="if (event.target.id.startsWith('image_'))
|
||||
CookieImagePopupAction(event.target);">
|
||||
<menupopup id="menupopup_checkPermissions_image"
|
||||
onpopupshowing="CheckPermissionsMenu('image', this);">
|
||||
<menuitem id="image_deny"
|
||||
|
@ -597,30 +598,49 @@
|
|||
type="radio"
|
||||
name="image"/>
|
||||
<menuseparator/>
|
||||
<menuitem id="menuitem_cookieDisplay"
|
||||
<menuitem id="menuitem_imageDisplay"
|
||||
label="&cookieDisplayImagesCmd.label;"
|
||||
accesskey="&cookieDisplayImagesCmd.accesskey;"/>
|
||||
accesskey="&cookieDisplayImagesCmd.accesskey;"
|
||||
oncommand="toDataManager(hostUrl() + '|permissions|add|image');
|
||||
event.stopPropagation();"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
<menu id="menu_popupManager"
|
||||
label="&cookiePopupManager.label;"
|
||||
accesskey="&cookiePopupManager.accesskey;"
|
||||
oncommand="popupBlockerMenuCommand(event.target);">
|
||||
label="&popupsManager.label;"
|
||||
accesskey="&popupsManager.accesskey;"
|
||||
oncommand="if (event.target.id.startsWith('popup_'))
|
||||
CookieImagePopupAction(event.target);">
|
||||
<menupopup id="menupopup_checkForVisibility"
|
||||
onpopupshowing="CheckForVisibility(event);"
|
||||
onpopupshowing="CheckForVisibility(event, this);"
|
||||
onpopuphiding="RemovePopupsItems(this);">
|
||||
<menuitem id="AllowPopups"
|
||||
label="&cookieAllowPopupsCmd.label;"
|
||||
accesskey="&cookieAllowPopupsCmd.accesskey;"
|
||||
oncommand="toDataManager(popupHost() + '|permissions|add|popup');"/>
|
||||
<menuitem id="ManagePopups"
|
||||
label="&cookieManagePopups.label;"
|
||||
accesskey="&cookieManagePopups.accesskey;"
|
||||
oncommand="toDataManager('|permissions');"
|
||||
<menuitem id="popup_deny"
|
||||
label="&popupBlockCmd.label;"
|
||||
accesskey="&popupBlockCmd.accesskey;"
|
||||
title="&popupsMessageChangeTitle.label;"
|
||||
msg="&popupBlockMsg.label;"
|
||||
type="radio"
|
||||
name="popup"/>
|
||||
<menuitem id="popup_default"
|
||||
label="&popupDefaultCmd.label;"
|
||||
accesskey="&popupDefaultCmd.accesskey;"
|
||||
title="&popupsMessageChangeTitle.label;"
|
||||
msg="&popupDefaultMsg.label;"
|
||||
type="radio"
|
||||
name="popup"/>
|
||||
<menuitem id="popup_allow"
|
||||
label="&popupAllowCmd.label;"
|
||||
accesskey="&popupAllowCmd.accesskey;"
|
||||
title="&popupsMessageChangeTitle.label;"
|
||||
msg="&popupAllowMsg.label;"
|
||||
type="radio"
|
||||
name="popup"/>
|
||||
<menuseparator id="popupMenuSeparator"/>
|
||||
<menuitem id="menuitem_PopupsManage"
|
||||
label="&popupsManage.label;"
|
||||
accesskey="&popupsManage.accesskey;"
|
||||
oncommand="toDataManager(hostUrl() + '|permissions|add|popup');
|
||||
event.stopPropagation();"
|
||||
hidden="true"/>
|
||||
<menuseparator id="popupMenuSeparator" hidden="true"/>
|
||||
<!-- Additional items are generated (except for mac - bug 533097)
|
||||
by popupBlockerMenuShowing() in navigator.js. -->
|
||||
</menupopup>
|
||||
</menu>
|
||||
<menuseparator id="navBeginGlobalItems"/>
|
||||
|
|
|
@ -1293,6 +1293,15 @@ function popupBlockerMenuCommand(target)
|
|||
target.parentNode.browser.unblockPopup(target.getAttribute("popupReportIndex"));
|
||||
}
|
||||
|
||||
function hostUrl()
|
||||
{
|
||||
var url = "";
|
||||
try {
|
||||
url = getBrowser().currentURI.scheme + "://" + getBrowser().currentURI.hostPort;
|
||||
} catch (e) {}
|
||||
return url;
|
||||
}
|
||||
|
||||
function disablePopupBlockerNotifications()
|
||||
{
|
||||
Services.prefs.setBoolPref("privacy.popups.showBrowserMessage", false);
|
||||
|
|
|
@ -502,7 +502,7 @@
|
|||
oncommand="this.notificationbox.allowPopupsForSite(event);"/>
|
||||
<menuitem id="showPopupManager" label="&showPopupManager.label;"
|
||||
accesskey="&showPopupManager.accesskey;"
|
||||
oncommand="toDataManager(this.hostport + '|permissions|add|popup')"/>
|
||||
oncommand="toDataManager(hostUrl() + '|permissions|add|popup')"/>
|
||||
<menuitem id="dontShowMessage" label="&dontShowMessage.label;"
|
||||
accesskey="&dontShowMessage.accesskey;"
|
||||
oncommand="disablePopupBlockerNotifications();"/>
|
||||
|
|
|
@ -122,17 +122,25 @@
|
|||
<!ENTITY cookieBlockImagesCmd.accesskey "B">
|
||||
<!ENTITY cookieBlockImagesMsg.label "Images from this website will never be downloaded.">
|
||||
|
||||
<!ENTITY cookieAllowPopupsCmd.label "Allow Popups from This Website">
|
||||
<!ENTITY cookieAllowPopupsCmd.accesskey "A">
|
||||
<!ENTITY cookieManagePopups.label "Manage Popups">
|
||||
<!ENTITY cookieManagePopups.accesskey "M">
|
||||
<!ENTITY popupsMessageChangeTitle.label "Popup Permissions Changed">
|
||||
<!ENTITY popupAllowCmd.label "Allow Popups from This Website">
|
||||
<!ENTITY popupAllowCmd.accesskey "A">
|
||||
<!ENTITY popupAllowMsg.label "Popups from this website will always be shown.">
|
||||
<!ENTITY popupDefaultCmd.label "Use Default Popup Permissions">
|
||||
<!ENTITY popupDefaultCmd.accesskey "U">
|
||||
<!ENTITY popupDefaultMsg.label "Popups from this website will be shown based on default settings.">
|
||||
<!ENTITY popupBlockCmd.label "Block Popups from This Website">
|
||||
<!ENTITY popupBlockCmd.accesskey "B">
|
||||
<!ENTITY popupBlockMsg.label "Popups from this website will not be shown.">
|
||||
<!ENTITY popupsManage.label "Manage Popups">
|
||||
<!ENTITY popupsManage.accesskey "M">
|
||||
|
||||
<!ENTITY cookieCookieManager.label "Cookie Manager">
|
||||
<!ENTITY cookieCookieManager.accesskey "C">
|
||||
<!ENTITY cookieImageManager.label "Image Manager">
|
||||
<!ENTITY cookieImageManager.accesskey "I">
|
||||
<!ENTITY cookiePopupManager.label "Popup Manager">
|
||||
<!ENTITY cookiePopupManager.accesskey "o">
|
||||
<!ENTITY popupsManager.label "Popup Manager">
|
||||
<!ENTITY popupsManager.accesskey "o">
|
||||
|
||||
<!ENTITY clearPrivateDataCmd.label "Clear Private Data…">
|
||||
<!ENTITY clearPrivateDataCmd.accesskey "e">
|
||||
|
|
Загрузка…
Ссылка в новой задаче