64
64
// how many plugins are to be installed
65
65
this.pluginsToInstallNum = 0;
68
67
this.mBrowser = null;
69
68
this.mSuccessfullPluginInstallation = 0;
69
this.mNeedsRestart = false;
71
71
this.mPluginPidArray = new Object();
72
72
// arguments[0] is an array that contains two items:
73
73
// an array of mimetypes that are missing
74
// a reference to the tab that needs them, so we can reload it
74
// a reference to the browser that needs them,
75
// so we can notify which browser can be reloaded.
76
77
if ("arguments" in window) {
77
78
for (var item in window.arguments[0].plugins){
100
100
// initiate the datasource call
101
101
var rdfUpdater = new nsRDFItemUpdater(this.getOS(), this.getChromeLocale());
103
for (item in this.mPluginRequestArray) {
103
for (var item in this.mPluginRequestArray) {
104
104
rdfUpdater.checkForPlugin(this.mPluginRequestArray[item]);
108
108
// aPluginInfo is null if the datasource call failed, and pid is -1 if
109
109
// no matching plugin was found.
110
nsPluginInstallerWizard.prototype.pluginInfoReceived = function (aPluginInfos){
110
nsPluginInstallerWizard.prototype.pluginInfoReceived = function (aPluginRequestItem, aPluginInfos){
111
111
this.WSPluginCounter++;
113
113
if (aPluginInfos ) {
149
149
if (this.WSPluginCounter == this.mPluginRequestArrayLength) {
150
150
// check if no plugins were found
151
if (this.mPluginInfoArrayLength == 0 && this.mPluginInfoAptArrayLength == 0) {
152
this.advancePage("lastpage", true, false, false);
151
if (this.mPluginInfoArrayLength == 0) {
152
this.advancePage("lastpage");
154
154
// we want to allow user to cancel
155
this.advancePage(null, true, false, true);
155
this.advancePage(null);
162
nsPluginInstallerWizard.prototype.createPluginSetGroupBox = function () {
162
nsPluginInstallerWizard.prototype.createPluginSetGroupBox = function (mimetype) {
164
164
var stringBundle = document.getElementById("ubufoxPluginWizardString");
165
165
var gbox = document.createElement("vbox");
193
193
var groupBox = null;
194
194
var lastSibling = null;
196
for (mimetype in this.mPluginInfoArray){
196
for (var mimetype in this.mPluginInfoArray){
197
197
// [plugin image] [Plugin_Name Plugin_Version]
198
198
var pluginInfoSet = this.mPluginInfoArray[mimetype];
199
199
var firstPluginSet = (groupBox == null);
200
groupBox = this.createPluginSetGroupBox(document, mimetype, pluginInfoSet);
200
groupBox = this.createPluginSetGroupBox(mimetype);
202
202
if(firstPluginSet) {
203
203
this.mPluginPlaceHolder = document.getElementById("pluginselection-placeholder");
290
291
var mime = selectedItem._ubufoxPluginInfoMimeType;
291
292
this.mMimeTypePluginSelections[mime] = selectedItem._ubufoxPluginInfo.pid;
294
for (mime in this.mMimeTypePluginSelections) {
294
this.pluginsToInstallNum = 0;
295
for (var mime in this.mMimeTypePluginSelections) {
295
296
if(this.mMimeTypePluginSelections[mime] && this.mMimeTypePluginSelections[mime] != "-1")
297
this.pluginsToInstallNum++;
299
300
// if no plugins are checked, don't allow to advance
301
if (this.pluginsToInstallNum > 0)
301
302
this.canAdvance(true);
303
304
this.canAdvance(false);
447
448
this.canAdvance(aAccepted);
450
nsPluginInstallerWizard.prototype.advancePage = function (aPageId, aCanAdvance, aCanRewind, aCanCancel){
451
nsPluginInstallerWizard.prototype.advancePage = function (aPageId){
451
452
this.canAdvance(true);
452
453
document.getElementById("plugin-installer-wizard").advance(aPageId);
454
this.canAdvance(aCanAdvance);
455
this.canRewind(aCanRewind);
456
this.canCancel(aCanCancel);
459
456
nsPluginInstallerWizard.prototype.startPluginInstallation = function (){
460
457
this.canAdvance(false);
461
458
this.canRewind(false);
463
// since the user can choose what plugins to install, we need to store
464
// which ones were choosen, as nsIXPInstallManager returns an index and not the
465
// mimetype. So store the pids.
467
// for ubutfox we deal with multiple cases: first case is XPIInstall, which will
460
// for ubufox we deal with multiple cases: first case is XPIInstall, which will
468
461
// run the "normal" XPIInstall process; second case is XPIInstall url contains
469
462
// and apt: protocol url ... this will run apt protocol handler
470
var pluginURLArray = new Array();
471
var pluginHashArray = new Array();
472
var pluginPidArray = new Array();
473
this.mAptPluginURLArray = new Array();
474
this.mAptPluginPidArray = new Array();
476
for (mime in this.mMimeTypePluginSelections) {
477
var pluginPid = this.mMimeTypePluginSelections[mime];
478
var pluginItem = this.mPluginPidArray[pluginPid];
480
// only push to the array if it has an XPILocation, else nsIXPInstallManager
482
if (pluginItem && pluginItem.XPILocation && pluginItem.XPILocation.indexOf("apt:") != 0 && pluginItem.licenseAccepted) {
483
pluginURLArray.push(pluginItem.XPILocation);
484
pluginHashArray.push(pluginItem.XPIHash);
485
pluginPidArray.push(pluginItem.pid);
486
} else if (pluginItem && pluginItem.XPILocation && pluginItem.XPILocation.indexOf("apt:") == 0) {
487
this.mAptPluginURLArray.push(pluginItem.XPILocation);
488
this.mAptPluginPidArray.push(pluginPid);
490
window.alert("Unhandled mime install flavour (supported: vendor, apt)");
463
var installerPlugins = [];
465
this.aptPlugins = [];
467
for (var mime in this.mMimeTypePluginSelections) {
468
var pluginItem = this.mPluginPidArray[this.mMimeTypePluginSelections[mime]];
470
if (pluginItem && pluginItem.licenseAccepted) {
471
if (pluginItem.InstallerLocation)
472
installerPlugins.push(pluginItem);
473
else if (pluginItem.XPILocation && pluginItem.XPILocation.indexOf("apt:") != 0)
474
xpiPlugins.push(pluginItem);
475
else if (pluginItem.XPILocation && pluginItem.XPILocation.indexOf("apt:") == 0)
476
this.aptPlugins.push(pluginItem);
478
window.alert("Unhandled mime install flavour (supported: vendor, apt)");
495
if (pluginURLArray.length > 0)
496
PluginXPIInstallService.startPluginInstallation(pluginURLArray,
499
else if (this.mAptPluginURLArray.length > 0)
500
PluginAPTInstallService.startPluginInstallation(this.mAptPluginURLArray,
501
this.mAptPluginPidArray);
484
if (installerPlugins.length > 0 || xpiPlugins.length > 0)
485
PluginXPIInstallService.startPluginInstallation(installerPlugins,
487
else if (this.aptPlugins.length > 0)
488
PluginAPTInstallService.startPluginInstallation(this.aptPlugins);
503
this.advancePage(null, true, false, false);
490
this.advancePage(null);
630
618
var notInstalledList = "?action=missingplugins";
631
619
var myRows = document.getElementById("pluginResultList");
633
this.mNeedsRestart = false;
635
621
// clear children
636
622
for (var run = myRows.childNodes.length; run--; run > 0)
637
623
myRows.removeChild(myRows.childNodes.item(run));
639
for (mimetype in this.mMimeTypePluginSelections) {
640
var pid = this.mMimeTypePluginSelections[mimetype];
641
var pluginInfoItem = this.mPluginPidArray[pid];
625
for (var mimetype in this.mMimeTypePluginSelections) {
626
var pluginInfoItem = this.mPluginPidArray[this.mMimeTypePluginSelections[mimetype]];
642
627
// [plugin image] [Plugin_Name Plugin_Version] [Success/Failed] [Manual Install (if Failed)]
644
629
var myPluginItem = pluginInfoItem; //this.mPluginInfoArray[pluginInfoItem];
661
646
// only check needsRestart if the plugin was successfully installed.
662
647
if (myPluginItem.needsRestart)
663
this.mNeedsRestart = false;
648
this.mNeedsRestart = true;
666
651
// manual url - either returned from the webservice or the pluginspage attribute
668
if ((myPluginItem.error || !myPluginItem.XPILocation) && (myPluginItem.manualInstallationURL || this.mPluginRequestArray[myPluginItem.requestedMimetype].pluginsPage)){
653
if ((myPluginItem.error || (!myPluginItem.XPILocation && !myPluginItem.InstallerLocation)) && (myPluginItem.manualInstallationURL || this.mPluginRequestArray[myPluginItem.requestedMimetype].pluginsPage)){
669
654
manualUrl = myPluginItem.manualInstallationURL ? myPluginItem.manualInstallationURL : this.mPluginRequestArray[myPluginItem.requestedMimetype].pluginsPage;
716
701
"&appID=" + app.ID +
717
702
"&appVersion=" + app.platformBuildID +
718
703
"&clientOS=" + this.getOS() +
719
"&chromeLocale=" + this.getChromeLocale();
704
"&chromeLocale=" + this.getChromeLocale() +
705
"&appRelease=" + app.version;
721
707
document.getElementById("moreInfoLink").addEventListener("click", function() { gPluginInstaller.loadURL("https://pfs.mozilla.org/plugins/" + notInstalledList) }, false);
709
if (this.mNeedsRestart) {
710
var cancel = document.getElementById("plugin-installer-wizard").getButton("cancel");
711
cancel.label = this.getString("pluginInstallation.close.label");
712
cancel.accessKey = this.getString("pluginInstallation.close.accesskey");
713
var finish = document.getElementById("plugin-installer-wizard").getButton("finish");
714
finish.label = this.getFormattedString("pluginInstallation.restart.label", [app.name]);
715
finish.accessKey = this.getString("pluginInstallation.restart.accesskey");
716
this.canCancel(true);
719
this.canCancel(false);
723
722
this.canAdvance(true);
724
723
this.canRewind(false);
725
this.canCancel(false);
728
726
nsPluginInstallerWizard.prototype.loadURL = function (aUrl){
729
727
// Check if the page where the plugin came from can load aUrl before
730
// loading it, and do *not* allow loading javascript: or data: URIs.
731
var pluginPage = window.opener.content.location.href;
728
// loading it, and do *not* allow loading URIs that would inherit our
731
var pluginPagePrincipal =
732
window.opener.content.document.nodePrincipal;
733
734
const nsIScriptSecurityManager =
734
735
Components.interfaces.nsIScriptSecurityManager;
736
Components.classes["@mozilla.org/scriptsecuritymanager;1"]
737
.getService(nsIScriptSecurityManager);
736
var secMan = Components.classes["@mozilla.org/scriptsecuritymanager;1"]
737
.getService(nsIScriptSecurityManager);
739
secMan.checkLoadURIStr(pluginPage, aUrl,
740
nsIScriptSecurityManager.DISALLOW_SCRIPT_OR_DATA);
739
secMan.checkLoadURIStrWithPrincipal(pluginPagePrincipal, aUrl,
740
nsIScriptSecurityManager.DISALLOW_INHERIT_PRINCIPAL);
742
742
window.opener.open(aUrl);
838
if (gPluginInstaller.mBrowser) { // ffox 3 code can autoscan ...
840
var event = document.createEvent("Events");
841
event.initEvent("NewPluginInstalled", true, true);
842
var dispatched = gPluginInstaller.mBrowser.dispatchEvent(event);
844
else if (gPluginInstaller.mTab) { // ffox 2 code can autoscan ...
845
if ((gPluginInstaller.mSuccessfullPluginInstallation > 0) &&
846
(gPluginInstaller.mPluginInfoArrayLength != 0)) {
847
// clear the tab's plugin list only if we installed at least one plugin
848
gPluginInstaller.mTab.missingPlugins = null;
850
window.opener.gMissingPluginInstaller.closeNotification();
851
// reload the browser to make the new plugin show
852
window.opener.getBrowser().reloadTab(gPluginInstaller.mTab);
839
// don't refresh if no plugins were found or installed
840
if ((gPluginInstaller.mSuccessfullPluginInstallation > 0) &&
841
(gPluginInstaller.mPluginInfoArray.length != 0)) {
843
// reload plugins so JS detection works immediately
845
var ph = Components.classes["@mozilla.org/plugin/host;1"]
846
.getService(Components.interfaces.nsIPluginHost);
847
ph.reloadPlugins(false);
850
// reloadPlugins throws an exception if there were no plugins to load
853
if (gPluginInstaller.mBrowser) {
854
// notify listeners that a plugin is installed,
855
// so that they can reset the UI and update the browser.
856
var event = document.createEvent("Events");
857
event.initEvent("NewPluginInstalled", true, true);
858
gPluginInstaller.mBrowser.dispatchEvent(event);