Categories

Writing auto-updaters

I was presented with a problem to solve last week – how do you get a Mozilla product to automatically suggest and download another product? The method I came up with was use the extension updater to our advantage: We can push an update via the browser’s autoupdate mechanism to install and extension which does all the work for us!

1) Built-in update manager downloads and installs a custom xpi.

2) This extension will load on next start, so all we need to do is overlay the browser.xul and we’ve got startup on every instance from that moment forward. All of our intended logic is encapsulated and run with privileges inside the chrome.

3) Use the hidden window trick to limit launching of the code to once-per-session.

4) Use the “@mozilla.org/download-manager;1″ CID to initiate the download and then monitor all downloads using the observer service (watch for dl-start/dl-done etc).

5) Once that is complete, you can then call downloadedFileObject.targetFile.launch() and your installer will run!

More details will follow when I can release the code.

1 comment to Writing auto-updaters

  • Wanli

    Hi,
    Could you kindly share me the code about downlod manager ? I’m really stucked here. Thanks!
    wanliyou AT gmail DOT com