home *** CD-ROM | disk | FTP | other *** search
/ Clickx 47 / Clickx 47.iso / assets / software / Miro_Installer.exe / xulrunner / chrome / toolkit.jar / content / mozapps / plugins / pluginInstallerWizard.js < prev    next >
Encoding:
JavaScript  |  2005-07-14  |  22.0 KB  |  638 lines

  1. /* ***** BEGIN LICENSE BLOCK *****
  2.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  3.  *
  4.  * The contents of this file are subject to the Mozilla Public License Version
  5.  * 1.1 (the "License"); you may not use this file except in compliance with
  6.  * the License. You may obtain a copy of the License at
  7.  * http://www.mozilla.org/MPL/
  8.  *
  9.  * Software distributed under the License is distributed on an "AS IS" basis,
  10.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11.  * for the specific language governing rights and limitations under the
  12.  * License.
  13.  *
  14.  * The Original Code is Plugin Finder Service.
  15.  *
  16.  * The Initial Developer of the Original Code is
  17.  * IBM Corporation.
  18.  * Portions created by the IBM Corporation are Copyright (C) 2004
  19.  * IBM Corporation. All Rights Reserved.
  20.  *
  21.  * Contributor(s):
  22.  *   Doron Rosenberg <doronr@us.ibm.com>
  23.  *
  24.  * Alternatively, the contents of this file may be used under the terms of
  25.  * either the GNU General Public License Version 2 or later (the "GPL"), or
  26.  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27.  * in which case the provisions of the GPL or the LGPL are applicable instead
  28.  * of those above. If you wish to allow use of your version of this file only
  29.  * under the terms of either the GPL or the LGPL, and not to allow others to
  30.  * use your version of this file under the terms of the MPL, indicate your
  31.  * decision by deleting the provisions above and replace them with the notice
  32.  * and other provisions required by the GPL or the LGPL. If you do not delete
  33.  * the provisions above, a recipient may use your version of this file under
  34.  * the terms of any one of the MPL, the GPL or the LGPL.
  35.  *
  36.  * ***** END LICENSE BLOCK ***** */
  37.  
  38. function nsPluginInstallerWizard(){
  39.  
  40.   // create the request array
  41.   this.mPluginRequestArray = new Object();
  42.   // since the array is a hash, store the length
  43.   this.mPluginRequestArrayLength = 0;
  44.  
  45.   // create the plugin info array.
  46.   // a hash indexed by plugin id so we don't install 
  47.   // the same plugin more than once.
  48.   this.mPluginInfoArray = new Object();
  49.   this.mPluginInfoArrayLength = 0;
  50.  
  51.   // holds plugins we couldn't find
  52.   this.mPluginNotFoundArray = new Object();
  53.   this.mPluginNotFoundArrayLength = 0;
  54.  
  55.   // array holding pids of plugins that require a license
  56.   this.mPluginLicenseArray = new Array();
  57.  
  58.   this.mTab = null;
  59.   this.mSuccessfullPluginInstallation = 0;
  60.  
  61.   // arguments[0] is an array that contains two items:
  62.   //     an array of mimetypes that are missing
  63.   //     a reference to the tab that needs them, so we can reload it
  64.  
  65.   if ("arguments" in window) {
  66.     for (var item in window.arguments[0].plugins){
  67.       this.mPluginRequestArray[window.arguments[0].plugins[item].mimetype] =
  68.         new nsPluginRequest(window.arguments[0].plugins[item]);
  69.  
  70.       this.mPluginRequestArrayLength++;
  71.     }
  72.  
  73.     this.mTab = window.arguments[0].tab;
  74.   }
  75.  
  76.   this.WSPluginCounter = 0;
  77.   this.licenseAcceptCounter = 0;
  78.  
  79.   this.prefBranch = null;
  80. }
  81.  
  82. nsPluginInstallerWizard.prototype.getPluginData = function (){
  83.   // for each mPluginRequestArray item, call the datasource
  84.   this.WSPluginCounter = 0;
  85.  
  86.   // initiate the datasource call
  87.   var rdfUpdater = new nsRDFItemUpdater(this.getOS(), this.getChromeLocale());
  88.  
  89.   for (item in this.mPluginRequestArray) {
  90.     rdfUpdater.checkForPlugin(this.mPluginRequestArray[item]);
  91.   }
  92. }
  93.  
  94. // aPluginInfo is null if the datasource call failed, and pid is -1 if
  95. // no matching plugin was found.
  96. nsPluginInstallerWizard.prototype.pluginInfoReceived = function (aPluginInfo){
  97.   this.WSPluginCounter++;
  98.  
  99.   if (aPluginInfo && (aPluginInfo.pid != -1) ) {
  100.     // hash by id
  101.     this.mPluginInfoArray[aPluginInfo.pid] = new PluginInfo(aPluginInfo);
  102.     this.mPluginInfoArrayLength++;
  103.   } else {
  104.     this.mPluginNotFoundArray[aPluginInfo.requestedMimetype] = new PluginInfo(aPluginInfo);
  105.     this.mPluginNotFoundArrayLength++;
  106.   }
  107.  
  108.   var progressMeter = document.getElementById("ws_request_progress");
  109.  
  110.   if (progressMeter.getAttribute("mode") == "undetermined")
  111.     progressMeter.setAttribute("mode", "determined");
  112.  
  113.   progressMeter.setAttribute("value",
  114.       ((this.WSPluginCounter / this.mPluginRequestArrayLength) * 100) + "%");
  115.  
  116.   if (this.WSPluginCounter == this.mPluginRequestArrayLength) {
  117.     // check if no plugins were found
  118.     if (this.mPluginInfoArrayLength == 0) {
  119.       this.advancePage("lastpage", true, false, false);
  120.     } else {
  121.       // we want to allow user to cancel
  122.       this.advancePage(null, true, false, true);
  123.     }
  124.   } else {
  125.     // process more.
  126.   }
  127. }
  128.  
  129. nsPluginInstallerWizard.prototype.showPluginList = function (){
  130.   var myPluginList = document.getElementById("pluginList");
  131.   var hasPluginWithInstallerUI = false;
  132.  
  133.   // clear children
  134.   for (var run = myPluginList.childNodes.length; run > 0; run--)
  135.     myPluginList.removeChild(myPluginList.childNodes.item(run));
  136.  
  137.   for (pluginInfoItem in this.mPluginInfoArray){
  138.     // [plugin image] [Plugin_Name Plugin_Version]
  139.  
  140.     var pluginInfo = this.mPluginInfoArray[pluginInfoItem];
  141.  
  142.     // create the checkbox
  143.     var myCheckbox = document.createElement("checkbox");
  144.     myCheckbox.setAttribute("checked", "true");
  145.     myCheckbox.setAttribute("oncommand", "gPluginInstaller.toggleInstallPlugin('" + pluginInfo.pid + "', this)");
  146.     // XXXlocalize (nit)
  147.     myCheckbox.setAttribute("label", pluginInfo.name + " " + (pluginInfo.version ? pluginInfo.version : ""));
  148.     myCheckbox.setAttribute("src", pluginInfo.IconUrl);
  149.  
  150.     myPluginList.appendChild(myCheckbox);
  151.  
  152.     if (pluginInfo.InstallerShowsUI == "true")
  153.       hasPluginWithInstallerUI = true;
  154.   }
  155.  
  156.   if (hasPluginWithInstallerUI)
  157.     document.getElementById("installerUI").hidden = false;
  158.  
  159.   this.canAdvance(true);
  160.   this.canRewind(false);
  161. }
  162.  
  163. nsPluginInstallerWizard.prototype.toggleInstallPlugin = function (aPid, aCheckbox) {
  164.   this.mPluginInfoArray[aPid].toBeInstalled = aCheckbox.checked;
  165.  
  166.   // if no plugins are checked, don't allow to advance  
  167.   var pluginsToInstallNum = 0;
  168.   for (pluginInfoItem in this.mPluginInfoArray){
  169.     if (this.mPluginInfoArray[pluginInfoItem].toBeInstalled)
  170.       pluginsToInstallNum++;
  171.   }
  172.  
  173.   if (pluginsToInstallNum > 0)
  174.     this.canAdvance(true);
  175.   else
  176.     this.canAdvance(false);
  177. }
  178.  
  179. nsPluginInstallerWizard.prototype.canAdvance = function (aBool){
  180.   document.getElementById("plugin-installer-wizard").canAdvance = aBool;
  181. }
  182.  
  183. nsPluginInstallerWizard.prototype.canRewind = function (aBool){
  184.   document.getElementById("plugin-installer-wizard").canRewind = aBool;
  185. }
  186.  
  187. nsPluginInstallerWizard.prototype.canCancel = function (aBool){
  188.   document.documentElement.getButton("cancel").disabled = !aBool;
  189. }
  190.  
  191. nsPluginInstallerWizard.prototype.showLicenses = function (){
  192.   this.canAdvance(false);
  193.   this.canRewind(false);
  194.  
  195.   // only add if a license is provided and the plugin was selected to
  196.   // be installed
  197.   for (pluginInfoItem in this.mPluginInfoArray){
  198.     var myPluginInfoItem = this.mPluginInfoArray[pluginInfoItem];
  199.     if (myPluginInfoItem.toBeInstalled && myPluginInfoItem.licenseURL && (myPluginInfoItem.licenseURL != ""))
  200.       this.mPluginLicenseArray.push(myPluginInfoItem.pid);
  201.   }
  202.  
  203.   if (this.mPluginLicenseArray.length == 0) {
  204.     // no plugins require licenses
  205.     this.advancePage(null, true, false, false);
  206.   } else {
  207.     this.licenseAcceptCounter = 0;
  208.  
  209.     // add a nsIWebProgress listener to the license iframe.
  210.     var docShell = document.getElementById("licenseIFrame").docShell;
  211.     var iiReq = docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor);
  212.     var webProgress = iiReq.getInterface(Components.interfaces.nsIWebProgress);
  213.     webProgress.addProgressListener(gPluginInstaller.progressListener,
  214.                                     Components.interfaces.nsIWebProgress.NOTIFY_ALL);
  215.  
  216.     this.showLicense();
  217.   }
  218. }
  219.  
  220. nsPluginInstallerWizard.prototype.enableNext = function (){
  221.   gPluginInstaller.canAdvance(true);
  222.   document.getElementById("licenseRadioGroup1").disabled = false;
  223.   document.getElementById("licenseRadioGroup2").disabled = false;
  224. }
  225.  
  226. const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
  227. nsPluginInstallerWizard.prototype.progressListener = {
  228.   onStateChange : function(aWebProgress, aRequest, aStateFlags, aStatus)
  229.   {
  230.     if ((aStateFlags & nsIWebProgressListener.STATE_STOP) &&
  231.        (aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK)) {
  232.       // iframe loaded
  233.       gPluginInstaller.enableNext();
  234.     }
  235.   },
  236.  
  237.   onProgressChange : function(aWebProgress, aRequest, aCurSelfProgress,
  238.                               aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress)
  239.   {},
  240.   onStatusChange : function(aWebProgress, aRequest, aStatus, aMessage)
  241.   {},
  242.  
  243.   QueryInterface : function(aIID)
  244.   {
  245.      if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
  246.          aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
  247.          aIID.equals(Components.interfaces.nsISupports))
  248.        return this;
  249.      throw Components.results.NS_NOINTERFACE;
  250.    }
  251. }
  252.  
  253. nsPluginInstallerWizard.prototype.showLicense = function (){
  254.   var pluginInfo = this.mPluginInfoArray[this.mPluginLicenseArray[this.licenseAcceptCounter]];
  255.  
  256.   this.canAdvance(false);
  257.  
  258.   loadFlags = Components.interfaces.nsIWebNavigation.LOAD_FLAGS_NONE;
  259.   document.getElementById("licenseIFrame").webNavigation.loadURI(pluginInfo.licenseURL, loadFlags, null, null, null);
  260.  
  261.   document.getElementById("pluginLicenseLabel").firstChild.nodeValue = 
  262.     this.getFormattedString("pluginLicenseAgreement.label", [pluginInfo.name]);
  263.  
  264.   document.getElementById("licenseRadioGroup1").disabled = true;
  265.   document.getElementById("licenseRadioGroup2").disabled = true;
  266.   document.getElementById("licenseRadioGroup").selectedIndex = 
  267.     pluginInfo.licenseAccepted ? 0 : 1;
  268. }
  269.  
  270. nsPluginInstallerWizard.prototype.showNextLicense = function (){
  271.   var rv = true;
  272.  
  273.   if (this.mPluginLicenseArray.length > 0) {
  274.     this.storeLicenseRadioGroup();
  275.  
  276.     this.licenseAcceptCounter++;
  277.  
  278.     if (this.licenseAcceptCounter < this.mPluginLicenseArray.length) {
  279.       this.showLicense();
  280.  
  281.       rv = false;
  282.       this.canRewind(true);
  283.     }
  284.   }
  285.  
  286.   return rv;
  287. }
  288.  
  289. nsPluginInstallerWizard.prototype.showPreviousLicense = function (){
  290.   this.storeLicenseRadioGroup();
  291.   this.licenseAcceptCounter--;
  292.  
  293.   if (this.licenseAcceptCounter > 0)
  294.     this.canRewind(true);
  295.   else
  296.     this.canRewind(false);
  297.  
  298.   this.showLicense();
  299.   
  300.   // don't allow to return from the license screens
  301.   return false;
  302. }
  303.  
  304. nsPluginInstallerWizard.prototype.storeLicenseRadioGroup = function (){
  305.   var pluginInfo = this.mPluginInfoArray[this.mPluginLicenseArray[this.licenseAcceptCounter]];
  306.   pluginInfo.licenseAccepted = !document.getElementById("licenseRadioGroup").selectedIndex;
  307. }
  308.  
  309. nsPluginInstallerWizard.prototype.advancePage = function (aPageId, aCanAdvance, aCanRewind, aCanCancel){
  310.   this.canAdvance(true);
  311.   document.getElementById("plugin-installer-wizard").advance(aPageId);
  312.  
  313.   this.canAdvance(aCanAdvance);
  314.   this.canRewind(aCanRewind);
  315.   this.canCancel(aCanCancel);
  316. }
  317.  
  318. nsPluginInstallerWizard.prototype.startPluginInstallation = function (){
  319.   this.canAdvance(false);
  320.   this.canRewind(false);
  321.  
  322.   // since the user can choose what plugins to install, we need to store
  323.   // which ones were choosen, as nsIXPInstallManager returns an index and not the
  324.   // mimetype.  So store the pids.
  325.  
  326.   var pluginURLArray = new Array();
  327.   var pluginPidArray = new Array();
  328.  
  329.   for (pluginInfoItem in this.mPluginInfoArray){
  330.     var pluginItem = this.mPluginInfoArray[pluginInfoItem];
  331.  
  332.     // only push to the array if it has an XPILocation, else nsIXPInstallManager
  333.     // will complain.
  334.     if (pluginItem.toBeInstalled && pluginItem.XPILocation && pluginItem.licenseAccepted) {
  335.       pluginURLArray.push(pluginItem.XPILocation);
  336.       pluginPidArray.push(pluginItem.pid);
  337.     }
  338.   }
  339.  
  340.   if (pluginURLArray.length > 0)
  341.     PluginInstallService.startPluginInsallation(pluginURLArray, pluginPidArray);
  342.   else
  343.     this.advancePage(null, true, false, false);
  344. }
  345.  
  346. /*
  347.   0    starting download
  348.   1    download finished
  349.   2    starting installation
  350.   3    finished installation
  351.   4    all done
  352. */
  353. nsPluginInstallerWizard.prototype.pluginInstallationProgress = function (aPid, aProgress, aError) {
  354.  
  355.   var statMsg = null;
  356.   var pluginInfo = gPluginInstaller.mPluginInfoArray[aPid];
  357.  
  358.   switch (aProgress) {
  359.  
  360.     case 0:
  361.       statMsg = this.getFormattedString("pluginInstallation.download.start", [pluginInfo.name]);
  362.       break;
  363.  
  364.     case 1:
  365.       statMsg = this.getFormattedString("pluginInstallation.download.finish", [pluginInfo.name]);
  366.       break;
  367.  
  368.     case 2:
  369.       statMsg = this.getFormattedString("pluginInstallation.install.start", [pluginInfo.name]);
  370.       break;
  371.  
  372.     case 3:
  373.       if (aError) {
  374.         statMsg = this.getFormattedString("pluginInstallation.install.error", [pluginInfo.name, aError]);
  375.         pluginInfo.error = aError;
  376.       } else {
  377.         statMsg = this.getFormattedString("pluginInstallation.install.finish", [pluginInfo.name]);
  378.         pluginInfo.error = null;
  379.       }
  380.       break;
  381.  
  382.     case 4:
  383.       statMsg = this.getString("pluginInstallation.complete");
  384.       break;
  385.   }
  386.  
  387.   if (statMsg)
  388.     document.getElementById("plugin_install_progress_message").value = statMsg;
  389.  
  390.   if (aProgress == 4) {
  391.     this.advancePage(null, true, false, false);
  392.   }
  393. }
  394.  
  395. nsPluginInstallerWizard.prototype.pluginInstallationProgressMeter = function (aPid, aValue, aMaxValue){
  396.   var progressElm = document.getElementById("plugin_install_progress");
  397.  
  398.   if (progressElm.getAttribute("mode") == "undetermined")
  399.     progressElm.setAttribute("mode", "determined");
  400.   
  401.   progressElm.setAttribute("value", Math.ceil((aValue / aMaxValue) * 100) + "%")
  402. }
  403.  
  404. nsPluginInstallerWizard.prototype.addPluginResultRow = function (aImgSrc, aName, aNameTooltip, aStatus, aStatusTooltip, aManualUrl){
  405.   var myRows = document.getElementById("pluginResultList");
  406.  
  407.   var myRow = document.createElement("row");
  408.   myRow.setAttribute("align", "center");
  409.  
  410.   // create the image
  411.   var myImage = document.createElement("image");
  412.   myImage.setAttribute("src", aImgSrc);
  413.   myImage.setAttribute("height", "16px");
  414.   myImage.setAttribute("width", "16px");
  415.   myRow.appendChild(myImage)
  416.  
  417.   // create the labels
  418.   var myLabel = document.createElement("label");
  419.   myLabel.setAttribute("value", aName);
  420.   if (aNameTooltip)
  421.     myLabel.setAttribute("tooltiptext", aNameTooltip);
  422.   myRow.appendChild(myLabel);
  423.  
  424.   if (aStatus) {
  425.     myLabel = document.createElement("label");
  426.     myLabel.setAttribute("value", aStatus);
  427.     myRow.appendChild(myLabel);
  428.   }
  429.  
  430.   // manual install
  431.   if (aManualUrl) {
  432.     var myButton = document.createElement("button");
  433.  
  434.     var manualInstallLabel = this.getString("pluginInstallationSummary.manualInstall.label");
  435.     var manualInstallTooltip = this.getString("pluginInstallationSummary.manualInstall.tooltip");
  436.  
  437.     myButton.setAttribute("label", manualInstallLabel);
  438.     myButton.setAttribute("tooltiptext", manualInstallTooltip);
  439.  
  440.     myRow.appendChild(myButton);
  441.  
  442.     // XXX: XUL sucks, need to add the listener after it got added into the document
  443.     if (aManualUrl)
  444.       myButton.addEventListener("command", function() { gPluginInstaller.loadURL(aManualUrl) }, false);
  445.   }
  446.  
  447.   myRows.appendChild(myRow);
  448. }
  449.  
  450. nsPluginInstallerWizard.prototype.showPluginResults = function (){
  451.   var notInstalledList = "?action=missingplugins";
  452.   var needsRestart = false;
  453.   var myRows = document.getElementById("pluginResultList");
  454.  
  455.   // clear children
  456.   for (var run = myRows.childNodes.length; run--; run > 0)
  457.     myRows.removeChild(myRows.childNodes.item(run));
  458.  
  459.   for (pluginInfoItem in this.mPluginInfoArray){
  460.     // [plugin image] [Plugin_Name Plugin_Version] [Success/Failed] [Manual Install (if Failed)]
  461.  
  462.     var myPluginItem = this.mPluginInfoArray[pluginInfoItem];
  463.  
  464.     if (myPluginItem.toBeInstalled) {
  465.       var statusMsg;
  466.       var statusTooltip;
  467.       if (myPluginItem.error){
  468.         statusMsg = this.getString("pluginInstallationSummary.failed");
  469.         statusTooltip = myPluginItem.error;
  470.         notInstalledList += "&mimetype=" + pluginInfoItem;
  471.       } else if (!myPluginItem.licenseAccepted) {
  472.         statusMsg = this.getString("pluginInstallationSummary.licenseNotAccepted");
  473.       } else if (!myPluginItem.XPILocation) {
  474.         statusMsg = this.getString("pluginInstallationSummary.notAvailable");
  475.         notInstalledList += "&mimetype=" + pluginInfoItem;
  476.       } else {
  477.         this.mSuccessfullPluginInstallation++;
  478.         statusMsg = this.getString("pluginInstallationSummary.success");
  479.  
  480.         // only check needsRestart if the plugin was successfully installed.
  481.         if (myPluginItem.needsRestart)
  482.           needsRestart = true;
  483.       }
  484.  
  485.       // manual url - either returned from the webservice or the pluginspage attribute
  486.       var manualUrl;
  487.       if ((myPluginItem.error || !myPluginItem.XPILocation) && (myPluginItem.manualInstallationURL || this.mPluginRequestArray[myPluginItem.requestedMimetype].pluginsPage)){
  488.         manualUrl = myPluginItem.manualInstallationURL ? myPluginItem.manualInstallationURL : this.mPluginRequestArray[myPluginItem.requestedMimetype].pluginsPage;
  489.       }
  490.  
  491.       this.addPluginResultRow(
  492.           myPluginItem.IconUrl, 
  493.           myPluginItem.name + " " + (myPluginItem.version ? myPluginItem.version : ""),
  494.           null,
  495.           statusMsg, 
  496.           statusTooltip,
  497.           manualUrl);
  498.     }
  499.   }
  500.  
  501.   // handle plugins we couldn't find
  502.   for (pluginInfoItem in this.mPluginNotFoundArray){
  503.     var pluginRequest = this.mPluginRequestArray[pluginInfoItem];
  504.  
  505.     // if there is a pluginspage, show UI
  506.     if (pluginRequest && pluginRequest.pluginsPage) {
  507.       this.addPluginResultRow(
  508.           "",
  509.           this.getString("pluginInstallation.unknownPlugin"),
  510.           pluginInfoItem,
  511.           null,
  512.           null,
  513.           this.mPluginRequestArray[pluginInfoItem].pluginsPage);
  514.     }
  515.  
  516.     notInstalledList += "&mimetype=" + pluginInfoItem;
  517.   }
  518.  
  519.   // no plugins were found, so change the description of the final page.
  520.   if (this.mPluginInfoArrayLength == 0) {
  521.     var noPluginsFound = this.getString("pluginInstallation.noPluginsFound");
  522.     document.getElementById("pluginSummaryDescription").setAttribute("value", noPluginsFound);
  523.   } else if (this.mSuccessfullPluginInstallation == 0) {
  524.     // plugins found, but none were installed.
  525.     var noPluginsInstalled = this.getString("pluginInstallation.noPluginsInstalled");
  526.     document.getElementById("pluginSummaryDescription").setAttribute("value", noPluginsInstalled);
  527.   }
  528.  
  529.   document.getElementById("pluginSummaryRestartNeeded").hidden = !needsRestart;
  530.  
  531.   var app = Components.classes["@mozilla.org/xre/app-info;1"]
  532.                       .getService(Components.interfaces.nsIXULAppInfo);
  533.  
  534.   // set the get more info link to contain the mimetypes we couldn't install.
  535.   notInstalledList +=
  536.     "&appID=" + app.ID +
  537.     "&appVersion=" + app.platformBuildID +
  538.     "&clientOS=" + this.getOS() +
  539.     "&chromeLocale=" + this.getChromeLocale();
  540.  
  541.   document.getElementById("moreInfoLink").addEventListener("click", function() { gPluginInstaller.loadURL("https://pfs.mozilla.org/plugins/" + notInstalledList) }, false);
  542.  
  543.   this.canAdvance(true);
  544.   this.canRewind(false);
  545.   this.canCancel(false);
  546. }
  547.  
  548. nsPluginInstallerWizard.prototype.loadURL = function (aUrl){
  549.   // Check if the page where the plugin came from can load aUrl before
  550.   // loading it, and do *not* allow loading javascript: or data: URIs.
  551.   var pluginPage = window.opener.content.location.href;
  552.  
  553.   const nsIScriptSecurityManager =
  554.     Components.interfaces.nsIScriptSecurityManager;
  555.   var secMan =
  556.     Components.classes["@mozilla.org/scriptsecuritymanager;1"]
  557.     .getService(nsIScriptSecurityManager);
  558.  
  559.   secMan.checkLoadURIStr(pluginPage, aUrl,
  560.                          nsIScriptSecurityManager.DISALLOW_SCRIPT_OR_DATA);
  561.  
  562.   window.opener.open(aUrl);
  563. }
  564.  
  565. nsPluginInstallerWizard.prototype.getString = function (aName){
  566.   return document.getElementById("pluginWizardString").getString(aName);
  567. }
  568.  
  569. nsPluginInstallerWizard.prototype.getFormattedString = function (aName, aArray){
  570.   return document.getElementById("pluginWizardString").getFormattedString(aName, aArray);
  571. }
  572.  
  573. nsPluginInstallerWizard.prototype.getOS = function (){
  574.   var httpService = Components.classes["@mozilla.org/network/protocol;1?name=http"]
  575.                               .getService(Components.interfaces.nsIHttpProtocolHandler);
  576.   return httpService.oscpu;
  577. }
  578.  
  579. nsPluginInstallerWizard.prototype.getChromeLocale = function (){
  580.   var chromeReg = Components.classes["@mozilla.org/chrome/chrome-registry;1"]
  581.                             .getService(Components.interfaces.nsIXULChromeRegistry);
  582.   return chromeReg.getSelectedLocale("global");
  583. }
  584.  
  585. nsPluginInstallerWizard.prototype.getPrefBranch = function (){
  586.   if (!this.prefBranch)
  587.     this.prefBranch = Components.classes["@mozilla.org/preferences-service;1"]
  588.                                 .getService(Components.interfaces.nsIPrefBranch);
  589.   return this.prefBranch;
  590. }
  591. function nsPluginRequest(aPlugRequest){
  592.   this.mimetype = encodeURI(aPlugRequest.mimetype);
  593.   this.pluginsPage = aPlugRequest.pluginsPage;
  594. }
  595.  
  596. function PluginInfo(aResult) {
  597.   this.name = aResult.name;
  598.   this.pid = aResult.pid;
  599.   this.version = aResult.version;
  600.   this.IconUrl = aResult.IconUrl;
  601.   this.XPILocation = aResult.XPILocation;
  602.   this.InstallerShowsUI = aResult.InstallerShowsUI;
  603.   this.manualInstallationURL = aResult.manualInstallationURL;
  604.   this.requestedMimetype = aResult.requestedMimetype;
  605.   this.licenseURL = aResult.licenseURL;
  606.   this.needsRestart = (aResult.needsRestart == "true");
  607.  
  608.   this.error = null;
  609.   this.toBeInstalled = true;
  610.  
  611.   // no license provided, make it accepted
  612.   this.licenseAccepted = this.licenseURL ? false : true;
  613. }
  614.  
  615. var gPluginInstaller;
  616.  
  617. function wizardInit(){
  618.   gPluginInstaller = new nsPluginInstallerWizard();
  619.   gPluginInstaller.canAdvance(false);
  620.   gPluginInstaller.getPluginData();
  621. }
  622.  
  623. function wizardFinish(){
  624.   // don't refresh if no plugins were found or installed
  625.   if ((gPluginInstaller.mSuccessfullPluginInstallation > 0) &&
  626.       (gPluginInstaller.mPluginInfoArray.length != 0) &&
  627.       gPluginInstaller.mTab) {
  628.     // clear the tab's plugin list only if we installed at least one plugin
  629.     gPluginInstaller.mTab.missingPlugins = null;
  630.     // reset UI
  631.     window.opener.getBrowser().hideMessage(window.opener.getBrowser().selectedBrowser, "top");
  632.     // reload the browser to make the new plugin show
  633.     window.opener.getBrowser().reloadTab(gPluginInstaller.mTab);
  634.   }
  635.  
  636.   return true;
  637. }
  638.