mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
Add a way to manually show a single blocked pop-up window
bug 198846, r=danm, sr=jag
This commit is contained in:
parent
e2ecdc9aba
commit
3688853ede
@ -262,7 +262,9 @@
|
||||
<menu label="&cookiePopupManager.label;"
|
||||
accesskey="&cookiePopupManager.accesskey;"
|
||||
id="popup"
|
||||
insertbefore="navBeginGlobalItems">
|
||||
insertbefore="navBeginGlobalItems"
|
||||
oncommand="popupBlockerMenuCommand(event.target);"
|
||||
onpopupshowing="return popupBlockerMenuShowing(event)" >
|
||||
<menupopup>
|
||||
<menuitem id="AllowPopups" label="&cookieAllowPopupsCmd.label;"
|
||||
accesskey="&cookieAllowPopupsCmd.accesskey;"
|
||||
@ -275,6 +277,9 @@
|
||||
accesskey="&cookieManagePopups.accesskey;"
|
||||
oncommand="OpenManagePopups('');"
|
||||
hidden="true"/>
|
||||
<menuseparator id="popupMenuSeparator" hidden="true"/>
|
||||
<!-- Additional items are generated, see popupBlockerMenuShowing()
|
||||
in navigator.js -->
|
||||
</menupopup>
|
||||
</menu>
|
||||
</menupopup>
|
||||
|
@ -2199,6 +2199,27 @@ function onPopupBlocked(aEvent) {
|
||||
var popupIcon = document.getElementById("popupIcon");
|
||||
popupIcon.hidden = false;
|
||||
}
|
||||
if (!browser.popupUrls) {
|
||||
browser.popupUrls = [];
|
||||
browser.popupFeatures = [];
|
||||
}
|
||||
// Check for duplicates, remove the old occurence of this url,
|
||||
// to update the features, and put it at the end of the list.
|
||||
for (var i = 0; i < browser.popupUrls.length; ++i) {
|
||||
if (browser.popupUrls[i].equals(aEvent.popupWindowURI)) {
|
||||
browser.popupUrls.splice(i, 1);
|
||||
browser.popupFeatures.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Limit the length of the menu to some reasonable size.
|
||||
// We only add one item every time, so no need for more complex stuff.
|
||||
if (browser.popupUrls.length >= 100) {
|
||||
browser.popupUrls.shift();
|
||||
browser.popupFeatures.shift();
|
||||
}
|
||||
browser.popupUrls.push(aEvent.popupWindowURI);
|
||||
browser.popupFeatures.push(aEvent.popupWindowFeatures);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2224,6 +2245,45 @@ function StatusbarViewPopupManager() {
|
||||
"chrome,resizable=yes", hostPort);
|
||||
}
|
||||
|
||||
function popupBlockerMenuShowing(event) {
|
||||
var parent = event.target;
|
||||
var browser = getBrowser().selectedBrowser;
|
||||
var separator = document.getElementById("popupMenuSeparator");
|
||||
|
||||
if ("popupDomain" in browser) {
|
||||
createShowPopupsMenu(parent);
|
||||
if (separator)
|
||||
separator.hidden = false;
|
||||
} else {
|
||||
if (separator)
|
||||
separator.hidden = true;
|
||||
}
|
||||
}
|
||||
|
||||
function createShowPopupsMenu(parent) {
|
||||
while (parent.lastChild && parent.lastChild.hasAttribute("uri"))
|
||||
parent.removeChild(parent.lastChild);
|
||||
|
||||
var browser = getBrowser().selectedBrowser;
|
||||
|
||||
for (var i = 0; i < browser.popupUrls.length; i++) {
|
||||
var menuitem = document.createElement("menuitem");
|
||||
menuitem.setAttribute("label", gNavigatorBundle.getFormattedString('popupMenuShow', [browser.popupUrls[i].spec]));
|
||||
menuitem.setAttribute("uri", browser.popupUrls[i].spec);
|
||||
menuitem.setAttribute("features", browser.popupFeatures[i]);
|
||||
parent.appendChild(menuitem);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function popupBlockerMenuCommand(target) {
|
||||
var uri = target.getAttribute("uri");
|
||||
if (uri) {
|
||||
window.content.open(uri, "", target.getAttribute("features"));
|
||||
}
|
||||
}
|
||||
|
||||
function toHistory()
|
||||
{
|
||||
toOpenWindowByType("history:manager", "chrome://communicator/content/history/history.xul");
|
||||
|
@ -349,11 +349,20 @@
|
||||
<statusbarpanel class="statusbarpanel-progress" id="progress-panel" hidden="true">
|
||||
<progressmeter class="progressmeter-statusbar" id="statusbar-icon" mode="normal" value="0"/>
|
||||
</statusbarpanel>
|
||||
<statusbarpanel id="popupIcon" class="statusbarpanel-iconic" hidden="true" oncommand="StatusbarViewPopupManager()" tooltiptext="&popupIcon.tooltiptext;"/>
|
||||
<statusbarpanel id="popupIcon" class="statusbarpanel-iconic" hidden="true"
|
||||
oncommand="StatusbarViewPopupManager()"
|
||||
tooltiptext="&popupIcon.tooltiptext;"
|
||||
context="popupBlockerMenu"/>
|
||||
<statusbarpanel class="statusbarpanel-iconic" id="offline-status"/>
|
||||
<statusbarpanel class="statusbarpanel-iconic" id="security-button"
|
||||
onclick="BrowserPageInfo(null, 'securityTab')"/>
|
||||
</statusbar>
|
||||
<popupset>
|
||||
<menupopup id="popupBlockerMenu"
|
||||
oncommand="popupBlockerMenuCommand(event.target);"
|
||||
onpopupshowing="return popupBlockerMenuShowing(event)"/>
|
||||
<!-- Items are generated, see popupBlockerMenuShowing() -->
|
||||
</popupset>
|
||||
<popupset>
|
||||
<popup id="networkProperties"/>
|
||||
</popupset>
|
||||
|
@ -331,6 +331,8 @@ nsBrowserStatusHandler.prototype =
|
||||
if (blank ||
|
||||
!("popupDomain" in browser)) {
|
||||
browser.popupDomain = null;
|
||||
browser.popupUrls = null;
|
||||
browser.popupFeatures = null;
|
||||
}
|
||||
else {
|
||||
var hostPort = "";
|
||||
@ -338,8 +340,11 @@ nsBrowserStatusHandler.prototype =
|
||||
hostPort = locationURI.hostPort;
|
||||
}
|
||||
catch(ex) { }
|
||||
if (hostPort != browser.popupDomain)
|
||||
if (hostPort != browser.popupDomain) {
|
||||
browser.popupDomain = null;
|
||||
browser.popupUrls = null;
|
||||
browser.popupFeatures = null;
|
||||
}
|
||||
}
|
||||
|
||||
var popupIcon = document.getElementById("popupIcon");
|
||||
|
@ -86,3 +86,5 @@ searchFor=Search %S for "%S"
|
||||
# For JVM Configuration
|
||||
switchJVMTitle=Select Java version
|
||||
switchJVMFailed=Failed to select this version of java
|
||||
|
||||
popupMenuShow=Show %S
|
||||
|
@ -262,7 +262,9 @@
|
||||
<menu label="&cookiePopupManager.label;"
|
||||
accesskey="&cookiePopupManager.accesskey;"
|
||||
id="popup"
|
||||
insertbefore="navBeginGlobalItems">
|
||||
insertbefore="navBeginGlobalItems"
|
||||
oncommand="popupBlockerMenuCommand(event.target);"
|
||||
onpopupshowing="return popupBlockerMenuShowing(event)" >
|
||||
<menupopup>
|
||||
<menuitem id="AllowPopups" label="&cookieAllowPopupsCmd.label;"
|
||||
accesskey="&cookieAllowPopupsCmd.accesskey;"
|
||||
@ -275,6 +277,9 @@
|
||||
accesskey="&cookieManagePopups.accesskey;"
|
||||
oncommand="OpenManagePopups('');"
|
||||
hidden="true"/>
|
||||
<menuseparator id="popupMenuSeparator" hidden="true"/>
|
||||
<!-- Additional items are generated, see popupBlockerMenuShowing()
|
||||
in navigator.js -->
|
||||
</menupopup>
|
||||
</menu>
|
||||
</menupopup>
|
||||
|
Loading…
Reference in New Issue
Block a user