2 // By Pike (Heavily inspired by code from Henrik Gemal and Stephen Clavering)
3 // Modified by Jason for Evergreen
7 // --- Editable items begin ---
8 extFullName: 'Evergreen Staff Client Demo', // The name displayed to the user (don't include the version)
9 extShortName: 'evergreen', // The leafname of the JAR file (without the .jar part)
12 extLocaleNames: ['en-US'], //null, // e.g. ['en-US', 'en-GB']
13 extSkinNames: null, // e.g. ['classic', 'modern']
14 extPostInstallMessage: 'Success! Please restart your browser to finish the installation.', // Set to null for no post-install message
15 // --- Editable items end ---
22 var jarName = this.extShortName + '.jar';
23 var profileDir = Install.getFolder('Profile', 'chrome');
25 // Parse HTTP arguments
26 this.parseArguments();
28 // Check if extension is already installed in profile
29 if (File.exists(Install.getFolder(profileDir, jarName)))
31 if (!this.silentInstall)
33 Install.alert('Updating existing Profile install of ' + this.extFullName + ' to version ' + this.extVersion + '.');
35 this.profileInstall = true;
37 else if (!this.silentInstall)
39 // Ask user for install location, profile or browser dir?
40 this.profileInstall = Install.confirm('Install ' + this.extFullName + ' ' + this.extVersion + ' to your Profile directory (OK) or your Browser directory (Cancel)?');
44 var dispName = this.extFullName + ' ' + this.extVersion;
45 var regName = '/' + this.extAuthor + '/' + this.extShortName;
46 Install.initInstall(dispName, regName, this.extVersion);
48 // Find directory to install into
50 if (this.profileInstall) installPath = profileDir;
51 else installPath = Install.getFolder('chrome');
54 Install.addFile(null, 'chrome/' + jarName, installPath, null);
57 var jarPath = Install.getFolder(installPath, jarName);
58 var installType = this.profileInstall ? Install.PROFILE_CHROME : Install.DELAYED_CHROME;
61 Install.registerChrome(Install.CONTENT | installType, jarPath, 'content/' + this.extShortName + '/');
64 for (var locale in this.extLocaleNames)
66 var regPath = 'locale/' + this.extLocaleNames[locale] + '/' + this.extShortName + '/';
67 Install.registerChrome(Install.LOCALE | installType, jarPath, regPath);
71 for (var skin in this.extSkinNames)
73 var regPath = 'skin/' + this.extSkinNames[skin] + '/' + this.extShortName + '/';
74 Install.registerChrome(Install.SKIN | installType, jarPath, regPath);
78 var err = Install.performInstall();
79 if (err == Install.SUCCESS || err == Install.REBOOT_NEEDED)
81 if (!this.silentInstall && this.extPostInstallMessage)
83 Install.alert(this.extPostInstallMessage);
88 this.handleError(err);
93 parseArguments: function()
95 // Can't use string handling in install, so use if statement instead
96 var args = Install.arguments;
99 this.profileInstall = false;
100 this.silentInstall = true;
102 else if (args == 'p=1')
104 this.profileInstall = true;
105 this.silentInstall = true;
109 handleError: function(err)
111 if (!this.silentInstall)
113 Install.alert('Error: Could not install ' + this.extFullName + ' ' + this.extVersion + ' (Error code: ' + err + ')');
115 Install.cancelInstall(err);
119 XpiInstaller.install();