开发者

InstallTrigger.install is not working in Firefox 4 while using -chrome. Any work arounds?

I work on an application that runs in chrome mode in Firefox (fx.exe -chrome chrome://app/content/main.xul). Prior to Firefox 4 (3开发者_如何学运维.6 and below) I used the InstallTrigger.install to upgrade the application when there was a new version available.

Unfortunately, this no longer works in Firefox 4. Has anyone else run into this problem? How did you get around it?


To work around the issue we used the AddOnManager API in the place of InstallTrigger.

For more information see XUL Dev Add-On Manager

Components.utils['import']("resource://gre/modules/AddonManager.jsm");

AddonManager.getInstallForURL(xpi_address, function(addon) {
    addon.addListener({
        onDownloadStarted: function() {
            alert('Download Started');
        }
      });
      addon.addListener({
        onDownloadProgress: function() {
            var complete_percent = parseInt((100 * (addon.progress/addon.maxProgress)),10);
        }
      });
      addon.addListener({
        onDownloadFailed: function() {
            alert('Upgrade Failed');
        }
      });
      addon.addListener({
        onDownloadEnded: function() {
            alert('Download Successful');
        }
      });
      addon.addListener({
        onInstallStarted: function() {
            alert('Install Started');
        }
      });
      addon.addListener({
        onInstallEnded: function() {
            alert('Install Successful');
        }
      });
      addon.addListener({
        onInstallFailed: function() {
            alert('Install Failed');
        }
      });
      addon.install();
    }, "application/x-xpinstall");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜