toolkit/mozapps/plugins/content/pluginInstallerWizard.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 function nsPluginInstallerWizard(){
     7   // create the request array
     8   this.mPluginRequests = new Map();
    10   // create the plugin info array.
    11   // a hash indexed by plugin id so we don't install 
    12   // the same plugin more than once.
    13   this.mPluginInfoArray = new Object();
    14   this.mPluginInfoArrayLength = 0;
    16   // holds plugins we couldn't find
    17   this.mPluginNotFoundArray = new Object();
    18   this.mPluginNotFoundArrayLength = 0;
    20   // array holding pids of plugins that require a license
    21   this.mPluginLicenseArray = new Array();
    23   // how many plugins are to be installed
    24   this.pluginsToInstallNum = 0;
    26   this.mBrowser = null;
    27   this.mSuccessfullPluginInstallation = 0;
    28   this.mNeedsRestart = false;
    30   // arguments[0] is an object that contains two items:
    31   //     a mimetype->pluginInfo map of missing plugins,
    32   //     a reference to the browser that needs them, 
    33   //        so we can notify which browser can be reloaded.
    35   if ("arguments" in window) {
    36     for (let [mimetype, pluginInfo] of window.arguments[0].plugins){
    37       this.mPluginRequests.set(mimetype, new nsPluginRequest(pluginInfo));
    38     }
    40     this.mBrowser = window.arguments[0].browser;
    41   }
    43   this.WSPluginCounter = 0;
    44   this.licenseAcceptCounter = 0;
    46   this.prefBranch = null;
    47 }
    49 nsPluginInstallerWizard.prototype.getPluginData = function (){
    50   // for each mPluginRequests item, call the datasource
    51   this.WSPluginCounter = 0;
    53   // initiate the datasource call
    54   var rdfUpdater = new nsRDFItemUpdater(this.getOS(), this.getChromeLocale());
    56   for (let [mimetype, pluginRequest] of this.mPluginRequests) {
    57     rdfUpdater.checkForPlugin(pluginRequest);
    58   }
    59 }
    61 // aPluginInfo is null if the datasource call failed, and pid is -1 if
    62 // no matching plugin was found.
    63 nsPluginInstallerWizard.prototype.pluginInfoReceived = function (aPluginRequestItem, aPluginInfo){
    64   this.WSPluginCounter++;
    66   if (aPluginInfo && (aPluginInfo.pid != -1) ) {
    67     // hash by id
    68     this.mPluginInfoArray[aPluginInfo.pid] = new PluginInfo(aPluginInfo);
    69     this.mPluginInfoArrayLength++;
    70   } else {
    71     this.mPluginNotFoundArray[aPluginRequestItem.mimetype] = aPluginRequestItem;
    72     this.mPluginNotFoundArrayLength++;
    73   }
    75   var progressMeter = document.getElementById("ws_request_progress");
    77   if (progressMeter.getAttribute("mode") == "undetermined")
    78     progressMeter.setAttribute("mode", "determined");
    80   progressMeter.setAttribute("value",
    81       ((this.WSPluginCounter / this.mPluginRequests.size) * 100) + "%");
    83   if (this.WSPluginCounter == this.mPluginRequests.size) {
    84     // check if no plugins were found
    85     if (this.mPluginInfoArrayLength == 0) {
    86       this.advancePage("lastpage");
    87     } else {
    88       this.advancePage(null);
    89     }
    90   } else {
    91     // process more.
    92   }
    93 }
    95 nsPluginInstallerWizard.prototype.showPluginList = function (){
    96   var myPluginList = document.getElementById("pluginList");
    97   var hasPluginWithInstallerUI = false;
    99   // clear children
   100   for (var run = myPluginList.childNodes.length; run > 0; run--)
   101     myPluginList.removeChild(myPluginList.childNodes.item(run));
   103   this.pluginsToInstallNum = 0;
   105   for (var pluginInfoItem in this.mPluginInfoArray){
   106     // [plugin image] [Plugin_Name Plugin_Version]
   108     var pluginInfo = this.mPluginInfoArray[pluginInfoItem];
   110     // create the checkbox
   111     var myCheckbox = document.createElement("checkbox");
   112     myCheckbox.setAttribute("checked", "true");
   113     myCheckbox.setAttribute("oncommand", "gPluginInstaller.toggleInstallPlugin('" + pluginInfo.pid + "', this)");
   114     // XXXlocalize (nit)
   115     myCheckbox.setAttribute("label", pluginInfo.name + " " + (pluginInfo.version ? pluginInfo.version : ""));
   116     myCheckbox.setAttribute("src", pluginInfo.IconUrl);
   118     myPluginList.appendChild(myCheckbox);
   120     if (pluginInfo.InstallerShowsUI == "true")
   121       hasPluginWithInstallerUI = true;
   123     // keep a running count of plugins the user wants to install
   124     this.pluginsToInstallNum++;
   125   }
   127   if (hasPluginWithInstallerUI)
   128     document.getElementById("installerUI").hidden = false;
   130   this.canAdvance(true);
   131   this.canRewind(false);
   132 }
   134 nsPluginInstallerWizard.prototype.toggleInstallPlugin = function (aPid, aCheckbox) {
   135   this.mPluginInfoArray[aPid].toBeInstalled = aCheckbox.checked;
   137   // if no plugins are checked, don't allow to advance
   138   this.pluginsToInstallNum = 0;
   139   for (var pluginInfoItem in this.mPluginInfoArray){
   140     if (this.mPluginInfoArray[pluginInfoItem].toBeInstalled)
   141       this.pluginsToInstallNum++;
   142   }
   144   if (this.pluginsToInstallNum > 0)
   145     this.canAdvance(true);
   146   else
   147     this.canAdvance(false);
   148 }
   150 nsPluginInstallerWizard.prototype.canAdvance = function (aBool){
   151   document.getElementById("plugin-installer-wizard").canAdvance = aBool;
   152 }
   154 nsPluginInstallerWizard.prototype.canRewind = function (aBool){
   155   document.getElementById("plugin-installer-wizard").canRewind = aBool;
   156 }
   158 nsPluginInstallerWizard.prototype.canCancel = function (aBool){
   159   document.documentElement.getButton("cancel").disabled = !aBool;
   160 }
   162 nsPluginInstallerWizard.prototype.showLicenses = function (){
   163   this.canAdvance(false);
   164   this.canRewind(false);
   166   // only add if a license is provided and the plugin was selected to
   167   // be installed
   168   for (var pluginInfoItem in this.mPluginInfoArray){
   169     var myPluginInfoItem = this.mPluginInfoArray[pluginInfoItem];
   170     if (myPluginInfoItem.toBeInstalled && myPluginInfoItem.licenseURL && (myPluginInfoItem.licenseURL != ""))
   171       this.mPluginLicenseArray.push(myPluginInfoItem.pid);
   172   }
   174   if (this.mPluginLicenseArray.length == 0) {
   175     // no plugins require licenses
   176     this.advancePage(null);
   177   } else {
   178     this.licenseAcceptCounter = 0;
   180     // add a nsIWebProgress listener to the license iframe.
   181     var docShell = document.getElementById("licenseIFrame").docShell;
   182     var iiReq = docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor);
   183     var webProgress = iiReq.getInterface(Components.interfaces.nsIWebProgress);
   184     webProgress.addProgressListener(gPluginInstaller.progressListener,
   185                                     Components.interfaces.nsIWebProgress.NOTIFY_ALL);
   187     this.showLicense();
   188   }
   189 }
   191 nsPluginInstallerWizard.prototype.enableNext = function (){
   192   // if only one plugin exists, don't enable the next button until
   193   // the license is accepted
   194   if (gPluginInstaller.pluginsToInstallNum > 1)
   195     gPluginInstaller.canAdvance(true);
   197   document.getElementById("licenseRadioGroup1").disabled = false;
   198   document.getElementById("licenseRadioGroup2").disabled = false;
   199 }
   201 const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
   202 nsPluginInstallerWizard.prototype.progressListener = {
   203   onStateChange : function(aWebProgress, aRequest, aStateFlags, aStatus)
   204   {
   205     if ((aStateFlags & nsIWebProgressListener.STATE_STOP) &&
   206        (aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK)) {
   207       // iframe loaded
   208       gPluginInstaller.enableNext();
   209     }
   210   },
   212   onProgressChange : function(aWebProgress, aRequest, aCurSelfProgress,
   213                               aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress)
   214   {},
   215   onStatusChange : function(aWebProgress, aRequest, aStatus, aMessage)
   216   {},
   218   QueryInterface : function(aIID)
   219   {
   220      if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
   221          aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
   222          aIID.equals(Components.interfaces.nsISupports))
   223        return this;
   224      throw Components.results.NS_NOINTERFACE;
   225    }
   226 }
   228 nsPluginInstallerWizard.prototype.showLicense = function (){
   229   var pluginInfo = this.mPluginInfoArray[this.mPluginLicenseArray[this.licenseAcceptCounter]];
   231   this.canAdvance(false);
   233   var loadFlags = Components.interfaces.nsIWebNavigation.LOAD_FLAGS_NONE;
   234   document.getElementById("licenseIFrame").webNavigation.loadURI(pluginInfo.licenseURL, loadFlags, null, null, null);
   236   document.getElementById("pluginLicenseLabel").firstChild.nodeValue = 
   237     this.getFormattedString("pluginLicenseAgreement.label", [pluginInfo.name]);
   239   document.getElementById("licenseRadioGroup1").disabled = true;
   240   document.getElementById("licenseRadioGroup2").disabled = true;
   241   document.getElementById("licenseRadioGroup").selectedIndex = 
   242     pluginInfo.licenseAccepted ? 0 : 1;
   243 }
   245 nsPluginInstallerWizard.prototype.showNextLicense = function (){
   246   var rv = true;
   248   if (this.mPluginLicenseArray.length > 0) {
   249     this.storeLicenseRadioGroup();
   251     this.licenseAcceptCounter++;
   253     if (this.licenseAcceptCounter < this.mPluginLicenseArray.length) {
   254       this.showLicense();
   256       rv = false;
   257       this.canRewind(true);
   258     }
   259   }
   261   return rv;
   262 }
   264 nsPluginInstallerWizard.prototype.showPreviousLicense = function (){
   265   this.storeLicenseRadioGroup();
   266   this.licenseAcceptCounter--;
   268   if (this.licenseAcceptCounter > 0)
   269     this.canRewind(true);
   270   else
   271     this.canRewind(false);
   273   this.showLicense();
   275   // don't allow to return from the license screens
   276   return false;
   277 }
   279 nsPluginInstallerWizard.prototype.storeLicenseRadioGroup = function (){
   280   var pluginInfo = this.mPluginInfoArray[this.mPluginLicenseArray[this.licenseAcceptCounter]];
   281   pluginInfo.licenseAccepted = !document.getElementById("licenseRadioGroup").selectedIndex;
   282 }
   284 nsPluginInstallerWizard.prototype.licenseRadioGroupChange = function(aAccepted) {
   285   // only if one plugin is to be installed should selection change the next button
   286   if (this.pluginsToInstallNum == 1)
   287     this.canAdvance(aAccepted);
   288 }
   290 nsPluginInstallerWizard.prototype.advancePage = function (aPageId){
   291   this.canAdvance(true);
   292   document.getElementById("plugin-installer-wizard").advance(aPageId);
   293 }
   295 nsPluginInstallerWizard.prototype.startPluginInstallation = function (){
   296   this.canAdvance(false);
   297   this.canRewind(false);
   299   var installerPlugins = [];
   300   var xpiPlugins = [];
   302   for (var pluginInfoItem in this.mPluginInfoArray){
   303     var pluginItem = this.mPluginInfoArray[pluginInfoItem];
   305     if (pluginItem.toBeInstalled && pluginItem.licenseAccepted) {
   306       if (pluginItem.InstallerLocation)
   307         installerPlugins.push(pluginItem);
   308       else if (pluginItem.XPILocation)
   309         xpiPlugins.push(pluginItem);
   310     }
   311   }
   313   if (installerPlugins.length > 0 || xpiPlugins.length > 0)
   314     PluginInstallService.startPluginInstallation(installerPlugins,
   315                                                  xpiPlugins);
   316   else
   317     this.advancePage(null);
   318 }
   320 /*
   321   0    starting download
   322   1    download finished
   323   2    starting installation
   324   3    finished installation
   325   4    all done
   326 */
   327 nsPluginInstallerWizard.prototype.pluginInstallationProgress = function (aPid, aProgress, aError) {
   329   var statMsg = null;
   330   var pluginInfo = gPluginInstaller.mPluginInfoArray[aPid];
   332   switch (aProgress) {
   334     case 0:
   335       statMsg = this.getFormattedString("pluginInstallation.download.start", [pluginInfo.name]);
   336       break;
   338     case 1:
   339       statMsg = this.getFormattedString("pluginInstallation.download.finish", [pluginInfo.name]);
   340       break;
   342     case 2:
   343       statMsg = this.getFormattedString("pluginInstallation.install.start", [pluginInfo.name]);
   344       var progressElm = document.getElementById("plugin_install_progress");
   345       progressElm.setAttribute("mode", "undetermined");
   346       break;
   348     case 3:
   349       if (aError) {
   350         statMsg = this.getFormattedString("pluginInstallation.install.error", [pluginInfo.name, aError]);
   351         pluginInfo.error = aError;
   352       } else {
   353         statMsg = this.getFormattedString("pluginInstallation.install.finish", [pluginInfo.name]);
   354         pluginInfo.error = null;
   355       }
   356       break;
   358     case 4:
   359       statMsg = this.getString("pluginInstallation.complete");
   360       break;
   361   }
   363   if (statMsg)
   364     document.getElementById("plugin_install_progress_message").value = statMsg;
   366   if (aProgress == 4) {
   367     this.advancePage(null);
   368   }
   369 }
   371 nsPluginInstallerWizard.prototype.pluginInstallationProgressMeter = function (aPid, aValue, aMaxValue){
   372   var progressElm = document.getElementById("plugin_install_progress");
   374   if (progressElm.getAttribute("mode") == "undetermined")
   375     progressElm.setAttribute("mode", "determined");
   377   progressElm.setAttribute("value", Math.ceil((aValue / aMaxValue) * 100) + "%")
   378 }
   380 nsPluginInstallerWizard.prototype.addPluginResultRow = function (aImgSrc, aName, aNameTooltip, aStatus, aStatusTooltip, aManualUrl){
   381   var myRows = document.getElementById("pluginResultList");
   383   var myRow = document.createElement("row");
   384   myRow.setAttribute("align", "center");
   386   // create the image
   387   var myImage = document.createElement("image");
   388   myImage.setAttribute("src", aImgSrc);
   389   myImage.setAttribute("height", "16px");
   390   myImage.setAttribute("width", "16px");
   391   myRow.appendChild(myImage)
   393   // create the labels
   394   var myLabel = document.createElement("label");
   395   myLabel.setAttribute("value", aName);
   396   if (aNameTooltip)
   397     myLabel.setAttribute("tooltiptext", aNameTooltip);
   398   myRow.appendChild(myLabel);
   400   if (aStatus) {
   401     myLabel = document.createElement("label");
   402     myLabel.setAttribute("value", aStatus);
   403     myRow.appendChild(myLabel);
   404   }
   406   // manual install
   407   if (aManualUrl) {
   408     var myButton = document.createElement("button");
   410     var manualInstallLabel = this.getString("pluginInstallationSummary.manualInstall.label");
   411     var manualInstallTooltip = this.getString("pluginInstallationSummary.manualInstall.tooltip");
   413     myButton.setAttribute("label", manualInstallLabel);
   414     myButton.setAttribute("tooltiptext", manualInstallTooltip);
   416     myRow.appendChild(myButton);
   418     // XXX: XUL sucks, need to add the listener after it got added into the document
   419     if (aManualUrl)
   420       myButton.addEventListener("command", function() { gPluginInstaller.loadURL(aManualUrl) }, false);
   421   }
   423   myRows.appendChild(myRow);
   424 }
   426 nsPluginInstallerWizard.prototype.showPluginResults = function (){
   427   var notInstalledList = "?action=missingplugins";
   428   var myRows = document.getElementById("pluginResultList");
   430   // clear children
   431   for (var run = myRows.childNodes.length; run--; run > 0)
   432     myRows.removeChild(myRows.childNodes.item(run));
   434   for (var pluginInfoItem in this.mPluginInfoArray){
   435     // [plugin image] [Plugin_Name Plugin_Version] [Success/Failed] [Manual Install (if Failed)]
   437     var myPluginItem = this.mPluginInfoArray[pluginInfoItem];
   439     if (myPluginItem.toBeInstalled) {
   440       var statusMsg;
   441       var statusTooltip;
   442       if (myPluginItem.error){
   443         statusMsg = this.getString("pluginInstallationSummary.failed");
   444         statusTooltip = myPluginItem.error;
   445         notInstalledList += "&mimetype=" + pluginInfoItem;
   446       } else if (!myPluginItem.licenseAccepted) {
   447         statusMsg = this.getString("pluginInstallationSummary.licenseNotAccepted");
   448       } else if (!myPluginItem.XPILocation && !myPluginItem.InstallerLocation) {
   449         statusMsg = this.getString("pluginInstallationSummary.notAvailable");
   450         notInstalledList += "&mimetype=" + pluginInfoItem;
   451       } else {
   452         this.mSuccessfullPluginInstallation++;
   453         statusMsg = this.getString("pluginInstallationSummary.success");
   455         // only check needsRestart if the plugin was successfully installed.
   456         if (myPluginItem.needsRestart)
   457           this.mNeedsRestart = true;
   458       }
   460       // manual url - either returned from the webservice or the pluginspage attribute
   461       var manualUrl;
   462       if ((myPluginItem.error || (!myPluginItem.XPILocation && !myPluginItem.InstallerLocation)) &&
   463           (myPluginItem.manualInstallationURL || this.mPluginRequests.get(myPluginItem.requestedMimetype).pluginsPage)){
   464         manualUrl = myPluginItem.manualInstallationURL ? myPluginItem.manualInstallationURL : this.mPluginRequests.get(myPluginItem.requestedMimetype).pluginsPage;
   465       }
   467       this.addPluginResultRow(
   468           myPluginItem.IconUrl, 
   469           myPluginItem.name + " " + (myPluginItem.version ? myPluginItem.version : ""),
   470           null,
   471           statusMsg, 
   472           statusTooltip,
   473           manualUrl);
   474     }
   475   }
   477   // handle plugins we couldn't find
   478   for (pluginInfoItem in this.mPluginNotFoundArray){
   479     var pluginRequest = this.mPluginNotFoundArray[pluginInfoItem];
   481     // if there is a pluginspage, show UI
   482     if (pluginRequest.pluginsPage) {
   483       this.addPluginResultRow(
   484           "",
   485           this.getFormattedString("pluginInstallation.unknownPlugin", [pluginInfoItem]),
   486           null,
   487           null,
   488           null,
   489           pluginRequest.pluginsPage);
   490     }
   492     notInstalledList += "&mimetype=" + pluginInfoItem;
   493   }
   495   // no plugins were found, so change the description of the final page.
   496   if (this.mPluginInfoArrayLength == 0) {
   497     var noPluginsFound = this.getString("pluginInstallation.noPluginsFound");
   498     document.getElementById("pluginSummaryDescription").setAttribute("value", noPluginsFound);
   499   } else if (this.mSuccessfullPluginInstallation == 0) {
   500     // plugins found, but none were installed.
   501     var noPluginsInstalled = this.getString("pluginInstallation.noPluginsInstalled");
   502     document.getElementById("pluginSummaryDescription").setAttribute("value", noPluginsInstalled);
   503   }
   505   document.getElementById("pluginSummaryRestartNeeded").hidden = !this.mNeedsRestart;
   507   var app = Components.classes["@mozilla.org/xre/app-info;1"]
   508                       .getService(Components.interfaces.nsIXULAppInfo);
   510   // set the get more info link to contain the mimetypes we couldn't install.
   511   notInstalledList +=
   512     "&appID=" + app.ID +
   513     "&appVersion=" + app.platformBuildID +
   514     "&clientOS=" + this.getOS() +
   515     "&chromeLocale=" + this.getChromeLocale() +
   516     "&appRelease=" + app.version;
   518   document.getElementById("moreInfoLink").addEventListener("click", function() { gPluginInstaller.loadURL("https://pfs.mozilla.org/plugins/" + notInstalledList) }, false);
   520   if (this.mNeedsRestart) {
   521     var cancel = document.getElementById("plugin-installer-wizard").getButton("cancel");
   522     cancel.label = this.getString("pluginInstallation.close.label");
   523     cancel.accessKey = this.getString("pluginInstallation.close.accesskey");
   524     var finish = document.getElementById("plugin-installer-wizard").getButton("finish");
   525     finish.label = this.getFormattedString("pluginInstallation.restart.label", [app.name]);
   526     finish.accessKey = this.getString("pluginInstallation.restart.accesskey");
   527     this.canCancel(true);
   528   }
   529   else {
   530     this.canCancel(false);
   531   }
   532   this.canAdvance(true);
   533   this.canRewind(false);
   534 }
   536 nsPluginInstallerWizard.prototype.loadURL = function (aUrl){
   537   // Check if the page where the plugin came from can load aUrl before
   538   // loading it, and do *not* allow loading URIs that would inherit our
   539   // principal.
   541   var pluginPagePrincipal =
   542     window.opener.content.document.nodePrincipal;
   544   const nsIScriptSecurityManager =
   545     Components.interfaces.nsIScriptSecurityManager;
   546   var secMan = Components.classes["@mozilla.org/scriptsecuritymanager;1"]
   547                          .getService(nsIScriptSecurityManager);
   549   secMan.checkLoadURIStrWithPrincipal(pluginPagePrincipal, aUrl,
   550     nsIScriptSecurityManager.DISALLOW_INHERIT_PRINCIPAL);
   552   window.opener.open(aUrl);
   553 }
   555 nsPluginInstallerWizard.prototype.getString = function (aName){
   556   return document.getElementById("pluginWizardString").getString(aName);
   557 }
   559 nsPluginInstallerWizard.prototype.getFormattedString = function (aName, aArray){
   560   return document.getElementById("pluginWizardString").getFormattedString(aName, aArray);
   561 }
   563 nsPluginInstallerWizard.prototype.getOS = function (){
   564   var httpService = Components.classes["@mozilla.org/network/protocol;1?name=http"]
   565                               .getService(Components.interfaces.nsIHttpProtocolHandler);
   566   return httpService.oscpu;
   567 }
   569 nsPluginInstallerWizard.prototype.getChromeLocale = function (){
   570   var chromeReg = Components.classes["@mozilla.org/chrome/chrome-registry;1"]
   571                             .getService(Components.interfaces.nsIXULChromeRegistry);
   572   return chromeReg.getSelectedLocale("global");
   573 }
   575 nsPluginInstallerWizard.prototype.getPrefBranch = function (){
   576   if (!this.prefBranch)
   577     this.prefBranch = Components.classes["@mozilla.org/preferences-service;1"]
   578                                 .getService(Components.interfaces.nsIPrefBranch);
   579   return this.prefBranch;
   580 }
   581 function nsPluginRequest(aPlugRequest){
   582   this.mimetype = encodeURI(aPlugRequest.mimetype);
   583   this.pluginsPage = aPlugRequest.pluginsPage;
   584 }
   586 function PluginInfo(aResult) {
   587   this.name = aResult.name;
   588   this.pid = aResult.pid;
   589   this.version = aResult.version;
   590   this.IconUrl = aResult.IconUrl;
   591   this.InstallerLocation = aResult.InstallerLocation;
   592   this.InstallerHash = aResult.InstallerHash;
   593   this.XPILocation = aResult.XPILocation;
   594   this.XPIHash = aResult.XPIHash;
   595   this.InstallerShowsUI = aResult.InstallerShowsUI;
   596   this.manualInstallationURL = aResult.manualInstallationURL;
   597   this.requestedMimetype = aResult.requestedMimetype;
   598   this.licenseURL = aResult.licenseURL;
   599   this.needsRestart = (aResult.needsRestart == "true");
   601   this.error = null;
   602   this.toBeInstalled = true;
   604   // no license provided, make it accepted
   605   this.licenseAccepted = this.licenseURL ? false : true;
   606 }
   608 var gPluginInstaller;
   610 function wizardInit(){
   611   gPluginInstaller = new nsPluginInstallerWizard();
   612   gPluginInstaller.canAdvance(false);
   613   gPluginInstaller.getPluginData();
   614 }
   616 function wizardFinish(){
   617   if (gPluginInstaller.mNeedsRestart) {
   618     // Notify all windows that an application quit has been requested.
   619     var os = Components.classes["@mozilla.org/observer-service;1"]
   620                        .getService(Components.interfaces.nsIObserverService);
   621     var cancelQuit = Components.classes["@mozilla.org/supports-PRBool;1"]
   622                                .createInstance(Components.interfaces.nsISupportsPRBool);
   623     os.notifyObservers(cancelQuit, "quit-application-requested", "restart");
   625     // Something aborted the quit process.
   626     if (!cancelQuit.data) {
   627       var nsIAppStartup = Components.interfaces.nsIAppStartup;
   628       var appStartup = Components.classes["@mozilla.org/toolkit/app-startup;1"]
   629                                  .getService(nsIAppStartup);
   630       appStartup.quit(nsIAppStartup.eAttemptQuit | nsIAppStartup.eRestart);
   631       return true;
   632     }
   633   }
   635   // don't refresh if no plugins were found or installed
   636   if ((gPluginInstaller.mSuccessfullPluginInstallation > 0) &&
   637       (gPluginInstaller.mPluginInfoArray.length != 0)) {
   639     // reload plugins so JS detection works immediately
   640     try {
   641       var ph = Components.classes["@mozilla.org/plugin/host;1"]
   642                          .getService(Components.interfaces.nsIPluginHost);
   643       ph.reloadPlugins(false);
   644     }
   645     catch (e) {
   646       // reloadPlugins throws an exception if there were no plugins to load
   647     }
   649     if (gPluginInstaller.mBrowser) {
   650       // notify listeners that a plugin is installed,
   651       // so that they can reset the UI and update the browser.
   652       var event = document.createEvent("Events");
   653       event.initEvent("NewPluginInstalled", true, true);
   654       gPluginInstaller.mBrowser.dispatchEvent(event);
   655     }
   656   }
   658   return true;
   659 }

mercurial