Bug 388504 - It should be possible for an extension to reload Page Info on a different document patch by Florian Quèze <f.qu@queze.net>, r=db48x, sr=neil

This commit is contained in:
db48x@yahoo.com 2007-08-06 09:13:05 -07:00
parent 8d4874280c
commit 4398f99eea
4 changed files with 75 additions and 28 deletions

View File

@ -62,8 +62,7 @@ function initFeedTab()
}
var feedListbox = document.getElementById("feedListbox");
if (feedListbox.getRowCount() > 0)
document.getElementById("feedTab").hidden = false;
document.getElementById("feedTab").hidden = feedListbox.getRowCount() == 0;
}
function onSubscribeFeed()

View File

@ -243,9 +243,16 @@ const XHTMLre = RegExp(XHTMLNSre + "|" + XHTML2NSre, "");
* invoked as "XXXLoadFunc();"
*/
// These functions are called once when the Page Info window is opened.
// These functions are called to build the data displayed in the Page
// Info window. The global variables gDocument and gWindow are set.
var onLoadRegistry = [ ];
// These functions are called to remove old data still displayed in
// the window when the document whose information is displayed
// changes. For example, at this time, the list of images of the Media
// tab is cleared.
var onResetRegistry = [ ];
// These are called once for each subframe of the target document and
// the target document itself. The frame is passed as an argument.
var onProcessFrame = [ ];
@ -294,27 +301,12 @@ function onLoadPageInfo()
gDocument = gWindow.document;
}
var titleFormat = gWindow != gWindow.top ? "pageInfo.frame.title"
: "pageInfo.page.title";
document.title = gBundle.getFormattedString(titleFormat, [gDocument.location]);
document.getElementById("main-window").setAttribute("relatedUrl", gDocument.location);
// do the easy stuff first
makeGeneralTab();
// init media view
var imageTree = document.getElementById("imagetree");
imageTree.view = gImageView;
// and then the hard stuff
makeTabs(gDocument, gWindow);
initFeedTab();
onLoadPermission();
/* Call registered overlay init functions */
onLoadRegistry.map(function(func) { func(); });
// build the content
loadPageInfo();
/* Select the requested tab, if the name is specified */
var initialTab = "general";
@ -328,6 +320,55 @@ function onLoadPageInfo()
radioGroup.focus();
}
function loadPageInfo()
{
var titleFormat = gWindow != gWindow.top ? "pageInfo.frame.title"
: "pageInfo.page.title";
document.title = gBundle.getFormattedString(titleFormat, [gDocument.location]);
document.getElementById("main-window").setAttribute("relatedUrl", gDocument.location);
// do the easy stuff first
makeGeneralTab();
// and then the hard stuff
makeTabs(gDocument, gWindow);
initFeedTab();
onLoadPermission();
/* Call registered overlay init functions */
onLoadRegistry.map(function(func) { func(); });
}
function resetPageInfo()
{
/* Reset Meta tags part */
gMetaView.clear();
/* Reset Media tab */
var mediaTab = document.getElementById("mediaTab");
if (!mediaTab.hidden) {
var os = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
os.removeObserver(imagePermissionObserver, "perm-changed");
mediaTab.hidden = true;
}
gImageView.clear();
gImageHash = {};
/* Reset Feeds Tab */
var feedListbox = document.getElementById("feedListbox");
while (feedListbox.firstChild)
feedListbox.removeChild(feedListbox.firstChild);
/* Call registered overlay reset functions */
onResetRegistry.map(function(func) { func(); });
/* And let's rebuild the data */
loadPageInfo();
}
function onUnloadPageInfo()
{
if (!document.getElementById("mediaTab").hidden) {
@ -410,10 +451,9 @@ function makeGeneralTab()
var metaNodes = gDocument.getElementsByTagName("meta");
var length = metaNodes.length;
if (!length) {
var metaGroup = document.getElementById("metaTags");
var metaGroup = document.getElementById("metaTags");
if (!length)
metaGroup.collapsed = true;
}
else {
var metaTagsCaption = document.getElementById("metaTagsCaption");
if (length == 1)
@ -425,6 +465,8 @@ function makeGeneralTab()
for (var i = 0; i < length; i++)
gMetaView.addRow([metaNodes[i].name || metaNodes[i].httpEquiv, metaNodes[i].content]);
metaGroup.collapsed = false;
}
// get the date of last modification

View File

@ -86,6 +86,7 @@ function onLoadPermission()
.getService(Components.interfaces.nsIPrefBranch2);
var uri = gDocument.documentURIObject;
var permTab = document.getElementById("permTab");
if(/^https?/.test(uri.scheme)) {
gPermURI = uri;
var hostText = document.getElementById("hostText");
@ -97,9 +98,10 @@ function onLoadPermission()
.getService(Components.interfaces.nsIObserverService);
os.addObserver(permissionObserver, "perm-changed", false);
onUnloadRegistry.push(onUnloadPermission);
permTab.hidden = false;
}
else
document.getElementById("permTab").hidden = true;
permTab.hidden = true;
}
function onUnloadPermission()

View File

@ -162,10 +162,14 @@ function securityOnLoad() {
var info = security._getSecurityInfo();
if (!info) {
document.getElementById("securityTab").setAttribute("hidden", true);
document.getElementById("securityTab").hidden = true;
document.getElementById("securityBox").collapsed = true;
return;
}
else {
document.getElementById("securityTab").hidden = false;
document.getElementById("securityBox").collapsed = false;
}
/* Set Identity section text */
setText("security-identity-domain-value", info.hostName);
@ -198,15 +202,15 @@ function securityOnLoad() {
setText("general-security-identity", generalPageIdentityString);
/* Manage the View Cert button*/
var viewCert = document.getElementById("security-view-cert");
if (info.cert) {
var viewText = pageInfoBundle.getString("securityCertText");
setText("security-view-text", viewText);
security._cert = info.cert;
viewCert.collapsed = false;
}
else {
var viewCert = document.getElementById("security-view-cert");
else
viewCert.collapsed = true;
}
/* Set Privacy & History section text */
var yesStr = pageInfoBundle.getString("yes");