1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/mozapps/plugins/content/pluginInstallerWizard.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,659 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +function nsPluginInstallerWizard(){ 1.9 + 1.10 + // create the request array 1.11 + this.mPluginRequests = new Map(); 1.12 + 1.13 + // create the plugin info array. 1.14 + // a hash indexed by plugin id so we don't install 1.15 + // the same plugin more than once. 1.16 + this.mPluginInfoArray = new Object(); 1.17 + this.mPluginInfoArrayLength = 0; 1.18 + 1.19 + // holds plugins we couldn't find 1.20 + this.mPluginNotFoundArray = new Object(); 1.21 + this.mPluginNotFoundArrayLength = 0; 1.22 + 1.23 + // array holding pids of plugins that require a license 1.24 + this.mPluginLicenseArray = new Array(); 1.25 + 1.26 + // how many plugins are to be installed 1.27 + this.pluginsToInstallNum = 0; 1.28 + 1.29 + this.mBrowser = null; 1.30 + this.mSuccessfullPluginInstallation = 0; 1.31 + this.mNeedsRestart = false; 1.32 + 1.33 + // arguments[0] is an object that contains two items: 1.34 + // a mimetype->pluginInfo map of missing plugins, 1.35 + // a reference to the browser that needs them, 1.36 + // so we can notify which browser can be reloaded. 1.37 + 1.38 + if ("arguments" in window) { 1.39 + for (let [mimetype, pluginInfo] of window.arguments[0].plugins){ 1.40 + this.mPluginRequests.set(mimetype, new nsPluginRequest(pluginInfo)); 1.41 + } 1.42 + 1.43 + this.mBrowser = window.arguments[0].browser; 1.44 + } 1.45 + 1.46 + this.WSPluginCounter = 0; 1.47 + this.licenseAcceptCounter = 0; 1.48 + 1.49 + this.prefBranch = null; 1.50 +} 1.51 + 1.52 +nsPluginInstallerWizard.prototype.getPluginData = function (){ 1.53 + // for each mPluginRequests item, call the datasource 1.54 + this.WSPluginCounter = 0; 1.55 + 1.56 + // initiate the datasource call 1.57 + var rdfUpdater = new nsRDFItemUpdater(this.getOS(), this.getChromeLocale()); 1.58 + 1.59 + for (let [mimetype, pluginRequest] of this.mPluginRequests) { 1.60 + rdfUpdater.checkForPlugin(pluginRequest); 1.61 + } 1.62 +} 1.63 + 1.64 +// aPluginInfo is null if the datasource call failed, and pid is -1 if 1.65 +// no matching plugin was found. 1.66 +nsPluginInstallerWizard.prototype.pluginInfoReceived = function (aPluginRequestItem, aPluginInfo){ 1.67 + this.WSPluginCounter++; 1.68 + 1.69 + if (aPluginInfo && (aPluginInfo.pid != -1) ) { 1.70 + // hash by id 1.71 + this.mPluginInfoArray[aPluginInfo.pid] = new PluginInfo(aPluginInfo); 1.72 + this.mPluginInfoArrayLength++; 1.73 + } else { 1.74 + this.mPluginNotFoundArray[aPluginRequestItem.mimetype] = aPluginRequestItem; 1.75 + this.mPluginNotFoundArrayLength++; 1.76 + } 1.77 + 1.78 + var progressMeter = document.getElementById("ws_request_progress"); 1.79 + 1.80 + if (progressMeter.getAttribute("mode") == "undetermined") 1.81 + progressMeter.setAttribute("mode", "determined"); 1.82 + 1.83 + progressMeter.setAttribute("value", 1.84 + ((this.WSPluginCounter / this.mPluginRequests.size) * 100) + "%"); 1.85 + 1.86 + if (this.WSPluginCounter == this.mPluginRequests.size) { 1.87 + // check if no plugins were found 1.88 + if (this.mPluginInfoArrayLength == 0) { 1.89 + this.advancePage("lastpage"); 1.90 + } else { 1.91 + this.advancePage(null); 1.92 + } 1.93 + } else { 1.94 + // process more. 1.95 + } 1.96 +} 1.97 + 1.98 +nsPluginInstallerWizard.prototype.showPluginList = function (){ 1.99 + var myPluginList = document.getElementById("pluginList"); 1.100 + var hasPluginWithInstallerUI = false; 1.101 + 1.102 + // clear children 1.103 + for (var run = myPluginList.childNodes.length; run > 0; run--) 1.104 + myPluginList.removeChild(myPluginList.childNodes.item(run)); 1.105 + 1.106 + this.pluginsToInstallNum = 0; 1.107 + 1.108 + for (var pluginInfoItem in this.mPluginInfoArray){ 1.109 + // [plugin image] [Plugin_Name Plugin_Version] 1.110 + 1.111 + var pluginInfo = this.mPluginInfoArray[pluginInfoItem]; 1.112 + 1.113 + // create the checkbox 1.114 + var myCheckbox = document.createElement("checkbox"); 1.115 + myCheckbox.setAttribute("checked", "true"); 1.116 + myCheckbox.setAttribute("oncommand", "gPluginInstaller.toggleInstallPlugin('" + pluginInfo.pid + "', this)"); 1.117 + // XXXlocalize (nit) 1.118 + myCheckbox.setAttribute("label", pluginInfo.name + " " + (pluginInfo.version ? pluginInfo.version : "")); 1.119 + myCheckbox.setAttribute("src", pluginInfo.IconUrl); 1.120 + 1.121 + myPluginList.appendChild(myCheckbox); 1.122 + 1.123 + if (pluginInfo.InstallerShowsUI == "true") 1.124 + hasPluginWithInstallerUI = true; 1.125 + 1.126 + // keep a running count of plugins the user wants to install 1.127 + this.pluginsToInstallNum++; 1.128 + } 1.129 + 1.130 + if (hasPluginWithInstallerUI) 1.131 + document.getElementById("installerUI").hidden = false; 1.132 + 1.133 + this.canAdvance(true); 1.134 + this.canRewind(false); 1.135 +} 1.136 + 1.137 +nsPluginInstallerWizard.prototype.toggleInstallPlugin = function (aPid, aCheckbox) { 1.138 + this.mPluginInfoArray[aPid].toBeInstalled = aCheckbox.checked; 1.139 + 1.140 + // if no plugins are checked, don't allow to advance 1.141 + this.pluginsToInstallNum = 0; 1.142 + for (var pluginInfoItem in this.mPluginInfoArray){ 1.143 + if (this.mPluginInfoArray[pluginInfoItem].toBeInstalled) 1.144 + this.pluginsToInstallNum++; 1.145 + } 1.146 + 1.147 + if (this.pluginsToInstallNum > 0) 1.148 + this.canAdvance(true); 1.149 + else 1.150 + this.canAdvance(false); 1.151 +} 1.152 + 1.153 +nsPluginInstallerWizard.prototype.canAdvance = function (aBool){ 1.154 + document.getElementById("plugin-installer-wizard").canAdvance = aBool; 1.155 +} 1.156 + 1.157 +nsPluginInstallerWizard.prototype.canRewind = function (aBool){ 1.158 + document.getElementById("plugin-installer-wizard").canRewind = aBool; 1.159 +} 1.160 + 1.161 +nsPluginInstallerWizard.prototype.canCancel = function (aBool){ 1.162 + document.documentElement.getButton("cancel").disabled = !aBool; 1.163 +} 1.164 + 1.165 +nsPluginInstallerWizard.prototype.showLicenses = function (){ 1.166 + this.canAdvance(false); 1.167 + this.canRewind(false); 1.168 + 1.169 + // only add if a license is provided and the plugin was selected to 1.170 + // be installed 1.171 + for (var pluginInfoItem in this.mPluginInfoArray){ 1.172 + var myPluginInfoItem = this.mPluginInfoArray[pluginInfoItem]; 1.173 + if (myPluginInfoItem.toBeInstalled && myPluginInfoItem.licenseURL && (myPluginInfoItem.licenseURL != "")) 1.174 + this.mPluginLicenseArray.push(myPluginInfoItem.pid); 1.175 + } 1.176 + 1.177 + if (this.mPluginLicenseArray.length == 0) { 1.178 + // no plugins require licenses 1.179 + this.advancePage(null); 1.180 + } else { 1.181 + this.licenseAcceptCounter = 0; 1.182 + 1.183 + // add a nsIWebProgress listener to the license iframe. 1.184 + var docShell = document.getElementById("licenseIFrame").docShell; 1.185 + var iiReq = docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor); 1.186 + var webProgress = iiReq.getInterface(Components.interfaces.nsIWebProgress); 1.187 + webProgress.addProgressListener(gPluginInstaller.progressListener, 1.188 + Components.interfaces.nsIWebProgress.NOTIFY_ALL); 1.189 + 1.190 + this.showLicense(); 1.191 + } 1.192 +} 1.193 + 1.194 +nsPluginInstallerWizard.prototype.enableNext = function (){ 1.195 + // if only one plugin exists, don't enable the next button until 1.196 + // the license is accepted 1.197 + if (gPluginInstaller.pluginsToInstallNum > 1) 1.198 + gPluginInstaller.canAdvance(true); 1.199 + 1.200 + document.getElementById("licenseRadioGroup1").disabled = false; 1.201 + document.getElementById("licenseRadioGroup2").disabled = false; 1.202 +} 1.203 + 1.204 +const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener; 1.205 +nsPluginInstallerWizard.prototype.progressListener = { 1.206 + onStateChange : function(aWebProgress, aRequest, aStateFlags, aStatus) 1.207 + { 1.208 + if ((aStateFlags & nsIWebProgressListener.STATE_STOP) && 1.209 + (aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK)) { 1.210 + // iframe loaded 1.211 + gPluginInstaller.enableNext(); 1.212 + } 1.213 + }, 1.214 + 1.215 + onProgressChange : function(aWebProgress, aRequest, aCurSelfProgress, 1.216 + aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress) 1.217 + {}, 1.218 + onStatusChange : function(aWebProgress, aRequest, aStatus, aMessage) 1.219 + {}, 1.220 + 1.221 + QueryInterface : function(aIID) 1.222 + { 1.223 + if (aIID.equals(Components.interfaces.nsIWebProgressListener) || 1.224 + aIID.equals(Components.interfaces.nsISupportsWeakReference) || 1.225 + aIID.equals(Components.interfaces.nsISupports)) 1.226 + return this; 1.227 + throw Components.results.NS_NOINTERFACE; 1.228 + } 1.229 +} 1.230 + 1.231 +nsPluginInstallerWizard.prototype.showLicense = function (){ 1.232 + var pluginInfo = this.mPluginInfoArray[this.mPluginLicenseArray[this.licenseAcceptCounter]]; 1.233 + 1.234 + this.canAdvance(false); 1.235 + 1.236 + var loadFlags = Components.interfaces.nsIWebNavigation.LOAD_FLAGS_NONE; 1.237 + document.getElementById("licenseIFrame").webNavigation.loadURI(pluginInfo.licenseURL, loadFlags, null, null, null); 1.238 + 1.239 + document.getElementById("pluginLicenseLabel").firstChild.nodeValue = 1.240 + this.getFormattedString("pluginLicenseAgreement.label", [pluginInfo.name]); 1.241 + 1.242 + document.getElementById("licenseRadioGroup1").disabled = true; 1.243 + document.getElementById("licenseRadioGroup2").disabled = true; 1.244 + document.getElementById("licenseRadioGroup").selectedIndex = 1.245 + pluginInfo.licenseAccepted ? 0 : 1; 1.246 +} 1.247 + 1.248 +nsPluginInstallerWizard.prototype.showNextLicense = function (){ 1.249 + var rv = true; 1.250 + 1.251 + if (this.mPluginLicenseArray.length > 0) { 1.252 + this.storeLicenseRadioGroup(); 1.253 + 1.254 + this.licenseAcceptCounter++; 1.255 + 1.256 + if (this.licenseAcceptCounter < this.mPluginLicenseArray.length) { 1.257 + this.showLicense(); 1.258 + 1.259 + rv = false; 1.260 + this.canRewind(true); 1.261 + } 1.262 + } 1.263 + 1.264 + return rv; 1.265 +} 1.266 + 1.267 +nsPluginInstallerWizard.prototype.showPreviousLicense = function (){ 1.268 + this.storeLicenseRadioGroup(); 1.269 + this.licenseAcceptCounter--; 1.270 + 1.271 + if (this.licenseAcceptCounter > 0) 1.272 + this.canRewind(true); 1.273 + else 1.274 + this.canRewind(false); 1.275 + 1.276 + this.showLicense(); 1.277 + 1.278 + // don't allow to return from the license screens 1.279 + return false; 1.280 +} 1.281 + 1.282 +nsPluginInstallerWizard.prototype.storeLicenseRadioGroup = function (){ 1.283 + var pluginInfo = this.mPluginInfoArray[this.mPluginLicenseArray[this.licenseAcceptCounter]]; 1.284 + pluginInfo.licenseAccepted = !document.getElementById("licenseRadioGroup").selectedIndex; 1.285 +} 1.286 + 1.287 +nsPluginInstallerWizard.prototype.licenseRadioGroupChange = function(aAccepted) { 1.288 + // only if one plugin is to be installed should selection change the next button 1.289 + if (this.pluginsToInstallNum == 1) 1.290 + this.canAdvance(aAccepted); 1.291 +} 1.292 + 1.293 +nsPluginInstallerWizard.prototype.advancePage = function (aPageId){ 1.294 + this.canAdvance(true); 1.295 + document.getElementById("plugin-installer-wizard").advance(aPageId); 1.296 +} 1.297 + 1.298 +nsPluginInstallerWizard.prototype.startPluginInstallation = function (){ 1.299 + this.canAdvance(false); 1.300 + this.canRewind(false); 1.301 + 1.302 + var installerPlugins = []; 1.303 + var xpiPlugins = []; 1.304 + 1.305 + for (var pluginInfoItem in this.mPluginInfoArray){ 1.306 + var pluginItem = this.mPluginInfoArray[pluginInfoItem]; 1.307 + 1.308 + if (pluginItem.toBeInstalled && pluginItem.licenseAccepted) { 1.309 + if (pluginItem.InstallerLocation) 1.310 + installerPlugins.push(pluginItem); 1.311 + else if (pluginItem.XPILocation) 1.312 + xpiPlugins.push(pluginItem); 1.313 + } 1.314 + } 1.315 + 1.316 + if (installerPlugins.length > 0 || xpiPlugins.length > 0) 1.317 + PluginInstallService.startPluginInstallation(installerPlugins, 1.318 + xpiPlugins); 1.319 + else 1.320 + this.advancePage(null); 1.321 +} 1.322 + 1.323 +/* 1.324 + 0 starting download 1.325 + 1 download finished 1.326 + 2 starting installation 1.327 + 3 finished installation 1.328 + 4 all done 1.329 +*/ 1.330 +nsPluginInstallerWizard.prototype.pluginInstallationProgress = function (aPid, aProgress, aError) { 1.331 + 1.332 + var statMsg = null; 1.333 + var pluginInfo = gPluginInstaller.mPluginInfoArray[aPid]; 1.334 + 1.335 + switch (aProgress) { 1.336 + 1.337 + case 0: 1.338 + statMsg = this.getFormattedString("pluginInstallation.download.start", [pluginInfo.name]); 1.339 + break; 1.340 + 1.341 + case 1: 1.342 + statMsg = this.getFormattedString("pluginInstallation.download.finish", [pluginInfo.name]); 1.343 + break; 1.344 + 1.345 + case 2: 1.346 + statMsg = this.getFormattedString("pluginInstallation.install.start", [pluginInfo.name]); 1.347 + var progressElm = document.getElementById("plugin_install_progress"); 1.348 + progressElm.setAttribute("mode", "undetermined"); 1.349 + break; 1.350 + 1.351 + case 3: 1.352 + if (aError) { 1.353 + statMsg = this.getFormattedString("pluginInstallation.install.error", [pluginInfo.name, aError]); 1.354 + pluginInfo.error = aError; 1.355 + } else { 1.356 + statMsg = this.getFormattedString("pluginInstallation.install.finish", [pluginInfo.name]); 1.357 + pluginInfo.error = null; 1.358 + } 1.359 + break; 1.360 + 1.361 + case 4: 1.362 + statMsg = this.getString("pluginInstallation.complete"); 1.363 + break; 1.364 + } 1.365 + 1.366 + if (statMsg) 1.367 + document.getElementById("plugin_install_progress_message").value = statMsg; 1.368 + 1.369 + if (aProgress == 4) { 1.370 + this.advancePage(null); 1.371 + } 1.372 +} 1.373 + 1.374 +nsPluginInstallerWizard.prototype.pluginInstallationProgressMeter = function (aPid, aValue, aMaxValue){ 1.375 + var progressElm = document.getElementById("plugin_install_progress"); 1.376 + 1.377 + if (progressElm.getAttribute("mode") == "undetermined") 1.378 + progressElm.setAttribute("mode", "determined"); 1.379 + 1.380 + progressElm.setAttribute("value", Math.ceil((aValue / aMaxValue) * 100) + "%") 1.381 +} 1.382 + 1.383 +nsPluginInstallerWizard.prototype.addPluginResultRow = function (aImgSrc, aName, aNameTooltip, aStatus, aStatusTooltip, aManualUrl){ 1.384 + var myRows = document.getElementById("pluginResultList"); 1.385 + 1.386 + var myRow = document.createElement("row"); 1.387 + myRow.setAttribute("align", "center"); 1.388 + 1.389 + // create the image 1.390 + var myImage = document.createElement("image"); 1.391 + myImage.setAttribute("src", aImgSrc); 1.392 + myImage.setAttribute("height", "16px"); 1.393 + myImage.setAttribute("width", "16px"); 1.394 + myRow.appendChild(myImage) 1.395 + 1.396 + // create the labels 1.397 + var myLabel = document.createElement("label"); 1.398 + myLabel.setAttribute("value", aName); 1.399 + if (aNameTooltip) 1.400 + myLabel.setAttribute("tooltiptext", aNameTooltip); 1.401 + myRow.appendChild(myLabel); 1.402 + 1.403 + if (aStatus) { 1.404 + myLabel = document.createElement("label"); 1.405 + myLabel.setAttribute("value", aStatus); 1.406 + myRow.appendChild(myLabel); 1.407 + } 1.408 + 1.409 + // manual install 1.410 + if (aManualUrl) { 1.411 + var myButton = document.createElement("button"); 1.412 + 1.413 + var manualInstallLabel = this.getString("pluginInstallationSummary.manualInstall.label"); 1.414 + var manualInstallTooltip = this.getString("pluginInstallationSummary.manualInstall.tooltip"); 1.415 + 1.416 + myButton.setAttribute("label", manualInstallLabel); 1.417 + myButton.setAttribute("tooltiptext", manualInstallTooltip); 1.418 + 1.419 + myRow.appendChild(myButton); 1.420 + 1.421 + // XXX: XUL sucks, need to add the listener after it got added into the document 1.422 + if (aManualUrl) 1.423 + myButton.addEventListener("command", function() { gPluginInstaller.loadURL(aManualUrl) }, false); 1.424 + } 1.425 + 1.426 + myRows.appendChild(myRow); 1.427 +} 1.428 + 1.429 +nsPluginInstallerWizard.prototype.showPluginResults = function (){ 1.430 + var notInstalledList = "?action=missingplugins"; 1.431 + var myRows = document.getElementById("pluginResultList"); 1.432 + 1.433 + // clear children 1.434 + for (var run = myRows.childNodes.length; run--; run > 0) 1.435 + myRows.removeChild(myRows.childNodes.item(run)); 1.436 + 1.437 + for (var pluginInfoItem in this.mPluginInfoArray){ 1.438 + // [plugin image] [Plugin_Name Plugin_Version] [Success/Failed] [Manual Install (if Failed)] 1.439 + 1.440 + var myPluginItem = this.mPluginInfoArray[pluginInfoItem]; 1.441 + 1.442 + if (myPluginItem.toBeInstalled) { 1.443 + var statusMsg; 1.444 + var statusTooltip; 1.445 + if (myPluginItem.error){ 1.446 + statusMsg = this.getString("pluginInstallationSummary.failed"); 1.447 + statusTooltip = myPluginItem.error; 1.448 + notInstalledList += "&mimetype=" + pluginInfoItem; 1.449 + } else if (!myPluginItem.licenseAccepted) { 1.450 + statusMsg = this.getString("pluginInstallationSummary.licenseNotAccepted"); 1.451 + } else if (!myPluginItem.XPILocation && !myPluginItem.InstallerLocation) { 1.452 + statusMsg = this.getString("pluginInstallationSummary.notAvailable"); 1.453 + notInstalledList += "&mimetype=" + pluginInfoItem; 1.454 + } else { 1.455 + this.mSuccessfullPluginInstallation++; 1.456 + statusMsg = this.getString("pluginInstallationSummary.success"); 1.457 + 1.458 + // only check needsRestart if the plugin was successfully installed. 1.459 + if (myPluginItem.needsRestart) 1.460 + this.mNeedsRestart = true; 1.461 + } 1.462 + 1.463 + // manual url - either returned from the webservice or the pluginspage attribute 1.464 + var manualUrl; 1.465 + if ((myPluginItem.error || (!myPluginItem.XPILocation && !myPluginItem.InstallerLocation)) && 1.466 + (myPluginItem.manualInstallationURL || this.mPluginRequests.get(myPluginItem.requestedMimetype).pluginsPage)){ 1.467 + manualUrl = myPluginItem.manualInstallationURL ? myPluginItem.manualInstallationURL : this.mPluginRequests.get(myPluginItem.requestedMimetype).pluginsPage; 1.468 + } 1.469 + 1.470 + this.addPluginResultRow( 1.471 + myPluginItem.IconUrl, 1.472 + myPluginItem.name + " " + (myPluginItem.version ? myPluginItem.version : ""), 1.473 + null, 1.474 + statusMsg, 1.475 + statusTooltip, 1.476 + manualUrl); 1.477 + } 1.478 + } 1.479 + 1.480 + // handle plugins we couldn't find 1.481 + for (pluginInfoItem in this.mPluginNotFoundArray){ 1.482 + var pluginRequest = this.mPluginNotFoundArray[pluginInfoItem]; 1.483 + 1.484 + // if there is a pluginspage, show UI 1.485 + if (pluginRequest.pluginsPage) { 1.486 + this.addPluginResultRow( 1.487 + "", 1.488 + this.getFormattedString("pluginInstallation.unknownPlugin", [pluginInfoItem]), 1.489 + null, 1.490 + null, 1.491 + null, 1.492 + pluginRequest.pluginsPage); 1.493 + } 1.494 + 1.495 + notInstalledList += "&mimetype=" + pluginInfoItem; 1.496 + } 1.497 + 1.498 + // no plugins were found, so change the description of the final page. 1.499 + if (this.mPluginInfoArrayLength == 0) { 1.500 + var noPluginsFound = this.getString("pluginInstallation.noPluginsFound"); 1.501 + document.getElementById("pluginSummaryDescription").setAttribute("value", noPluginsFound); 1.502 + } else if (this.mSuccessfullPluginInstallation == 0) { 1.503 + // plugins found, but none were installed. 1.504 + var noPluginsInstalled = this.getString("pluginInstallation.noPluginsInstalled"); 1.505 + document.getElementById("pluginSummaryDescription").setAttribute("value", noPluginsInstalled); 1.506 + } 1.507 + 1.508 + document.getElementById("pluginSummaryRestartNeeded").hidden = !this.mNeedsRestart; 1.509 + 1.510 + var app = Components.classes["@mozilla.org/xre/app-info;1"] 1.511 + .getService(Components.interfaces.nsIXULAppInfo); 1.512 + 1.513 + // set the get more info link to contain the mimetypes we couldn't install. 1.514 + notInstalledList += 1.515 + "&appID=" + app.ID + 1.516 + "&appVersion=" + app.platformBuildID + 1.517 + "&clientOS=" + this.getOS() + 1.518 + "&chromeLocale=" + this.getChromeLocale() + 1.519 + "&appRelease=" + app.version; 1.520 + 1.521 + document.getElementById("moreInfoLink").addEventListener("click", function() { gPluginInstaller.loadURL("https://pfs.mozilla.org/plugins/" + notInstalledList) }, false); 1.522 + 1.523 + if (this.mNeedsRestart) { 1.524 + var cancel = document.getElementById("plugin-installer-wizard").getButton("cancel"); 1.525 + cancel.label = this.getString("pluginInstallation.close.label"); 1.526 + cancel.accessKey = this.getString("pluginInstallation.close.accesskey"); 1.527 + var finish = document.getElementById("plugin-installer-wizard").getButton("finish"); 1.528 + finish.label = this.getFormattedString("pluginInstallation.restart.label", [app.name]); 1.529 + finish.accessKey = this.getString("pluginInstallation.restart.accesskey"); 1.530 + this.canCancel(true); 1.531 + } 1.532 + else { 1.533 + this.canCancel(false); 1.534 + } 1.535 + this.canAdvance(true); 1.536 + this.canRewind(false); 1.537 +} 1.538 + 1.539 +nsPluginInstallerWizard.prototype.loadURL = function (aUrl){ 1.540 + // Check if the page where the plugin came from can load aUrl before 1.541 + // loading it, and do *not* allow loading URIs that would inherit our 1.542 + // principal. 1.543 + 1.544 + var pluginPagePrincipal = 1.545 + window.opener.content.document.nodePrincipal; 1.546 + 1.547 + const nsIScriptSecurityManager = 1.548 + Components.interfaces.nsIScriptSecurityManager; 1.549 + var secMan = Components.classes["@mozilla.org/scriptsecuritymanager;1"] 1.550 + .getService(nsIScriptSecurityManager); 1.551 + 1.552 + secMan.checkLoadURIStrWithPrincipal(pluginPagePrincipal, aUrl, 1.553 + nsIScriptSecurityManager.DISALLOW_INHERIT_PRINCIPAL); 1.554 + 1.555 + window.opener.open(aUrl); 1.556 +} 1.557 + 1.558 +nsPluginInstallerWizard.prototype.getString = function (aName){ 1.559 + return document.getElementById("pluginWizardString").getString(aName); 1.560 +} 1.561 + 1.562 +nsPluginInstallerWizard.prototype.getFormattedString = function (aName, aArray){ 1.563 + return document.getElementById("pluginWizardString").getFormattedString(aName, aArray); 1.564 +} 1.565 + 1.566 +nsPluginInstallerWizard.prototype.getOS = function (){ 1.567 + var httpService = Components.classes["@mozilla.org/network/protocol;1?name=http"] 1.568 + .getService(Components.interfaces.nsIHttpProtocolHandler); 1.569 + return httpService.oscpu; 1.570 +} 1.571 + 1.572 +nsPluginInstallerWizard.prototype.getChromeLocale = function (){ 1.573 + var chromeReg = Components.classes["@mozilla.org/chrome/chrome-registry;1"] 1.574 + .getService(Components.interfaces.nsIXULChromeRegistry); 1.575 + return chromeReg.getSelectedLocale("global"); 1.576 +} 1.577 + 1.578 +nsPluginInstallerWizard.prototype.getPrefBranch = function (){ 1.579 + if (!this.prefBranch) 1.580 + this.prefBranch = Components.classes["@mozilla.org/preferences-service;1"] 1.581 + .getService(Components.interfaces.nsIPrefBranch); 1.582 + return this.prefBranch; 1.583 +} 1.584 +function nsPluginRequest(aPlugRequest){ 1.585 + this.mimetype = encodeURI(aPlugRequest.mimetype); 1.586 + this.pluginsPage = aPlugRequest.pluginsPage; 1.587 +} 1.588 + 1.589 +function PluginInfo(aResult) { 1.590 + this.name = aResult.name; 1.591 + this.pid = aResult.pid; 1.592 + this.version = aResult.version; 1.593 + this.IconUrl = aResult.IconUrl; 1.594 + this.InstallerLocation = aResult.InstallerLocation; 1.595 + this.InstallerHash = aResult.InstallerHash; 1.596 + this.XPILocation = aResult.XPILocation; 1.597 + this.XPIHash = aResult.XPIHash; 1.598 + this.InstallerShowsUI = aResult.InstallerShowsUI; 1.599 + this.manualInstallationURL = aResult.manualInstallationURL; 1.600 + this.requestedMimetype = aResult.requestedMimetype; 1.601 + this.licenseURL = aResult.licenseURL; 1.602 + this.needsRestart = (aResult.needsRestart == "true"); 1.603 + 1.604 + this.error = null; 1.605 + this.toBeInstalled = true; 1.606 + 1.607 + // no license provided, make it accepted 1.608 + this.licenseAccepted = this.licenseURL ? false : true; 1.609 +} 1.610 + 1.611 +var gPluginInstaller; 1.612 + 1.613 +function wizardInit(){ 1.614 + gPluginInstaller = new nsPluginInstallerWizard(); 1.615 + gPluginInstaller.canAdvance(false); 1.616 + gPluginInstaller.getPluginData(); 1.617 +} 1.618 + 1.619 +function wizardFinish(){ 1.620 + if (gPluginInstaller.mNeedsRestart) { 1.621 + // Notify all windows that an application quit has been requested. 1.622 + var os = Components.classes["@mozilla.org/observer-service;1"] 1.623 + .getService(Components.interfaces.nsIObserverService); 1.624 + var cancelQuit = Components.classes["@mozilla.org/supports-PRBool;1"] 1.625 + .createInstance(Components.interfaces.nsISupportsPRBool); 1.626 + os.notifyObservers(cancelQuit, "quit-application-requested", "restart"); 1.627 + 1.628 + // Something aborted the quit process. 1.629 + if (!cancelQuit.data) { 1.630 + var nsIAppStartup = Components.interfaces.nsIAppStartup; 1.631 + var appStartup = Components.classes["@mozilla.org/toolkit/app-startup;1"] 1.632 + .getService(nsIAppStartup); 1.633 + appStartup.quit(nsIAppStartup.eAttemptQuit | nsIAppStartup.eRestart); 1.634 + return true; 1.635 + } 1.636 + } 1.637 + 1.638 + // don't refresh if no plugins were found or installed 1.639 + if ((gPluginInstaller.mSuccessfullPluginInstallation > 0) && 1.640 + (gPluginInstaller.mPluginInfoArray.length != 0)) { 1.641 + 1.642 + // reload plugins so JS detection works immediately 1.643 + try { 1.644 + var ph = Components.classes["@mozilla.org/plugin/host;1"] 1.645 + .getService(Components.interfaces.nsIPluginHost); 1.646 + ph.reloadPlugins(false); 1.647 + } 1.648 + catch (e) { 1.649 + // reloadPlugins throws an exception if there were no plugins to load 1.650 + } 1.651 + 1.652 + if (gPluginInstaller.mBrowser) { 1.653 + // notify listeners that a plugin is installed, 1.654 + // so that they can reset the UI and update the browser. 1.655 + var event = document.createEvent("Events"); 1.656 + event.initEvent("NewPluginInstalled", true, true); 1.657 + gPluginInstaller.mBrowser.dispatchEvent(event); 1.658 + } 1.659 + } 1.660 + 1.661 + return true; 1.662 +}