Bug 400764 - "Don't depend on Firefox specifics for notifications for popups and missing plugins" [p=twanno@lycos.nl (Teune van Steeg) r=gavin a1.9=schrep]

This commit is contained in:
reed@reedloden.com 2007-12-19 03:26:36 -08:00
Родитель 6a5609241f
Коммит 9c442c7554
4 изменённых файлов: 34 добавлений и 28 удалений

Просмотреть файл

@ -320,8 +320,11 @@ const gPopupBlockerObserver = {
_reportButton: null,
_kIPM: Components.interfaces.nsIPermissionManager,
onUpdatePageReport: function ()
onUpdatePageReport: function (aEvent)
{
if (aEvent.originalTarget != gBrowser.selectedBrowser)
return;
if (!this._reportButton)
this._reportButton = document.getElementById("page-report-button");
@ -804,6 +807,7 @@ function prepareForStartup()
// Note: we need to listen to untrusted events, because the pluginfinder XBL
// binding can't fire trusted ones (runs with page privileges).
gBrowser.addEventListener("PluginNotFound", gMissingPluginInstaller.newMissingPlugin, true, true);
gBrowser.addEventListener("NewPluginInstalled", gMissingPluginInstaller.refreshBrowser, false);
gBrowser.addEventListener("NewTab", BrowserOpenTab, false);
window.addEventListener("AppCommand", HandleAppCommandEvent, true);
@ -4970,7 +4974,7 @@ function getPluginInfo(pluginElement)
missingPluginInstaller.prototype.installSinglePlugin = function(aEvent){
var tabbrowser = getBrowser();
var missingPluginsArray = new Object;
var missingPluginsArray = {};
var pluginInfo = getPluginInfo(aEvent.target);
missingPluginsArray[pluginInfo.mimetype] = pluginInfo;
@ -4978,7 +4982,7 @@ missingPluginInstaller.prototype.installSinglePlugin = function(aEvent){
if (missingPluginsArray) {
window.openDialog("chrome://mozapps/content/plugins/pluginInstallerWizard.xul",
"PFSWindow", "modal,chrome,resizable=yes",
{plugins: missingPluginsArray, tab: tabbrowser.mCurrentTab});
{plugins: missingPluginsArray, browser: tabbrowser.selectedBrowser});
}
aEvent.preventDefault();
@ -5017,15 +5021,14 @@ missingPluginInstaller.prototype.newMissingPlugin = function(aEvent){
break;
}
var tab = tabbrowser.mTabContainer.childNodes[i];
if (!tab.missingPlugins)
tab.missingPlugins = {};
var browser = tabbrowser.getBrowserAtIndex(i);
if (!browser.missingPlugins)
browser.missingPlugins = {};
var pluginInfo = getPluginInfo(aEvent.target);
tab.missingPlugins[pluginInfo.mimetype] = pluginInfo;
browser.missingPlugins[pluginInfo.mimetype] = pluginInfo;
var browser = tabbrowser.getBrowserAtIndex(i);
var notificationBox = gBrowser.getNotificationBox(browser);
if (!notificationBox.getNotificationWithValue("missing-plugins")) {
var bundle_browser = document.getElementById("bundle_browser");
@ -5044,23 +5047,30 @@ missingPluginInstaller.prototype.newMissingPlugin = function(aEvent){
}
}
missingPluginInstaller.prototype.closeNotification = function() {
var notificationBox = gBrowser.getNotificationBox();
missingPluginInstaller.prototype.refreshBrowser = function(aEvent) {
var browser = aEvent.target;
var notificationBox = gBrowser.getNotificationBox(browser);
var notification = notificationBox.getNotificationWithValue("missing-plugins");
// clear the plugin list, now that at least one plugin has been installed
browser.missingPlugins = null;
if (notification) {
// reset UI
notificationBox.removeNotification(notification);
}
// reload the browser to make the new plugin show.
browser.reload();
}
function pluginsMissing()
{
// get the urls of missing plugins
var tabbrowser = getBrowser();
var missingPluginsArray = tabbrowser.mCurrentTab.missingPlugins;
var missingPluginsArray = tabbrowser.selectedBrowser.missingPlugins;
if (missingPluginsArray) {
window.openDialog("chrome://mozapps/content/plugins/pluginInstallerWizard.xul",
"PFSWindow", "modal,chrome,resizable=yes", {plugins: missingPluginsArray, tab: tabbrowser.mCurrentTab});
"PFSWindow", "modal,chrome,resizable=yes",
{plugins: missingPluginsArray, browser: tabbrowser.selectedBrowser});
}
}

Просмотреть файл

@ -419,7 +419,7 @@
this.mTabBrowser.setIcon(this.mTab, null);
// changing location, clear out the missing plugins list
this.mTab.missingPlugins = null;
this.mBrowser.missingPlugins = null;
if (!this.mBlank && this.mTabBrowser.mCurrentTab == this.mTab) {
for (var i = 0; i < this.mTabBrowser.mProgressListeners.length; i++) {

Просмотреть файл

@ -474,13 +474,9 @@
<method name="updatePageReport">
<body>
<![CDATA[
var tabBrowser = this.getTabBrowser();
if (!tabBrowser || tabBrowser.mCurrentBrowser != this)
return;
var event = document.createEvent("Events");
event.initEvent("DOMUpdatePageReport", true, true);
tabBrowser.dispatchEvent(event);
this.dispatchEvent(event);
]]>
</body>
</method>

Просмотреть файл

@ -58,12 +58,13 @@ function nsPluginInstallerWizard(){
// how many plugins are to be installed
this.pluginsToInstallNum = 0;
this.mTab = null;
this.mBrowser = null;
this.mSuccessfullPluginInstallation = 0;
// arguments[0] is an array that contains two items:
// an array of mimetypes that are missing
// a reference to the tab that needs them, so we can reload it
// a reference to the browser that needs them,
// so we can notify which browser can be reloaded.
if ("arguments" in window) {
for (var item in window.arguments[0].plugins){
@ -73,7 +74,7 @@ function nsPluginInstallerWizard(){
this.mPluginRequestArrayLength++;
}
this.mTab = window.arguments[0].tab;
this.mBrowser = window.arguments[0].browser;
}
this.WSPluginCounter = 0;
@ -644,13 +645,12 @@ function wizardFinish(){
// don't refresh if no plugins were found or installed
if ((gPluginInstaller.mSuccessfullPluginInstallation > 0) &&
(gPluginInstaller.mPluginInfoArray.length != 0) &&
gPluginInstaller.mTab) {
// clear the tab's plugin list only if we installed at least one plugin
gPluginInstaller.mTab.missingPlugins = null;
// reset UI
window.opener.gMissingPluginInstaller.closeNotification();
// reload the browser to make the new plugin show
window.opener.getBrowser().reloadTab(gPluginInstaller.mTab);
gPluginInstaller.mBrowser) {
// notify listeners that a plugin is installed,
// so that they can reset the UI and update the browser.
var event = document.createEvent("Events");
event.initEvent("NewPluginInstalled", true, true);
gPluginInstaller.mBrowser.dispatchEvent(event);
}
return true;