286034 - allow extensions to be installed/uninstalled by simply adding/removing their directories... r=bsmedberg, sr=darin, a=brendan

This commit is contained in:
ben%bengoodger.com 2005-04-23 01:39:51 +00:00
Родитель 59fbf4800d
Коммит b9725a8b1a
32 изменённых файлов: 5294 добавлений и 3890 удалений

Просмотреть файл

@ -45,7 +45,7 @@
static const nsXREAppData kAppData = {
"Mozilla",
"Firefox",
"Firefox Debug",
NS_STRINGIFY(APP_VERSION),
NS_STRINGIFY(BUILD_ID),
// ec8030f7-c20a-464f-9b0e-13a3a9e97384

Просмотреть файл

@ -3,7 +3,6 @@
<RDF xmlns:em="http://www.mozilla.org/2004/em-rdf#"
xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<Seq about="urn:mozilla:extension:root"/>
<Seq about="urn:mozilla:theme:root"/>
<Seq about="urn:mozilla:item:root"/>
</RDF>

Просмотреть файл

@ -54,8 +54,6 @@ FILES := $(addprefix $(srcdir)/, $(FILES))
libs::
$(INSTALL) $(FILES) $(DIST)/bin/defaults/profile/extensions
$(INSTALL) $(srcdir)/"installed-extensions.txt" $(DIST)/bin/defaults/profile/extensions
install::
$(SYSINSTALL) $(IFLAGS1) $(FILES) $(DESTDIR)$(mozappdir)/defaults/profile/extensions
$(SYSINSTALL) $(IFLAGS1) $(srcdir)/"installed-extensions.txt" $(DESTDIR)$(mozappdir)/defaults/profile/extensions

Просмотреть файл

@ -49,7 +49,7 @@ FILES := \
libs::
$(PERL) $(MOZILLA_DIR)/config/preprocessor.pl $(DEFINES) $(ACDEFINES) $(srcdir)/install.rdf.in > install.rdf
$(INSTALL) $(FILES) $(DIST)/bin/defaults/profile/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}
$(INSTALL) $(FILES) $(DIST)/bin/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}
install::
$(SYSINSTALL) $(IFLAGS1) $(FILES) $(DESTDIR)$(mozappdir)/defaults/profile/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}
$(SYSINSTALL) $(IFLAGS1) $(FILES) $(DESTDIR)$(mozappdir)/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}

Просмотреть файл

@ -12,8 +12,8 @@
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>1.0</em:minVersion>
<em:maxVersion>1.0</em:maxVersion>
<em:minVersion>1.1</em:minVersion>
<em:maxVersion>1.1</em:maxVersion>
</Description>
</em:targetApplication>

Просмотреть файл

@ -66,6 +66,13 @@ pref("update.extensions.enabled", true);
pref("update.extensions.wsdl", "chrome://mozapps/locale/extensions/extensions.properties");
pref("extensions.getMoreExtensionsURL", "chrome://mozapps/locale/extensions/extensions.properties");
pref("extensions.getMoreThemesURL", "chrome://mozapps/locale/extensions/extensions.properties");
// Developers can set this to |true| if they are constantly changing files in their
// extensions directory so that the extension system does not constantly think that
// their extensions are being updated and thus reregistered every time the app is
// started.
pref("extensions.ignoreMTimeChanges", false);
// Enables some extra Extension System Logging (can reduce performance)
pref("extensions.logging.enabled", false);
// App-specific update preferences
pref("app.update.enabled", true); // Whether or not app updates are enabled

Просмотреть файл

@ -24,9 +24,6 @@ bin/defaults/profile/localstore.rdf
bin/defaults/profile/prefs.js
bin/defaults/profile/search.rdf
bin/defaults/profile/mimeTypes.rdf
bin/defaults/profile/extensions/Extensions.rdf
bin/defaults/profile/extensions/installed-extensions.txt
bin/defaults/profile/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}/install.rdf
bin/defaults/profile/chrome/*
[xpcom]
@ -204,6 +201,7 @@ bin/components/mozgnome.xpt
; [Browser Chrome Files]
bin/chrome/browser.jar
bin/chrome/classic.jar
bin/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}/install.rdf
bin/chrome/comm.jar
bin/chrome/toolkit.jar
bin/chrome/toolkit.manifest

Просмотреть файл

@ -23,10 +23,6 @@ bin\defaults\profile\localstore.rdf
bin\defaults\profile\prefs.js
bin\defaults\profile\search.rdf
bin\defaults\profile\mimeTypes.rdf
bin\defaults\profile\extensions\Extensions.rdf
bin\defaults\profile\extensions\installed-extensions.txt
bin\defaults\profile\extensions\{641d8d09-7dda-4850-8228-ac0ab65e2ac9}\install.rdf
bin\defaults\profile\extensions\{972ce4c6-7e08-4474-a285-3208198ce6fd}\install.rdf
bin\defaults\profile\chrome\*
[xpcom]
@ -199,6 +195,7 @@ bin\components\update.xpt
; [Browser Chrome Files]
bin\chrome\browser.jar
bin\chrome\classic.jar
bin\extensions\{972ce4c6-7e08-4474-a285-3208198ce6fd}\install.rdf
bin\chrome\comm.jar
bin\chrome\toolkit.jar
bin\chrome\toolkit.manifest

Просмотреть файл

@ -46,14 +46,6 @@
<!ENTITY about.tooltip "About">
<!ENTITY homepage.tooltip "Home Page">
<!ENTITY extensionItem.toBeDisabled.label "This item will be disabled after you restart &brandShortName;.">
<!ENTITY extensionItem.toBeEnabled.label "This item will be enabled after you restart &brandShortName;.">
<!ENTITY extensionItem.toBeInstalled.label "This item will be installed after you restart &brandShortName;.">
<!ENTITY extensionItem.toBeUninstalled.label "This item will be uninstalled after you restart &brandShortName;.">
<!ENTITY extensionItem.done.label "Install Success">
<!ENTITY extensionItem.waiting.label "Waiting...">
<!ENTITY extensionItem.installing.label "Installing...">
<!ENTITY getMoreExtensions.label "Get More Extensions">
<!ENTITY getMoreExtensions.tooltip "Get More Extensions from addons.mozilla.org">
<!ENTITY getMoreThemes.label "Get More Themes">

Просмотреть файл

@ -8,9 +8,15 @@ restartBeforeEnableMessage=%S will be enabled the next time you restart %S.
restartBeforeDisableMessage=%S will be disabled the next time you restart %S.
restartBeforeUninstallTitle=Uninstall
restartBeforeUninstallMessage=%S will be uninstalled the next time you restart %S.
restartBeforeInstallMessage=%S will be installed the next time you restart %S.
restartBeforeUpgradeMessage=%S will be upgraded the next time you restart %S.
queryUninstallExtensionMessage=If you uninstall %S, the functionality it offers will no longer be available. Do you want to uninstall %S?
queryUninstallThemeMessage=Do you want to uninstall %S?
queryUninstallTitle=Uninstall %S
installSuccess=Install completed successfully
installWaiting=Waiting...
installInstalling=Installing...
droppedInWarning=The following items were found in your Extensions folder. Do you want to install them?
extensions.update.url=https://addons.mozilla.org/update/VersionCheck.php?reqVersion=%REQ_VERSION%&id=%ITEM_ID%&version=%ITEM_VERSION%&maxAppVersion=%ITEM_MAXAPPVERSION%&appID=%APP_ID%&appVersion=%APP_VERSION%&appOS=%APP_OS%
extensions.getMoreExtensionsURL=https://addons.mozilla.org/extensions/?application=%APPID%
@ -24,8 +30,6 @@ globalItemList=The following items are available to all users. \nYou can start F
globalItemListExtensions=\n\nGlobally Available Extensions:\n==============================\n\n
globalItemListThemes=\n\nGlobally Available Themes:\n==========================\n\n
installSuccess=Installed Successfully
statusFormatKBKB=#1 of #2 KB
statusFormatKBMB=#1 KB of #2 MB
statusFormatMBMB=#1 of #2 MB
@ -33,30 +37,27 @@ statusFormatMBMB=#1 of #2 MB
disabledObsoleteTitle=Old Extensions
disabledObsoleteMessage=Any old extensions that you have installed have been disabled.
theme=Theme
extension=Extension
type-4=Theme
type-2=Extension
incompatibleTitle=Incompatible %S
incompatibleMsg=%S %S could not be installed because it is not compatible with %S %S. (%S %S will only work with %S versions from %S to %S)
incompatibleMsgSingleAppVersion=%S %S could not be installed because it is not compatible %S %S. (%S %S will only work with %S %S)
incompatibleMsgSingleAppVersion=%S %S could not be installed because it is not compatible with %S %S. (%S %S will only work with %S %S)
incompatibleMessageNoApp=%S %S could not be installed because it is not compatible with %S.
incompatibleOlder=versions 0.8 or older.
incompatibleThemeName=this Theme
incompatibleExtension=Disabled - not compatible with %S %S
invalidGUIDMessage="%S" could not be installed because of an error in its Install Manifest ("%S" is not a valid GUID). Please contact the author of this item about the problem.
invalidVersionMessage="%S" could not be installed because of an error in its Install Manifest ("%S" is not a valid Version String). Please contact the author of this item about the problem.
missingFileTitle=Missing File
missingFileMessage=%S could not load this item because the file %S was missing.
missingFileConsoleMessage=Failed to install from %S because %S was not provided at the top level of the jar/xpi file.
malformedMessage=%S could not install this item because "%S" (provided by the item) is malformed. Please contact the author about this problem.
malformedMessage=%S could not install this item because "%S" (provided by the item) is not well-formed or does not exist. Please contact the author about this problem.
malformedTitle=Malformed File
malformedRegistrationTitle=Chrome Registration Failed
malformedRegistrationMessage=%S could not install this item because of a failure in Chrome Registration. Please contact the author about this problem, or click View Details for more information.
malformedRegistrationConsoleMessage=Chrome Registration failed for Extension '%S' when calling nsIXULChromeRegistry::%S with this chrome path: %S (profile extension = %S). Perhaps this path does not exist within the chrome JAR file, or the contents.rdf file at that location is malformed?
malformedRegistrationDetailsButton=View Details
invalidVersionMessage=%S could not install "%S" because its version information ("%S") is invalid. Please contact the author about this problem.
invalidVersionTitle=Invalid Version
malformedRegistrationMessage=%S could not install this item because of a failure in Chrome Registration. Please contact the author about this problem..
errorInstallTitle=Error
errorInstallMessage=%S could not download the file at \n\n%S\n\nbecause: %S

Просмотреть файл

@ -6,4 +6,6 @@ installButtonDisabledLabel=Install (%S)
installButtonLabel=Install Now
installComplete=Software Installation is complete. You will have to restart %S for changes to take effect.
installCompleteTitle=Installation Complete
installCompleteTitle=Installation Complete
error-203=Error Installing Item

Просмотреть файл

@ -8,60 +8,18 @@ extension {
-moz-box-orient: vertical;
}
extension[state="waiting"] {
-moz-binding: url("chrome://mozapps/content/extensions/extensions.xml#extension-waiting");
}
extension[state="downloading"] {
-moz-binding: url("chrome://mozapps/content/extensions/extensions.xml#extension-downloading");
}
extension[state="installing"] {
-moz-binding: url("chrome://mozapps/content/extensions/extensions.xml#extension-installing");
}
extension[state="done"] {
-moz-binding: url("chrome://mozapps/content/extensions/extensions.xml#extension-done");
}
extension[toBeDisabled="true"] {
-moz-binding: url("chrome://mozapps/content/extensions/extensions.xml#extension-tobedisabled");
}
extension[toBeEnabled="true"] {
-moz-binding: url("chrome://mozapps/content/extensions/extensions.xml#extension-tobeenabled");
}
extension[toBeInstalled="true"] {
-moz-binding: url("chrome://mozapps/content/extensions/extensions.xml#extension-tobeinstalled");
}
extension[toBeUninstalled="true"] {
-moz-binding: url("chrome://mozapps/content/extensions/extensions.xml#extension-tobeuninstalled");
}
extension[itemType="theme"] {
-moz-binding: url("chrome://mozapps/content/extensions/extensions.xml#theme");
}
extension[itemType="theme"][state="waiting"] {
-moz-binding: url("chrome://mozapps/content/extensions/extensions.xml#theme-waiting");
}
extension[itemType="theme"][state="downloading"] {
-moz-binding: url("chrome://mozapps/content/extensions/extensions.xml#theme-downloading");
}
extension[itemType="theme"][state="installing"] {
-moz-binding: url("chrome://mozapps/content/extensions/extensions.xml#theme-installing");
}
extension[itemType="theme"][state="done"] {
-moz-binding: url("chrome://mozapps/content/extensions/extensions.xml#theme-done");
}
.themePreviewArea {
width: 0px;
}

Просмотреть файл

@ -19,7 +19,7 @@
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Ben Goodger <ben@bengoodger.com>
# Ben Goodger <ben@mozilla.org>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
@ -44,8 +44,6 @@ const nsIUpdateItem = Components.interfaces.nsIUpdateItem;
var gExtensionManager = null;
var gExtensionsView = null;
var gWindowState = "";
var gURIPrefix = ""; // extension or theme prefix
var gDSRoot = ""; // extension or theme root
var gGetMoreURL = "";
var gCurrentTheme = "";
var gDownloadManager = null;
@ -61,33 +59,17 @@ const PREF_GENERAL_SKINS_SELECTEDSKIN = "general.skins.selectedSkin";
const KEY_DEFAULT_THEME = "classic/1.0";
const RDFURI_ITEM_ROOT = "urn:mozilla:item:root";
const PREFIX_ITEM_URI = "urn:mozilla:item:";
///////////////////////////////////////////////////////////////////////////////
// Utility Functions
const PREFIX_EXTENSION = "urn:mozilla:extension:";
const PREFIX_THEME = "urn:mozilla:theme:";
function getItemPrefix(aItemType)
function getIDFromResourceURI(aURI)
{
var prefix = "";
if (aItemType & nsIUpdateItem.TYPE_EXTENSION)
prefix = PREFIX_EXTENSION;
else if (aItemType & nsIUpdateItem.TYPE_THEME)
prefix = PREFIX_THEME;
return prefix;
}
function stripPrefix(aURI, aItemType)
{
var val = aURI;
if (aItemType == nsIUpdateItem.TYPE_ADDON)
val = stripPrefix(aURI, getItemType(aURI));
else {
var prefix = getItemPrefix(aItemType);
if (prefix && aURI.substr(0, prefix.length) == prefix)
val = aURI.substr(prefix.length, aURI.length);
}
return val;
if (aURI.substring(0, PREFIX_ITEM_URI.length) == PREFIX_ITEM_URI)
return aURI.substring(PREFIX_ITEM_URI.length);
return aURI;
}
function openURL(aURL)
@ -124,7 +106,15 @@ function setRestartMessage(aItem)
var themeName = aItem.getAttribute("name");
var restartMessage = extensionStrings.formatStringFromName("dssSwitchAfterRestart",
[brandShortName], 1);
aItem.setAttribute("creator", restartMessage);
for (var i = 0; i < gExtensionsView.childNodes.length; ++i) {
var item = gExtensionsView.childNodes[i];
if (item.hasAttribute("oldDescription")) {
item.setAttribute("description", item.getAttribute("oldDescription"));
item.removeAttribute("oldDescription");
}
}
aItem.setAttribute("oldDescription", aItem.getAttribute("description"));
aItem.setAttribute("description", restartMessage);
}
///////////////////////////////////////////////////////////////////////////////
@ -144,9 +134,9 @@ function Startup()
gWindowState = window.location.search.substr("?type=".length, window.location.search.length);
var isExtensions = gWindowState == "extensions";
gURIPrefix = isExtensions ? "urn:mozilla:extension:" : "urn:mozilla:theme:";
gDSRoot = isExtensions ? "urn:mozilla:extension:root" : "urn:mozilla:theme:root";
gItemType = isExtensions ? nsIUpdateItem.TYPE_EXTENSION : nsIUpdateItem.TYPE_THEME;
var typeCondition = document.getElementById("typeCondition");
typeCondition.setAttribute("object", gItemType);
document.documentElement.setAttribute("windowtype", document.documentElement.getAttribute("windowtype") + "-" + gWindowState);
@ -163,7 +153,7 @@ function Startup()
// Finally, update the UI.
gExtensionsView.database.AddDataSource(gExtensionManager.datasource);
gExtensionsView.setAttribute("ref", gDSRoot);
gExtensionsView.setAttribute("ref", RDFURI_ITEM_ROOT);
gExtensionsView.focus();
var pref = Components.classes["@mozilla.org/preferences-service;1"]
@ -171,11 +161,13 @@ function Startup()
if (!isExtensions) {
gExtensionsView.addEventListener("richview-select", onThemeSelect, false);
if (pref.prefHasUserValue(PREF_GENERAL_SKINS_SELECTEDSKIN))
if (pref.prefHasUserValue(PREF_EM_LAST_SELECTED_SKIN))
gCurrentTheme = pref.getCharPref(PREF_EM_LAST_SELECTED_SKIN);
else if (pref.prefHasUserValue(PREF_GENERAL_SKINS_SELECTEDSKIN))
gCurrentTheme = pref.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN);
else
if (!gCurrentTheme)
gCurrentTheme = KEY_DEFAULT_THEME;
var useThemeButton = document.getElementById("useThemeButton");
useThemeButton.hidden = false;
@ -185,15 +177,15 @@ function Startup()
var pref = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
if (!pref.getBoolPref(PREF_EXTENSIONS_DSS_ENABLED) &&
pref.getBoolPref(PREF_EXTENSIONS_DSS_SWITCHPENDING)) {
pref.getBoolPref(PREF_EXTENSIONS_DSS_SWITCHPENDING) &&
pref.prefHasUserValue(PREF_EM_LAST_SELECTED_SKIN)) {
var lastSelectedSkin = pref.getCharPref(PREF_EM_LAST_SELECTED_SKIN);
for (var i = 0; i < gExtensionsView.childNodes.length; ++i) {
var item = gExtensionsView.childNodes[i];
if (item.getAttribute("internalName") == lastSelectedSkin) {
setRestartMessage(item);
if (item.getAttribute("internalName") == lastSelectedSkin)
break;
}
}
setRestartMessage(item);
}
}
@ -333,7 +325,7 @@ XPInstallDownloadManager.prototype = {
// gExtensionManager.addDownload(displayName, url, iconURL, type);
var item = Components.classes["@mozilla.org/updates/item;1"]
.createInstance(Components.interfaces.nsIUpdateItem);
item.init(url, " ", "", "", displayName, -1, url, iconURL, "", type);
item.init(url, " ", "app-profile", "", "", displayName, url, iconURL, "", type);
items.push(item);
// Advance the enumerator
@ -349,7 +341,7 @@ XPInstallDownloadManager.prototype = {
},
/////////////////////////////////////////////////////////////////////////////
// nsIExtensionDownloadProgressListener
// nsIExtensionDownloadListener
onStateChange: function (aURL, aState, aValue)
{
const nsIXPIProgressDialog = Components.interfaces.nsIXPIProgressDialog;
@ -358,6 +350,11 @@ XPInstallDownloadManager.prototype = {
switch (aState) {
case nsIXPIProgressDialog.DOWNLOAD_START:
element.setAttribute("state", "waiting");
var extensionsStrings = document.getElementById("extensionsStrings");
element.setAttribute("description",
extensionsStrings.getString("installWaiting"));
element.setAttribute("progress", "0");
break;
case nsIXPIProgressDialog.DOWNLOAD_DONE:
@ -365,10 +362,17 @@ XPInstallDownloadManager.prototype = {
break;
case nsIXPIProgressDialog.INSTALL_START:
element.setAttribute("state", "installing");
var extensionsStrings = document.getElementById("extensionsStrings");
element.setAttribute("description",
extensionsStrings.getString("installInstalling"));
break;
case nsIXPIProgressDialog.INSTALL_DONE:
dump("*** state change = " + aURL + ", state = " + aState + ", value = " + aValue + "\n");
element.setAttribute("state", "done");
var extensionsStrings = document.getElementById("extensionsStrings");
element.setAttribute("description",
extensionsStrings.getString("installSuccess"));
var msg;
if (aValue != 0) {
var xpinstallStrings = document.getElementById("xpinstallStrings");
@ -392,12 +396,11 @@ XPInstallDownloadManager.prototype = {
.getService(Components.interfaces.nsIPromptService);
ps.alert(window, title, message);
element.setAttribute("status", msg);
}
// Remove the dummy, since we installed successfully
var type = gWindowState == "extensions" ? nsIUpdateItem.TYPE_EXTENSION
: nsIUpdateItem.TYPE_THEME;
gExtensionManager.removeDownload(aURL, type);
gExtensionManager.removeDownload(aURL);
break;
case nsIXPIProgressDialog.DIALOG_CLOSE:
break;
@ -466,7 +469,7 @@ XPInstallDownloadManager.prototype = {
// nsISupports
QueryInterface: function (aIID)
{
if (!aIID.equals(Components.interfaces.nsIExtensionDownloadProgressListener) &&
if (!aIID.equals(Components.interfaces.nsIExtensionDownloadListener) &&
!aIID.equals(Components.interfaces.nsISupports))
throw Components.results.NS_ERROR_NO_INTERFACE;
return this;
@ -673,6 +676,17 @@ var gExtensionsDNDObserver =
///////////////////////////////////////////////////////////////////////////////
// Command Updating and Command Handlers
function canWriteToLocation(element)
{
var installLocation = null;
if (element) {
var id = getIDFromResourceURI(element.id)
installLocation = gExtensionManager.getInstallLocation(id);
}
return installLocation ? installLocation.canAccess : false;
}
var gExtensionsViewController = {
supportsCommand: function (aCommand)
{
@ -697,7 +711,9 @@ var gExtensionsViewController = {
selectedItem.getAttribute("toBeUninstalled") != "true" &&
selectedItem.getAttribute("optionsURL") != "";
case "cmd_about":
return selectedItem && (selectedItem.disabled ? selectedItem.getAttribute("aboutURL") == "" : true);
return selectedItem &&
selectedItem.getAttribute("toBeInstalled") != "true" &&
(selectedItem.disabled ? selectedItem.getAttribute("aboutURL") == "" : true);
case "cmd_homepage":
return selectedItem && selectedItem.getAttribute("homepageURL") != "";
case "cmd_uninstall":
@ -709,12 +725,15 @@ var gExtensionsViewController = {
}
return selectedItem &&
selectedItem.getAttribute("toBeUninstalled") != "true" &&
selectedItem.getAttribute("locked") != "true";
selectedItem.getAttribute("toBeInstalled") != "true" &&
selectedItem.getAttribute("locked") != "true" &&
canWriteToLocation(selectedItem);
case "cmd_update":
return !selectedItem ||
(selectedItem &&
selectedItem.getAttribute("toBeUninstalled") != "true" &&
selectedItem.getAttribute("toBeInstalled") != "true");
selectedItem.getAttribute("toBeInstalled") != "true") &&
canWriteToLocation(selectedItem);
case "cmd_reallyEnable":
// controls whether to show Enable or Disable in extensions' context menu
return selectedItem &&
@ -730,8 +749,8 @@ var gExtensionsViewController = {
case "cmd_disable":
return selectedItem &&
!selectedItem.disabled &&
selectedItem.getAttribute("toBeUninstalled") != "true" &&
selectedItem.getAttribute("locked") != "true";
selectedItem.getAttribute("toBeUninstalled") != "true" &&
selectedItem.getAttribute("toBeInstalled") != "true";
case "cmd_movetop":
return selectedItem && (gExtensionsView.children[0] != selectedItem);
case "cmd_moveup":
@ -825,29 +844,29 @@ var gExtensionsViewController = {
cmd_movetop: function (aSelectedItem)
{
var movingID = aSelectedItem.id;
gExtensionManager.moveTop(stripPrefix(movingID, gItemType));
gExtensionManager.moveTop(getIDFromResourceURI(movingID));
gExtensionsView.selected = document.getElementById(movingID);
},
cmd_moveup: function (aSelectedItem)
{
var movingID = aSelectedItem.id;
gExtensionManager.moveUp(stripPrefix(movingID, gItemType));
gExtensionManager.moveUp(getIDFromResourceURI(movingID));
gExtensionsView.selected = document.getElementById(movingID);
},
cmd_movedn: function (aSelectedItem)
{
var movingID = aSelectedItem.id;
gExtensionManager.moveDown(stripPrefix(movingID, gItemType));
gExtensionManager.moveDown(getIDFromResourceURI(movingID));
gExtensionsView.selected = document.getElementById(movingID);
},
cmd_update: function (aSelectedItem)
{
var id = aSelectedItem ? stripPrefix(aSelectedItem.id, gItemType) : null;
var id = aSelectedItem ? getIDFromResourceURI(aSelectedItem.id) : null;
var itemType = gWindowState == "extensions" ? nsIUpdateItem.TYPE_EXTENSION : nsIUpdateItem.TYPE_THEME;
var items = gExtensionManager.getItemList(id, itemType, { });
var items = id ? [gExtensionManager.getItemForID(id)] : [];
var updates = Components.classes["@mozilla.org/updates/update-service;1"]
.getService(Components.interfaces.nsIUpdateService);
updates.checkForUpdates(items, items.length, itemType,
@ -881,9 +900,7 @@ var gExtensionsViewController = {
nextElement = selectedElement.previousSibling;
nextElement = nextElement.id;
if (gWindowState == "extensions")
gExtensionManager.uninstallExtension(stripPrefix(selectedID, gItemType));
else if (gWindowState == "themes") {
if (gWindowState == "themes") {
// If the theme being uninstalled is the current theme, we need to reselect
// the default.
var pref = Components.classes["@mozilla.org/preferences-service;1"]
@ -891,27 +908,20 @@ var gExtensionsViewController = {
var currentTheme = pref.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN);
if (aSelectedItem.getAttribute("internalName") == currentTheme)
this.cmd_useTheme(document.getElementById("urn:mozilla:theme:{972ce4c6-7e08-4474-a285-3208198ce6fd}"));
gExtensionManager.uninstallTheme(stripPrefix(selectedID, gItemType));
}
gExtensionManager.uninstallItem(getIDFromResourceURI(selectedID));
gExtensionsView.selected = document.getElementById(nextElement);
},
cmd_disable: function (aSelectedItem)
{
if (gWindowState == "extensions")
gExtensionManager.disableExtension(stripPrefix(aSelectedItem.id, gItemType));
else
gExtensionManager.disableTheme(stripPrefix(aSelectedItem.id, gItemType));
gExtensionManager.disableItem(getIDFromResourceURI(aSelectedItem.id));
},
cmd_enable: function (aSelectedItem)
{
if (gWindowState == "extensions")
gExtensionManager.enableExtension(stripPrefix(aSelectedItem.id, gItemType));
else
gExtensionManager.enableTheme(stripPrefix(aSelectedItem.id, gItemType));
gExtensionManager.enableItem(getIDFromResourceURI(aSelectedItem.id));
#ifdef MOZ_PHOENIX
}
}

Просмотреть файл

@ -72,137 +72,6 @@
</content>
</binding>
<binding id="extension-tobedisabled" extends="chrome://mozapps/content/shared/richview.xml#richview-item">
<resources>
<stylesheet src="chrome://mozapps/skin/extensions/extensions.css"/>
</resources>
<content>
<xul:hbox flex="1">
<xul:vbox pack="start">
<xul:image class="extension-icon" xbl:inherits="src=image"
style="width: 32px; max-width: 32px; height: 32px; max-height: 32px;"/>
</xul:vbox>
<xul:vbox pack="start" flex="1">
<xul:hbox>
<xul:label class="extension-item-name" xbl:inherits="value=name" crop="center"/>
<xul:label class="extension-item-version" xbl:inherits="value=version"/>
</xul:hbox>
<xul:description class="extension-item-description">
&extensionItem.toBeDisabled.label;
</xul:description>
</xul:vbox>
</xul:hbox>
</content>
<implementation>
<field name="eventPrefix">"extension-"</field>
</implementation>
</binding>
<binding id="extension-tobeenabled" extends="chrome://mozapps/content/shared/richview.xml#richview-item">
<resources>
<stylesheet src="chrome://mozapps/skin/extensions/extensions.css"/>
</resources>
<content>
<xul:hbox flex="1">
<xul:vbox pack="start">
<xul:image class="extension-icon" xbl:inherits="src=image"
style="width: 32px; max-width: 32px; height: 32px; max-height: 32px;"/>
</xul:vbox>
<xul:vbox pack="start" flex="1">
<xul:hbox>
<xul:label class="extension-item-name" xbl:inherits="value=name" crop="center"/>
<xul:label class="extension-item-version" xbl:inherits="value=version"/>
</xul:hbox>
<xul:description class="extension-item-description">
&extensionItem.toBeEnabled.label;
</xul:description>
</xul:vbox>
</xul:hbox>
</content>
<implementation>
<field name="eventPrefix">"extension-"</field>
</implementation>
</binding>
<binding id="extension-tobeinstalled" extends="chrome://mozapps/content/shared/richview.xml#richview-item">
<resources>
<stylesheet src="chrome://mozapps/skin/extensions/extensions.css"/>
</resources>
<content>
<xul:hbox flex="1">
<xul:vbox pack="start">
<xul:image class="extension-icon" xbl:inherits="src=image"
style="width: 32px; max-width: 32px; height: 32px; max-height: 32px;"/>
</xul:vbox>
<xul:vbox pack="start" flex="1">
<xul:hbox>
<xul:label class="extension-item-name" xbl:inherits="value=name" crop="center"/>
<xul:label class="extension-item-version" xbl:inherits="value=version"/>
</xul:hbox>
<xul:description class="extension-item-description">
&extensionItem.toBeInstalled.label;
</xul:description>
</xul:vbox>
</xul:hbox>
</content>
<implementation>
<field name="eventPrefix">"extension-"</field>
</implementation>
</binding>
<binding id="extension-tobeuninstalled" extends="chrome://mozapps/content/shared/richview.xml#richview-item">
<resources>
<stylesheet src="chrome://mozapps/skin/extensions/extensions.css"/>
</resources>
<content>
<xul:hbox flex="1">
<xul:vbox pack="start">
<xul:image class="extension-icon" xbl:inherits="src=image"
style="width: 32px; max-width: 32px; height: 32px; max-height: 32px;"/>
</xul:vbox>
<xul:vbox pack="start" flex="1">
<xul:hbox>
<xul:label class="extension-item-name" xbl:inherits="value=name" crop="center"/>
<xul:label class="extension-item-version" xbl:inherits="value=version"/>
</xul:hbox>
<xul:description class="extension-item-description">
&extensionItem.toBeUninstalled.label;
</xul:description>
</xul:vbox>
</xul:hbox>
</content>
<implementation>
<field name="eventPrefix">"extension-"</field>
</implementation>
</binding>
<binding id="extension-waiting" extends="chrome://mozapps/content/shared/richview.xml#richview-item">
<resources>
<stylesheet src="chrome://mozapps/skin/extensions/extensions.css"/>
</resources>
<content>
<xul:hbox flex="1">
<xul:vbox pack="start">
<xul:image class="extension-icon" xbl:inherits="src=image"
style="width: 32px; max-width: 32px; height: 32px; max-height: 32px;"/>
</xul:vbox>
<xul:vbox pack="start" flex="1">
<xul:hbox>
<xul:label class="extension-item-name" xbl:inherits="value=name" crop="center"/>
<xul:label class="extension-item-version" xbl:inherits="value=version"/>
</xul:hbox>
<xul:description class="extension-item-description">
&extensionItem.waiting.label;
</xul:description>
<xul:label value=" "/>
</xul:vbox>
</xul:hbox>
</content>
<implementation>
<field name="eventPrefix">"extension-"</field>
</implementation>
</binding>
<binding id="extension-downloading" extends="chrome://mozapps/content/shared/richview.xml#richview-item">
<resources>
<stylesheet src="chrome://mozapps/skin/extensions/extensions.css"/>
@ -228,178 +97,5 @@
</implementation>
</binding>
<binding id="extension-installing" extends="chrome://mozapps/content/shared/richview.xml#richview-item">
<resources>
<stylesheet src="chrome://mozapps/skin/extensions/extensions.css"/>
</resources>
<content>
<xul:hbox flex="1">
<xul:vbox pack="start">
<xul:image class="extension-icon" xbl:inherits="src=image"
style="width: 32px; max-width: 32px; height: 32px; max-height: 32px;"/>
</xul:vbox>
<xul:vbox pack="start" flex="1">
<xul:hbox>
<xul:label class="extension-item-name" xbl:inherits="value=name" crop="center"/>
<xul:label class="extension-item-version" xbl:inherits="value=version"/>
</xul:hbox>
<xul:description class="extension-item-description">
&extensionItem.installing.label;
</xul:description>
<xul:label value=" "/>
</xul:vbox>
</xul:hbox>
</content>
<implementation>
<field name="eventPrefix">"extension-"</field>
</implementation>
</binding>
<binding id="extension-done" extends="chrome://mozapps/content/shared/richview.xml#richview-item">
<resources>
<stylesheet src="chrome://mozapps/skin/extensions/extensions.css"/>
</resources>
<content>
<xul:hbox flex="1">
<xul:vbox pack="start">
<xul:image class="extension-icon" xbl:inherits="src=image"
style="width: 32px; max-width: 32px; height: 32px; max-height: 32px;"/>
</xul:vbox>
<xul:vbox pack="start" flex="1">
<xul:hbox>
<xul:label class="extension-item-name" xbl:inherits="value=name" crop="center"/>
<xul:label class="extension-item-version" xbl:inherits="value=version"/>
</xul:hbox>
<xul:label class="extension-item-description" xbl:inherits="value=error"
value="&extensionItem.done.label;"/>
<xul:label value=" "/>
</xul:vbox>
</xul:hbox>
</content>
<implementation>
<field name="eventPrefix">"extension-"</field>
</implementation>
</binding>
<binding id="theme" extends="chrome://mozapps/content/shared/richview.xml#richview-item">
<resources>
<stylesheet src="chrome://mozapps/skin/extensions/extensions.css"/>
</resources>
<content>
<xul:hbox flex="1">
<xul:vbox pack="start">
<xul:image class="extension-icon" xbl:inherits="src=image"
style="width: 32px; max-width: 32px; height: 32px; max-height: 32px;"/>
</xul:vbox>
<xul:vbox pack="start" flex="1">
<xul:hbox>
<xul:label class="extension-item-name" xbl:inherits="value=name" crop="center"/>
<xul:label class="extension-item-version" xbl:inherits="value=version"/>
</xul:hbox>
<xul:label class="extension-item-creator" xbl:inherits="value=creator" crop="right"/>
</xul:vbox>
</xul:hbox>
</content>
<implementation>
<field name="eventPrefix">"extension-"</field>
</implementation>
</binding>
<binding id="theme-waiting" extends="chrome://mozapps/content/shared/richview.xml#richview-item">
<resources>
<stylesheet src="chrome://mozapps/skin/extensions/extensions.css"/>
</resources>
<content>
<xul:hbox flex="1">
<xul:vbox pack="start">
<xul:image class="extension-icon" xbl:inherits="src=image"
style="width: 32px; max-width: 32px; height: 32px; max-height: 32px;"/>
</xul:vbox>
<xul:vbox pack="start" flex="1">
<xul:hbox>
<xul:label class="extension-item-name" xbl:inherits="value=name" crop="center"/>
<xul:label class="extension-item-version" xbl:inherits="value=version"/>
</xul:hbox>
<xul:label class="extension-item-status" crop="right">&extensionItem.waiting.label;</xul:label>
</xul:vbox>
</xul:hbox>
</content>
<implementation>
<field name="eventPrefix">"extension-"</field>
</implementation>
</binding>
<binding id="theme-downloading" extends="chrome://mozapps/content/shared/richview.xml#richview-item">
<resources>
<stylesheet src="chrome://mozapps/skin/extensions/extensions.css"/>
</resources>
<content>
<xul:hbox flex="1">
<xul:vbox pack="start">
<xul:image class="extension-icon" xbl:inherits="src=image"
style="width: 32px; max-width: 32px; height: 32px; max-height: 32px;"/>
</xul:vbox>
<xul:vbox pack="start" flex="1">
<xul:hbox>
<xul:label class="extension-item-name" xbl:inherits="value=name" crop="center"/>
<xul:label class="extension-item-version" xbl:inherits="value=version"/>
</xul:hbox>
<xul:progressmeter class="extension-item-progress" xbl:inherits="value=progress"/>
</xul:vbox>
</xul:hbox>
</content>
<implementation>
<field name="eventPrefix">"extension-"</field>
</implementation>
</binding>
<binding id="theme-installing" extends="chrome://mozapps/content/shared/richview.xml#richview-item">
<resources>
<stylesheet src="chrome://mozapps/skin/extensions/extensions.css"/>
</resources>
<content>
<xul:hbox flex="1">
<xul:vbox pack="start">
<xul:image class="extension-icon" xbl:inherits="src=image"
style="width: 32px; max-width: 32px; height: 32px; max-height: 32px;"/>
</xul:vbox>
<xul:vbox pack="start" flex="1">
<xul:hbox>
<xul:label class="extension-item-name" xbl:inherits="value=name" crop="center"/>
<xul:label class="extension-item-version" xbl:inherits="value=version"/>
</xul:hbox>
<xul:label class="extension-item-status" crop="right">&extensionItem.installing.label;</xul:label>
</xul:vbox>
</xul:hbox>
</content>
<implementation>
<field name="eventPrefix">"extension-"</field>
</implementation>
</binding>
<binding id="theme-done" extends="chrome://mozapps/content/shared/richview.xml#richview-item">
<resources>
<stylesheet src="chrome://mozapps/skin/extensions/extensions.css"/>
</resources>
<content>
<xul:hbox flex="1">
<xul:vbox pack="start">
<xul:image class="extension-icon" xbl:inherits="src=image"
style="width: 32px; max-width: 32px; height: 32px; max-height: 32px;"/>
</xul:vbox>
<xul:vbox pack="start" flex="1">
<xul:hbox>
<xul:label class="extension-item-name" xbl:inherits="value=name" crop="center"/>
<xul:label class="extension-item-version" xbl:inherits="value=version"/>
</xul:hbox>
<xul:label class="extension-item-status" crop="right">&extensionItem.done.label;</xul:label>
</xul:vbox>
</xul:hbox>
</content>
<implementation>
<field name="eventPrefix">"extension-"</field>
</implementation>
</binding>
</bindings>

Просмотреть файл

@ -153,74 +153,77 @@
<triple subject="?extension"
predicate="http://www.mozilla.org/2004/em-rdf#version"
object="?version"/>
<triple id="typeCondition" subject="?extension"
predicate="http://www.mozilla.org/2004/em-rdf#type"
object="2" parsetype="Integer"/>
</conditions>
<bindings>
<binding subject="?extension"
predicate="http://www.mozilla.org/2004/em-rdf#creator"
object="?creator"/>
predicate="http://www.mozilla.org/2004/em-rdf#iconURL"
object="?icon"/>
<binding subject="?extension"
predicate="http://www.mozilla.org/2004/em-rdf#iconURL"
object="?icon"/>
predicate="http://www.mozilla.org/2004/em-rdf#previewImage"
object="?previewImage"/>
<binding subject="?extension"
predicate="http://www.mozilla.org/2004/em-rdf#previewImage"
object="?previewImage"/>
predicate="http://www.mozilla.org/2004/em-rdf#optionsURL"
object="?options-url"/>
<binding subject="?extension"
predicate="http://www.mozilla.org/2004/em-rdf#optionsURL"
object="?options-url"/>
predicate="http://www.mozilla.org/2004/em-rdf#aboutURL"
object="?about-url"/>
<binding subject="?extension"
predicate="http://www.mozilla.org/2004/em-rdf#aboutURL"
object="?about-url"/>
predicate="http://www.mozilla.org/2004/em-rdf#updateURL"
object="?update-url"/>
<binding subject="?extension"
predicate="http://www.mozilla.org/2004/em-rdf#updateURL"
object="?update-url"/>
predicate="http://www.mozilla.org/2004/em-rdf#disabled"
object="?disabled"/>
<binding subject="?extension"
predicate="http://www.mozilla.org/2004/em-rdf#disabled"
object="?disabled"/>
predicate="http://www.mozilla.org/2004/em-rdf#compatible"
object="?compatible"/>
<binding subject="?extension"
predicate="http://www.mozilla.org/2004/em-rdf#compatible"
object="?compatible"/>
predicate="http://www.mozilla.org/2004/em-rdf#homepageURL"
object="?homepage-url"/>
<binding subject="?extension"
predicate="http://www.mozilla.org/2004/em-rdf#homepageURL"
object="?homepage-url"/>
predicate="http://www.mozilla.org/2004/em-rdf#description"
object="?description"/>
<binding subject="?extension"
predicate="http://www.mozilla.org/2004/em-rdf#description"
object="?description"/>
predicate="http://www.mozilla.org/2004/em-rdf#displayDescription"
object="?displayDescription"/>
<binding subject="?extension"
predicate="http://www.mozilla.org/2004/em-rdf#displayDescription"
object="?displayDescription"/>
predicate="http://www.mozilla.org/2004/em-rdf#locked"
object="?locked"/>
<binding subject="?extension"
predicate="http://www.mozilla.org/2004/em-rdf#locked"
object="?locked"/>
predicate="http://www.mozilla.org/2004/em-rdf#toBeInstalled"
object="?toBeInstalled"/>
<binding subject="?extension"
predicate="http://www.mozilla.org/2004/em-rdf#toBeInstalled"
object="?toBeInstalled"/>
predicate="http://www.mozilla.org/2004/em-rdf#toBeUpgraded"
object="?toBeUpgraded"/>
<binding subject="?extension"
predicate="http://www.mozilla.org/2004/em-rdf#toBeUninstalled"
object="?toBeUninstalled"/>
predicate="http://www.mozilla.org/2004/em-rdf#toBeUninstalled"
object="?toBeUninstalled"/>
<binding subject="?extension"
predicate="http://www.mozilla.org/2004/em-rdf#toBeEnabled"
object="?toBeEnabled"/>
predicate="http://www.mozilla.org/2004/em-rdf#toBeEnabled"
object="?toBeEnabled"/>
<binding subject="?extension"
predicate="http://www.mozilla.org/2004/em-rdf#toBeDisabled"
object="?toBeDisabled"/>
predicate="http://www.mozilla.org/2004/em-rdf#toBeDisabled"
object="?toBeDisabled"/>
<binding subject="?extension"
predicate="http://www.mozilla.org/2004/em-rdf#itemType"
object="?itemType"/>
predicate="http://www.mozilla.org/2004/em-rdf#internalName"
object="?internalName"/>
<binding subject="?extension"
predicate="http://www.mozilla.org/2004/em-rdf#internalName"
object="?internalName"/>
predicate="http://www.mozilla.org/2004/em-rdf#downloadURL"
object="?downloadURL"/>
<binding subject="?extension"
predicate="http://www.mozilla.org/2004/em-rdf#downloadURL"
object="?downloadURL"/>
predicate="http://www.mozilla.org/2004/em-rdf#state"
object="?state"/>
<binding subject="?extension"
predicate="http://www.mozilla.org/2004/em-rdf#state"
object="?state"/>
predicate="http://www.mozilla.org/2004/em-rdf#progress"
object="?progress"/>
<binding subject="?extension"
predicate="http://www.mozilla.org/2004/em-rdf#progress"
object="?progress"/>
predicate="http://www.mozilla.org/2004/em-rdf#status"
object="?status"/>
<binding subject="?extension"
predicate="http://www.mozilla.org/2004/em-rdf#status"
object="?status"/>
predicate="http://www.mozilla.org/2004/em-rdf#hidden"
object="?hidden"/>
</bindings>
<action>
<!-- XXXben - we could really use a variety of different templates
@ -229,13 +232,14 @@
image="?icon" name="?name" version="?version"
description="?displayDescription" creator="?creator"
disabled="?disabled" locked="?locked"
compatible="?compatible"
compatible="?compatible" hidden="?hidden"
optionsURL="?options-url" homepageURL="?homepage-url"
aboutURL="?about-url" updateURL="?update-url"
previewImage="?previewImage" internalName="?internalName"
toBeInstalled="?toBeInstalled" toBeUninstalled="?toBeUninstalled"
toBeEnabled="?toBeEnabled" toBeDisabled="?toBeDisabled"
itemType="?itemType" downloadURL="?downloadURL"
toBeUpgraded="?toBeUpgraded"
downloadURL="?downloadURL"
state="?state" progress="?progress" status="?status"/>
</action>
</rule>

Просмотреть файл

@ -19,7 +19,7 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Ben Goodger <ben@bengoodger.com>
* Ben Goodger <ben@mozilla.org> (Google Inc.)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -42,80 +42,398 @@ interface nsIFile;
interface nsIRDFDataSource;
interface nsIUpdateItem;
interface nsICommandLine;
interface nsISimpleEnumerator;
interface nsIDirectoryEnumerator;
[scriptable, uuid(9048223f-ec50-49e5-9866-80ee8f26179d)]
interface nsIExtensionDownloadProgressListener : nsISupports
/**
* Interface representing a location where extensions, themes etc are
* installed.
*/
[scriptable, uuid(a93bc6e0-b841-4f34-ac33-6b1cef1f4742)]
interface nsIInstallLocation : nsISupports
{
void onStateChange(in wstring aURL, in short aState, in long aValue);
/**
* The string identifier of this Install Location
*/
readonly attribute AString name;
/**
* An enumeration of nsIFiles for:
* - locations that contain items
* - potential dropped-in XPIs
* Note: This enumeration resolves Text Links to the directories they
* refer to.
*/
readonly attribute nsIDirectoryEnumerator itemLocations;
void onProgress(in wstring aURL, in unsigned long aValue, in unsigned long aMaxValue);
/**
* The file system location where items live. Items can be dropped in
* at this location. Can be null for Install Locations that don't have
* a file system presence.
* Note: This is a clone of the actual location which the caller can
* modify freely.
*/
readonly attribute nsIFile location;
/**
* Whether or not this Install Location is on an area of the file system
* that could be restricted on a restricted-access account, regardless
* of whether or not the location is restricted with the current user
* privileges.
*/
readonly attribute boolean restricted;
/**
* Whether or not the user can write to the Install Location with the
* current access privileges. This is different from restricted because
* it's not whether or not the location *might* be restricted, it's
* whether or not it actually *is* restricted right now.
*/
readonly attribute boolean canAccess;
/**
* Whether or not the install location is functioning properly. If the
* location is not functioning properly, this probably suggests the
* user has deleted files/registry keys etc by hand and we need to
* flush the various data sets and rebuild them.
* e.g. for a Directory Install Location this is whether or not the
* directory that contains the items exists. For a registry based
* location this is whether or not the key exists.
*/
readonly attribute boolean isFunctioning;
/**
* Constants representing priority of some default Install Locations.
* XXXben - priority ranking of user-level items vs. global-level items
* here is debatable. Should app-system-global trump
* xre-system-user?
* You should not use the exact values here, you should offset from
* these values each time you create a new Install Location. Offsetting
* can be brittle but you should know what Install Locations are being
* defined for your own application.
*/
const unsigned long PRIORITY_APP_PROFILE = 0;
const unsigned long PRIORITY_APP_SYSTEM_USER = 10;
const unsigned long PRIORITY_XRE_SYSTEM_USER = 100;
const unsigned long PRIORITY_APP_SYSTEM_GLOBAL = 1000;
const unsigned long PRIORITY_XRE_SYSTEM_GLOBAL = 10000;
/**
* The priority level of this Install Location in loading.
*/
readonly attribute long priority;
/**
* Gets the directory that contains an item.
* @param id
* The GUID of the item.
* @returns The location of the item.
*/
nsIFile getItemLocation(in AString id);
/**
* Gets a nsIFile object for a file within an item's directory structure.
* @param id
* The GUID of the item.
* @param path
* The path to the file beneath an Extension's directory
* @returns A file object at the requested location. The file does not
* necessarily have to exist.
*/
nsIFile getItemFile(in AString id, in AString path);
};
[scriptable, uuid(1a1e274d-c675-4177-99d3-4d153d1b795e)]
/**
* Interface for handling download and install notifications for Extensions
* and Themes.
*/
[scriptable, uuid(9048223f-ec50-49e5-9866-80ee8f26179d)]
interface nsIExtensionDownloadListener : nsISupports
{
/**
* Install/Download state has changed
* @param url
* The url that state changed for
* @param state
* The new state. States are defined in nsIXPIProgressDialog
* @param value
* Some data about the new state
*/
void onStateChange(in AString url, in short state, in long value);
/**
* Progress occurred in the download/install operation
* @param url
* The url that progress occurred for
* @param value
* The value of the current progress
* @param maxValue
* The maximum value |value| can reach
*/
void onProgress(in AString url, in unsigned long value,
in unsigned long maxValue);
};
/**
* Interface representing a system for the installation and management of
* Extensions, Themes etc.
*
* XXXben - Some of this stuff should go into a management-ey interface,
* some into an app-startup-ey interface.
*/
[scriptable, uuid(7b77761f-6737-4b77-abed-c82f35a57a90)]
interface nsIExtensionManager : nsISupports
{
// Apprunner hooks
boolean start(in nsICommandLine aCmdLine, in boolean aIsDirty);
/**
* Starts the Extension Manager, initializing Safe Mode, checking for
* item changes, additions and removals, and finishing pending operations.
* @param commandLine
* The command line the application was started with.
* @param isDirty
* Whether or not the extensions list changed since the last start.
* This is not the last word in whether or not items have been
* added or removed since it only tracks items installed through
* the UI.
* @returns true if the application has rewritten the extensions.ini file
* and needs to restart to register components/chrome etc,
* false otherwise
*/
boolean start(in nsICommandLine commandLine, in boolean isDirty);
/**
* Returns true if mismatches were found and the app needs to restart.
* Determines if there are incompatible items installed (and offers to
* upgrade them to newer versions if available, via a UI).
* @returns true if there were incompatible items that were disabled
* and the application needs to restart to re-register components,
* chrome etc, false otherwise.
*/
boolean checkForMismatches();
/**
* Handle command line flags, e.g. -install-global-[extension|theme]
* @param cmdLine
* the command line the application was started with
* XXXben - move this off this API - currently it is only used for
* global installation, and the apprunner can do this directly
* with |installItemFromFile|
*/
void handleCommandLineArgs(in nsICommandLine cmdline);
void register();
/**
* Gets the Install Location for an item
* @param id
* The GUID of the item
* @returns The Install Location where the item is installed.
*/
nsIInstallLocation getInstallLocation(in AString id);
// Installing Extensions
const unsigned long FLAG_INSTALL_PROFILE = 0x01;
const unsigned long FLAG_INSTALL_GLOBAL = 0x02;
/**
* An enumeration of all registered Install Items
*/
readonly attribute nsISimpleEnumerator installLocations;
void installExtension(in nsIFile aXPIFile, in unsigned long aFlags);
void uninstallExtension(in string aExtensionID);
void enableExtension(in string aExtensionID);
void disableExtension(in string aExtensionID);
/**
* Installs an item from a XPI/JAR file into the location specified.
* @param xpiFile
* The source file to install from. This function stages a copy
* of this file for persistence across potential application
* restarts, you are responsible for removing the file you pass
* in.
* @param installLocationKey
* The name identifier of an Install Location to install into.
*/
void installItemFromFile(in nsIFile xpiFile, in AString installLocationKey);
// Installing Themes
void installTheme(in nsIFile aJARFile, in unsigned long aFlags);
void uninstallTheme(in string aThemeID);
void enableTheme(in string aThemeID);
void disableTheme(in string aThemeID);
/**
* Uninstalls an item
* @param id
* The GUID of the item.
*/
void uninstallItem(in AString id);
// Downloads
void addDownloads([array, size_is(aItemCount)] in nsIUpdateItem aItems,
in unsigned long aItemCount);
void removeDownload(in wstring aURL, in unsigned short aType);
long addDownloadObserver(in nsIExtensionDownloadProgressListener aObserver);
void removeDownloadObserverAt(in long aIndex);
/**
* Enables a disabled item
* @param id
* The GUID of the item.
*/
void enableItem(in AString id);
/**
* Disables an enabled item
* @param id
* The GUID of the item.
*/
void disableItem(in AString id);
/**
* Checks for updates to a list of items.
* @param items
* An array of nsIUpdateItems to check for updates for.
* @param itemCount
* The length of |items|
* @param versionUpdateOnly
* false if this check should find the newest versions available,
* true if it should only find newer target application compatibility
* information for the currently installed version.
*/
void update([array, size_is(itemCount)] in nsIUpdateItem items,
in unsigned long itemCount,
in unsigned long versionUpdateOnly);
/**
* Whether or not the application is currently in safe mode.
*/
readonly attribute boolean inSafeMode;
// Updates
void update([array, size_is(aItemCount)] in nsIUpdateItem aItems,
in unsigned long aItemCount,
in unsigned long aVersionUpdateOnly);
/**
* Gets a nsIUpdateItem for the item with the specified id.
* @param id
* The GUID of the item to construct a nsIUpdateItem for.
* @returns The nsIUpdateItem representing the item.
*/
nsIUpdateItem getItemForID(in AString id);
// Management
void getItemList(in string aItemID,
in unsigned short aType,
out unsigned long aItemCount,
[retval, array, size_is(aItemCount)] out nsIUpdateItem aItems);
void moveUp(in string aItemID);
void moveDown(in string aItemID);
void moveTop(in string aItemID);
/**
* Retrieves a list of visible nsIUpdateItems of items matching the
* specified type.
* @param type
* The type of item to return.
* @param countRef
* The XPCJS reference to the number of items returned.
* @returns An array of nsIUpdateItems matching the id/type filter.
*
* XXXben - it would be good if this function took an optional
* install location.
*/
void getItemList(in unsigned long type, out unsigned long itemCount,
[retval, array, size_is(itemCount)] out nsIUpdateItem items);
/**
* The Extensions Datasource
* XXXben - the datasource should be registered with the RDF system, so it
* can be accessed via rdf:extensions, and not exposed through the API
* like this.
*/
readonly attribute nsIRDFDataSource datasource;
/**
* Adds active download entries to the UI
* @param items
* A list of nsIUpdateItems to entries to add
* @param itemCount
* The length of |items|
*/
void addDownloads([array, size_is(itemCount)] in nsIUpdateItem items,
in unsigned long itemCount);
/**
* Removes an active download from the UI
* @param url
* The URL of the active download to remove
*/
void removeDownload(in AString url);
/**
* Adds a download progress listener so the front end can listen to download
* and install progress.
* @param listener
* The listener to add
* @returns the index of the added listen in the listener list.
*/
long addDownloadListener(in nsIExtensionDownloadListener listener);
/**
* Removes a download progress listener.
* @param index
* The index of the listener to remove.
*/
void removeDownloadListenerAt(in long index);
/**
/**
* Move an item up a notch in its container
* @param id
* The GUID of the item to move
*/
void moveUp(in AString id);
/**
* Move an item down a notch in its container
* @param id
* The GUID of the item to move
*/
void moveDown(in AString id);
/**
* Move an item to the start of its container.
* @param id
* The GUID of the item to move
*/
void moveTop(in AString id);
};
/**
* Interface representing an object that can update a set of Extensions,
* Themes etc.
*/
[scriptable, uuid(c0b7517f-0b3a-41a2-bde8-ba3ac8a5af47)]
interface nsIExtensionItemUpdater : nsISupports
{
void checkForUpdates([array, size_is(aItemCount)] in nsIUpdateItem aItems,
in unsigned long aItemCount,
in boolean aVersionUpdateOnly);
/**
* Checks for updates to a list of items.
* @param items
* An array of nsIUpdateItems to check for updates for.
* @param itemCount
* The length of |items|
* @param versionUpdateOnly
* false if this check should find the newest versions available,
* true if it should only find newer target application compatibility
* information for the currently installed version.
*/
void checkForUpdates([array, size_is(itemCount)] in nsIUpdateItem items,
in unsigned long itemCount,
in boolean versionUpdateOnly);
/**
* The event that spawned the update check. Types defined in
* nsIUpdateService
*/
readonly attribute unsigned short sourceEvent;
readonly attribute unsigned short updateTypes;
/**
* The nsIUpdateItem types being checked for updates to.
*/
readonly attribute unsigned long updateTypes;
};
%{ C++
/**
* Install Location Key for Application-Global Items
*/
#define NS_INSTALL_LOCATION_APPGLOBAL NS_LITERAL_STRING("app-global")
/**
* Install Location Key for Application-Profile Items
*/
#define NS_INSTALL_LOCATION_APPPROFILE NS_LITERAL_STRING("app-profile")
/**
* The category that contains a list of contract-ids to Install Location
* services.
*/
#define CATEGORY_INSTALL_LOCATIONS "extension-install-locations"
/**
* The observer topic to listen to for actions performed on installed
* items.
*/
#define EM_ACTION_REQUESTED_TOPIC "em-action-requested"
#define EM_ITEM_INSTALLED "item-installed"
#define EM_ITEM_UPGRADED "item-upgraded"
#define EM_ITEM_UNINSTALLED "item-uninstalled"
#define EM_ITEM_ENABLED "item-enabled"
#define EM_ITEM_DISABLED "item-disabled"
%}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -16,13 +16,12 @@
#
# The Original Code is the Rich ScrollView.
#
# The Initial Developer of the Original Code is
# Ben Goodger.
# The Initial Developer of the Original Code is Ben Goodger.
# Portions created by the Initial Developer are Copyright (C) 2003-2004
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Ben Goodger <ben@bengoodger.com>
# Ben Goodger <ben@mozilla.org> (Google Inc.)
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
@ -109,7 +108,7 @@
<body>
<![CDATA[
for (var temp = aElement; temp; temp = temp.nextSibling) {
if ("fireEvent" in temp) {
if ("fireEvent" in temp && !temp.hidden) {
this.selected = temp;
break;
}
@ -123,7 +122,7 @@
<body>
<![CDATA[
for (var temp = aElement; temp; temp = temp.previousSibling) {
if ("fireEvent" in temp) {
if ("fireEvent" in temp && !temp.hidden) {
this.selected = temp;
break;
}

Просмотреть файл

@ -51,6 +51,14 @@
<script type="application/x-javascript">
<![CDATA[
function LOG(string)
{
dump("*** " + string + "\n");
var console = Components.classes["@mozilla.org/consoleservice;1"]
.getService(Components.interfaces.nsIConsoleService);
console.logStringMessage(string);
}
function init()
{
var state = window.arguments[0].state;
@ -65,6 +73,11 @@
var listbox = document.getElementById("extensions");
for (var i = 0; i < items.length; ++i) {
if (items[i].error) {
if (items[i].error == -207) {
LOG("Error -207 (\"Not a valid install package\") generally implies\r\n" +
"a 404 at the URL specified for the update. Check for typos in\r\n" +
"your update manifest.");
}
var listitem = document.createElement("listitem");
try {
var errorString = xpinstallStrings.getString("error" + items[i].error);

Просмотреть файл

@ -78,7 +78,6 @@
const nsIUpdateItem = Components.interfaces.nsIUpdateItem;
const nsIUpdateService = Components.interfaces.nsIUpdateService;
const nsIExtensionManager = Components.interfaces.nsIExtensionManager;
const PREF_UPDATE_APP_UPDATESAVAILABLE = "app.update.updatesAvailable";
const PREF_UPDATE_APP_PERFORMED = "app.update.performed";
@ -271,7 +270,8 @@ var gUpdateWizard = {
{
var errors = [];
for (var i = 0; i < this.errorItems.length; ++i)
errors.push({ name: this.errorItems[i].name, error: true });
errors.push({ name: this.errorItems[i].name, error: true,
item: this.errorItems[i] });
if (this.errorOnApp) {
var brandShortName = document.getElementById("brandStrings").getString("brandShortName");
@ -371,9 +371,9 @@ var gUpdatePage = {
this._totalCount = gUpdateWizard.items.length;
if (this._totalCount == 0) {
var em = Components.classes["@mozilla.org/extensions/manager;1"]
.getService(Components.interfaces.nsIExtensionManager);
var extensionCount = em.getItemList(null, nsIUpdateItem.TYPE_EXTENSION, {}).length;
var themeCount = em.getItemList(null, nsIUpdateItem.TYPE_THEME, {}).length;
.getService(Components.interfaces.nsIExtensionManager);
var extensionCount = em.getItemList(nsIUpdateItem.TYPE_EXTENSION, {}).length;
var themeCount = em.getItemList(nsIUpdateItem.TYPE_THEME, {}).length;
this._totalCount = extensionCount + themeCount + 1;
}

Просмотреть файл

@ -41,54 +41,106 @@
interface nsIDOMWindowInternal;
[scriptable, uuid(37648f86-0f77-4007-929e-673a75d5438f)]
/**
* An item managed by the Extension or Software Update System. Contains
* metadata that describes the item.
*/
[scriptable, uuid(415edb0a-4f2d-485c-9e10-f262b065ab33)]
interface nsIUpdateItem : nsISupports
{
readonly attribute string id;
readonly attribute string version;
readonly attribute string minAppVersion;
readonly attribute string maxAppVersion;
readonly attribute wstring name;
readonly attribute long row;
readonly attribute wstring xpiURL;
readonly attribute wstring iconURL;
readonly attribute wstring updateRDF;
/**
* The GUID of the item.
*/
readonly attribute AString id;
/**
* The Version of the item, in FVF format.
*/
readonly attribute AString version;
/**
* The minimum version of the application that this item works with,
* in FVF format.
*/
readonly attribute AString minAppVersion;
/**
* The maximum version of the application that this item works with,
* in FVF format.
*/
readonly attribute AString maxAppVersion;
/**
* The name of the Install Location where this item is installed.
*/
readonly attribute AString installLocationKey;
/**
* The name of this item.
*/
readonly attribute AString name;
/**
* The URL of the XPI where this item can be downloaded.
*/
readonly attribute AString xpiURL;
/**
* The URL of the icon that can be shown for this item.
*/
readonly attribute AString iconURL;
/**
* The URL of the update RDF file for this item.
*/
readonly attribute AString updateRDF;
const unsigned short TYPE_APP = 0x01;
const unsigned short TYPE_EXTENSION = 0x02;
const unsigned short TYPE_THEME = 0x04;
const unsigned short TYPE_LOCALE = 0x08;
const unsigned short TYPE_ADDON = TYPE_EXTENSION + TYPE_THEME + TYPE_LOCALE;
const unsigned short TYPE_ANY = TYPE_APP + TYPE_ADDON;
const unsigned long TYPE_APP = 0x01;
const unsigned long TYPE_EXTENSION = 0x02;
const unsigned long TYPE_THEME = 0x04;
const unsigned long TYPE_LOCALE = 0x08;
const unsigned long TYPE_PLUGIN = 0x10;
const unsigned long TYPE_ADDON = TYPE_EXTENSION + TYPE_THEME + TYPE_LOCALE + TYPE_PLUGIN;
const unsigned long TYPE_ANY = TYPE_APP + TYPE_ADDON;
readonly attribute long type;
/**
* The type of this item.
*/
readonly attribute long type;
void init(in string aID, in string aVersion, in string aMinAppVersion,
in string aMaxAppVersion, in wstring aName,
in long aRow, in wstring aUpdateURL, in wstring aIconURL,
in wstring aUpdateRDF, in long aType);
/**
* Initializes this Item object.
*/
void init(in AString aID, in AString aVersion,
in AString aInstallLocationKey, in AString aMinAppVersion,
in AString aMaxAppVersion, in AString aName,
in AString aUpdateURL, in AString aIconURL,
in AString aUpdateRDF, in long aType);
readonly attribute wstring objectSource;
/**
* Returns a JS Object source representing an nsIUpdateItem.
*/
readonly attribute AString objectSource;
};
[scriptable, uuid(24aee3ca-a274-4247-bd3b-d0acbb5a98aa)]
interface nsIAppUpdateInfoItem : nsISupports
{
readonly attribute wstring internalName;
readonly attribute wstring name;
readonly attribute wstring URL;
readonly attribute wstring infoURL;
readonly attribute wstring description;
readonly attribute AString internalName;
readonly attribute AString name;
readonly attribute AString URL;
readonly attribute AString infoURL;
readonly attribute AString description;
};
[scriptable, uuid(2daab124-9bc7-4c35-bb7b-0fecdea03ce8)]
interface nsIAppUpdateInfo : nsISupports
{
readonly attribute wstring updateVersion;
readonly attribute wstring updateDisplayVersion;
readonly attribute wstring updateInfoURL;
readonly attribute AString updateVersion;
readonly attribute AString updateDisplayVersion;
readonly attribute AString updateInfoURL;
void getCollection(in string aCollectionName, out unsigned long aItemCount,
void getCollection(in AString aCollectionName, out unsigned long aItemCount,
[retval, array, size_is(aItemCount)] out nsIAppUpdateInfoItem aItems);
};
@ -132,8 +184,8 @@ interface nsIVersionChecker : nsISupports
// -ve if B is newer
// equal if A == B
// +ve if A is newer
long compare(in string aVersionA, in string aVersionB);
long compare(in AString aVersionA, in AString aVersionB);
boolean isValidVersion(in string aVersion);
boolean isValidVersion(in AString aVersion);
};

Просмотреть файл

@ -962,50 +962,50 @@ function UpdateItem ()
UpdateItem.prototype = {
init: function UpdateItem_init (aID,
aVersion,
aInstallLocationKey,
aMinAppVersion,
aMaxAppVersion,
aName,
aRow,
aXPIURL,
aIconURL,
aUpdateRDF,
aType)
{
this._id = aID;
this._version = aVersion;
this._minAppVersion = aMinAppVersion;
this._maxAppVersion = aMaxAppVersion;
this._name = aName;
this._row = aRow;
this._xpiURL = aXPIURL;
this._iconURL = aIconURL;
this._updateRDF = aUpdateRDF;
this._type = aType;
this._id = aID;
this._version = aVersion;
this._installLocationKey = aInstallLocationKey;
this._minAppVersion = aMinAppVersion;
this._maxAppVersion = aMaxAppVersion;
this._name = aName;
this._xpiURL = aXPIURL;
this._iconURL = aIconURL;
this._updateRDF = aUpdateRDF;
this._type = aType;
},
get id() { return this._id; },
get version() { return this._version; },
get minAppVersion() { return this._minAppVersion; },
get maxAppVersion() { return this._maxAppVersion; },
get name() { return this._name; },
get row() { return this._row; },
get xpiURL() { return this._xpiURL; },
get iconURL() { return this._iconURL },
get updateRDF() { return this._updateRDF; },
get type() { return this._type; },
get id() { return this._id; },
get version() { return this._version; },
get installLocationKey(){ return this._installLocationKey;},
get minAppVersion() { return this._minAppVersion; },
get maxAppVersion() { return this._maxAppVersion; },
get name() { return this._name; },
get xpiURL() { return this._xpiURL; },
get iconURL() { return this._iconURL },
get updateRDF() { return this._updateRDF; },
get type() { return this._type; },
get objectSource()
{
return { id : this._id,
version : this._version,
minAppVersion : this._minAppVersion,
maxAppVersion : this._maxAppVersion,
name : this._name,
row : this._row,
xpiURL : this._xpiURL,
iconURL : this._iconURL,
updateRDF : this._updateRDF,
type : this._type
return { id : this._id,
version : this._version,
installLocationKey : this._installLocationKey,
minAppVersion : this._minAppVersion,
maxAppVersion : this._maxAppVersion,
name : this._name,
xpiURL : this._xpiURL,
iconURL : this._iconURL,
updateRDF : this._updateRDF,
type : this._type
}.toSource();
},
@ -1148,20 +1148,7 @@ nsVersionChecker.prototype = {
isValidVersion: function nsVersionChecker_isValidVersion (aVersion)
{
var parts = aVersion.split(".");
if (parts.length == 0)
return false;
for (var i = 0; i < parts.length; ++i) {
var part = parts[i];
if (i == parts.length - 1) {
if (part.lastIndexOf("+") != -1)
parts[i] = part.substr(0, part.length - 1);
}
var integer = parseInt(part);
if (isNaN(integer))
return false;
}
return true;
return /^([0-9]\.){1,3}[0-9]\+?$/.test(aVersion);
},
/////////////////////////////////////////////////////////////////////////////

Просмотреть файл

@ -73,7 +73,13 @@ XPInstallConfirm.init = function ()
var introString = bundle.getString("itemWarningIntroSingle");
if (numItemsToInstall > 4)
introString = bundle.getFormattedString("itemWarningIntroMultiple", [numItemsToInstall / 4]);
document.getElementById("itemWarningIntro").setAttribute("value", introString);
if (this._param.objects && this._param.objects.length)
introString = this._param.objects.queryElementAt(0, Components.interfaces.nsISupportsString).data;
var textNode = document.createTextNode(introString);
var introNode = document.getElementById("itemWarningIntro");
while (introNode.hasChildNodes())
introNode.removeChild(introNode.firstChild);
introNode.appendChild(textNode);
var okButton = document.documentElement.getButton("accept");
okButton.label = bundle.getFormattedString("installButtonDisabledLabel", [this._installCountdown]);

Просмотреть файл

@ -1631,14 +1631,6 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
NS_ENSURE_TRUE(chromeReg, 1);
chromeReg->CheckForNewChrome();
if (gAppData->flags & NS_XRE_ENABLE_EXTENSION_MANAGER) {
nsCOMPtr<nsIExtensionManager> em
(do_GetService("@mozilla.org/extensions/manager;1"));
NS_ENSURE_TRUE(em, 1);
em->Register();
}
}
return 0;
}
@ -1884,9 +1876,7 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
nsCOMPtr<nsIExtensionManager> em(do_GetService("@mozilla.org/extensions/manager;1"));
NS_ENSURE_TRUE(em, 1);
if (CheckArg("install-global-extension") ||
CheckArg("install-global-theme") || CheckArg("list-global-items") ||
CheckArg("lock-item") || CheckArg("unlock-item")) {
if (CheckArg("install-global-extension") || CheckArg("install-global-theme")) {
// Do the required processing and then shut down.
em->HandleCommandLineArgs(cmdLine);
return 0;

Просмотреть файл

@ -368,35 +368,41 @@ LoadDirsIntoArray(nsIFile* aComponentsList, const char* aSection,
nsCOMPtr<nsILocalFile> lf(do_QueryInterface(aComponentsList));
parser.Init(lf);
nsresult rv;
char parserBuf[MAXPATHLEN];
nsresult rv = parser.GetString(aSection, "Count", parserBuf, MAXPATHLEN);
if (NS_SUCCEEDED(rv)) {
PRInt32 count = atoi(parserBuf);
char buf[18];
nsCOMPtr<nsIFile> parent;
aComponentsList->GetParent(getter_AddRefs(parent));
nsCOMPtr<nsILocalFile> lfParent (do_QueryInterface(parent));
char buf[18];
PRInt32 i = 0;
do {
sprintf(buf, "Extension%d", i++);
for (PRInt32 i = 0; i < count; ++i) {
sprintf(buf, "Extension%d", i);
rv = parser.GetString(aSection, buf, parserBuf, MAXPATHLEN);
if (NS_FAILED(rv))
break;
rv = parser.GetString(aSection, buf, parserBuf, MAXPATHLEN);
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsILocalFile> dir(do_CreateInstance("@mozilla.org/file/local;1"));
dir->SetRelativeDescriptor(lfParent, nsDependentCString(parserBuf));
const char* const* a = aAppendList;
while (*a) {
dir->AppendNative(nsDependentCString(*a));
++a;
}
PRBool exists;
rv = dir->Exists(&exists);
if (NS_SUCCEEDED(rv) && exists)
aDirectories.AppendObject(dir);
}
nsCOMPtr<nsILocalFile> dir(do_CreateInstance("@mozilla.org/file/local;1"));
rv = dir->SetPersistentDescriptor(nsDependentCString(parserBuf));
if (NS_FAILED(rv)) {
// Must be a relative descriptor, relative to the profile directory,
// try that instead.
nsCOMPtr<nsIFile> profileDir;
aComponentsList->GetParent(getter_AddRefs(profileDir));
nsCOMPtr<nsILocalFile> lfProfileDir(do_QueryInterface(profileDir));
rv = dir->SetRelativeDescriptor(lfProfileDir, nsDependentCString(parserBuf));
if (NS_FAILED(rv))
continue;
}
const char* const* a = aAppendList;
while (*a) {
dir->AppendNative(nsDependentCString(*a));
++a;
}
PRBool exists;
rv = dir->Exists(&exists);
if (NS_SUCCEEDED(rv) && exists)
aDirectories.AppendObject(dir);
}
while (PR_TRUE);
}
static const char *const kAppendChromeManifests[] =
@ -453,13 +459,6 @@ nsXREDirProvider::GetFiles(const char* aProperty, nsISimpleEnumerator** aResult)
}
static const char *const kAppendPrefDir[] = { "defaults", "preferences", nsnull };
nsCOMPtr<nsIFile> appFile;
mAppDir->Clone(getter_AddRefs(appFile));
appFile->AppendNative(NS_LITERAL_CSTRING("extensions.ini"));
LoadDirsIntoArray(appFile, "ExtensionDirs",
kAppendPrefDir, directories);
nsCOMPtr<nsIFile> profileFile;
if (mProfileDir) {
mProfileDir->Clone(getter_AddRefs(profileFile));
@ -487,12 +486,6 @@ nsXREDirProvider::GetFiles(const char* aProperty, nsISimpleEnumerator** aResult)
manifests.AppendObject(file);
}
nsCOMPtr<nsIFile> appFile;
mAppDir->Clone(getter_AddRefs(appFile));
appFile->AppendNative(NS_LITERAL_CSTRING("extensions.ini"));
LoadDirsIntoArray(appFile, "ExtensionDirs",
kAppendChromeManifests, manifests);
if (mProfileDir) {
nsCOMPtr<nsIFile> profileFile;
mProfileDir->Clone(getter_AddRefs(profileFile));
@ -506,13 +499,6 @@ nsXREDirProvider::GetFiles(const char* aProperty, nsISimpleEnumerator** aResult)
}
else if (!strcmp(aProperty, NS_SKIN_MANIFESTS_FILE_LIST)) {
nsCOMArray<nsIFile> manifests;
nsCOMPtr<nsIFile> appFile;
mAppDir->Clone(getter_AddRefs(appFile));
appFile->AppendNative(NS_LITERAL_CSTRING("extensions.ini"));
LoadDirsIntoArray(appFile, "ThemeDirs",
kAppendChromeManifests, manifests);
if (mProfileDir) {
nsCOMPtr<nsIFile> profileFile;
mProfileDir->Clone(getter_AddRefs(profileFile));

Просмотреть файл

@ -127,6 +127,7 @@ XPIDLSRCS = \
nsIBinaryInputStream.idl \
nsIBinaryOutputStream.idl \
nsIByteArrayInputStream.idl \
nsIDirectoryEnumerator.idl \
nsIFastLoadFileControl.idl \
nsIFastLoadService.idl \
nsIInputStreamTee.idl \

Просмотреть файл

@ -0,0 +1,68 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the Directory Enumerator Interface.
*
* The Initial Developer of the Original Code is Google Inc.
* Portions created by the Initial Developer are Copyright (C) 2005
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Ben Goodger <ben@mozilla.org>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
interface nsIFile;
/**
* This interface provides a means for enumerating the contents of a directory.
* It is similar to nsISimpleEnumerator except the retrieved entries are QI'ed
* to nsIFile, and there is a mechanism for closing the directory when the
* enumeration is complete.
*
* @status UNDER_REVIEW
*/
[scriptable, uuid(31f7f4ae-6916-4f2d-a81e-926a4e3022ee)]
interface nsIDirectoryEnumerator : nsISupports
{
/**
* Retrieves the next file in the sequence. The "nextFile" element is the
* first element upon the first call. This attribute is null if there is no
* next element.
*/
readonly attribute nsIFile nextFile;
/**
* Closes the directory being enumerated, releasing the system resource.
* @throws NS_OK if the call succeeded and the directory was closed.
* NS_ERROR_FAILURE if the directory close failed.
* It is safe to call this function many times.
*/
void close();
};

Просмотреть файл

@ -47,6 +47,7 @@
#include "nsNativeCharsetUtils.h"
#include "nsISimpleEnumerator.h"
#include "nsIDirectoryEnumerator.h"
#include "nsIComponentManager.h"
#include "prtypes.h"
#include "prio.h"
@ -135,7 +136,8 @@ myLL_L2II(PRInt64 result, PRInt32 *hi, PRInt32 *lo )
}
class nsDirEnumerator : public nsISimpleEnumerator
class nsDirEnumerator : public nsISimpleEnumerator,
public nsIDirectoryEnumerator
{
public:
@ -207,6 +209,8 @@ class nsDirEnumerator : public nsISimpleEnumerator
mNext = do_QueryInterface(file);
}
*result = mNext != nsnull;
if (!*result)
Close();
return NS_OK;
}
@ -224,14 +228,34 @@ class nsDirEnumerator : public nsISimpleEnumerator
return NS_OK;
}
private:
~nsDirEnumerator()
NS_IMETHOD GetNextFile(nsIFile **result)
{
if (mDir)
*result = nsnull;
PRBool hasMore = PR_FALSE;
nsresult rv = HasMoreElements(&hasMore);
if (NS_FAILED(rv) || !hasMore)
return rv;
*result = mNext;
NS_IF_ADDREF(*result);
mNext = nsnull;
return NS_OK;
}
NS_IMETHOD Close()
{
if (mDir)
{
PRStatus status = PR_CloseDir(mDir);
NS_ASSERTION(status == PR_SUCCESS, "close failed");
mDir = nsnull;
}
return NS_OK;
}
private:
~nsDirEnumerator()
{
Close();
}
protected:
@ -240,7 +264,7 @@ class nsDirEnumerator : public nsISimpleEnumerator
nsCOMPtr<nsILocalFile> mNext;
};
NS_IMPL_ISUPPORTS1(nsDirEnumerator, nsISimpleEnumerator)
NS_IMPL_ISUPPORTS2(nsDirEnumerator, nsISimpleEnumerator, nsIDirectoryEnumerator)
//---------------------------------------------------------------------
// class TypeEaEnumerator - a convenience for accessing

Просмотреть файл

@ -41,6 +41,7 @@
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsIDirectoryEnumerator.h"
#include "nsISimpleEnumerator.h"
#include "nsITimelineService.h"
#include "nsVoidArray.h"
@ -116,7 +117,8 @@ class StFollowLinksState
#pragma mark -
#pragma mark [nsDirEnumerator]
class nsDirEnumerator : public nsISimpleEnumerator
class nsDirEnumerator : public nsISimpleEnumerator,
public nsIDirectoryEnumerator
{
public:
@ -185,6 +187,8 @@ class nsDirEnumerator : public nsISimpleEnumerator
}
}
*result = mNext != nsnull;
if (!*result)
Close();
return NS_OK;
}
@ -205,13 +209,36 @@ class nsDirEnumerator : public nsISimpleEnumerator
return NS_OK;
}
NS_IMETHOD GetNextFile(nsIFile **result)
{
*result = nsnull;
PRBool hasMore = PR_FALSE;
nsresult rv = HasMoreElements(&hasMore);
if (NS_FAILED(rv) || !hasMore)
return rv;
*result = mNext;
NS_IF_ADDREF(*result);
mNext = nsnull;
return NS_OK;
}
NS_IMETHOD Close()
{
if (mIterator) {
::FSCloseIterator(mIterator);
mIterator = nsnull;
}
if (mFSRefsArray) {
nsMemory::Free(mFSRefsArray);
mFSRefsArray = nsnull;
}
return NS_OK;
}
private:
~nsDirEnumerator()
{
if (mIterator)
::FSCloseIterator(mIterator);
if (mFSRefsArray)
nsMemory::Free(mFSRefsArray);
Close();
}
protected:
@ -228,7 +255,7 @@ class nsDirEnumerator : public nsISimpleEnumerator
PRInt32 mArrayCnt, mArrayIndex;
};
NS_IMPL_ISUPPORTS1(nsDirEnumerator, nsISimpleEnumerator)
NS_IMPL_ISUPPORTS2(nsDirEnumerator, nsISimpleEnumerator, nsIDirectoryEnumerator)
#pragma mark -
#pragma mark [StAEDesc]

Просмотреть файл

@ -78,6 +78,7 @@
#include "nsIComponentManager.h"
#include "nsXPIDLString.h"
#include "prproces.h"
#include "nsIDirectoryEnumerator.h"
#include "nsISimpleEnumerator.h"
#include "nsITimelineService.h"
@ -110,7 +111,8 @@
/* directory enumerator */
class NS_COM
nsDirEnumeratorUnix : public nsISimpleEnumerator
nsDirEnumeratorUnix : public nsISimpleEnumerator,
public nsIDirectoryEnumerator
{
public:
nsDirEnumeratorUnix();
@ -121,6 +123,9 @@ nsDirEnumeratorUnix : public nsISimpleEnumerator
// nsISimpleEnumerator interface
NS_DECL_NSISIMPLEENUMERATOR
// nsIDirectoryEnumerator interface
NS_DECL_NSIDIRECTORYENUMERATOR
NS_IMETHOD Init(nsLocalFile *parent, PRBool ignored);
private:
@ -142,11 +147,10 @@ nsDirEnumeratorUnix::nsDirEnumeratorUnix() :
nsDirEnumeratorUnix::~nsDirEnumeratorUnix()
{
if (mDir)
closedir(mDir);
Close();
}
NS_IMPL_ISUPPORTS1(nsDirEnumeratorUnix, nsISimpleEnumerator)
NS_IMPL_ISUPPORTS2(nsDirEnumeratorUnix, nsISimpleEnumerator, nsIDirectoryEnumerator)
NS_IMETHODIMP
nsDirEnumeratorUnix::Init(nsLocalFile *parent, PRBool resolveSymlinks /*ignored*/)
@ -170,29 +174,20 @@ NS_IMETHODIMP
nsDirEnumeratorUnix::HasMoreElements(PRBool *result)
{
*result = mDir && mEntry;
if (!*result)
Close();
return NS_OK;
}
NS_IMETHODIMP
nsDirEnumeratorUnix::GetNext(nsISupports **_retval)
{
nsresult rv;
if (!mDir || !mEntry) {
*_retval = nsnull;
return NS_OK;
}
nsLocalFile* file = new nsLocalFile();
if (!file)
return NS_ERROR_OUT_OF_MEMORY;
if (NS_FAILED(rv = file->InitWithNativePath(mParentPath)) ||
NS_FAILED(rv = file->AppendNative(nsDependentCString(mEntry->d_name)))) {
nsCOMPtr<nsIFile> file;
nsresult rv = GetNextFile(getter_AddRefs(file));
if (NS_FAILED(rv))
return rv;
}
*_retval = NS_STATIC_CAST(nsISupports *, file);
NS_ADDREF(*_retval);
return GetNextEntry();
NS_IF_ADDREF(*_retval = file);
return NS_OK;
}
NS_IMETHODIMP
@ -214,6 +209,39 @@ nsDirEnumeratorUnix::GetNextEntry()
return NS_OK;
}
NS_IMETHODIMP
nsDirEnumeratorUnix::GetNextFile(nsIFile **_retval)
{
nsresult rv;
if (!mDir || !mEntry) {
*_retval = nsnull;
return NS_OK;
}
nsLocalFile* file = new nsLocalFile();
if (!file)
return NS_ERROR_OUT_OF_MEMORY;
if (NS_FAILED(rv = file->InitWithNativePath(mParentPath)) ||
NS_FAILED(rv = file->AppendNative(nsDependentCString(mEntry->d_name)))) {
delete file;
return rv;
}
*_retval = file;
NS_ADDREF(*_retval);
return GetNextEntry();
}
NS_IMETHODIMP
nsDirEnumeratorUnix::Close()
{
if (mDir) {
closedir(mDir);
mDir = nsnull;
}
return NS_OK;
}
nsLocalFile::nsLocalFile() :
mHaveCachedStat(PR_FALSE)
{

Просмотреть файл

@ -44,6 +44,7 @@
#include "nsMemory.h"
#include "nsLocalFile.h"
#include "nsIDirectoryEnumerator.h"
#include "nsNativeCharsetUtils.h"
#include "nsISimpleEnumerator.h"
@ -310,7 +311,8 @@ IsShortcutPath(const char *path)
// nsDirEnumerator
//-----------------------------------------------------------------------------
class nsDirEnumerator : public nsISimpleEnumerator
class nsDirEnumerator : public nsISimpleEnumerator,
public nsIDirectoryEnumerator
{
public:
@ -382,6 +384,8 @@ class nsDirEnumerator : public nsISimpleEnumerator
mNext = do_QueryInterface(file);
}
*result = mNext != nsnull;
if (!*result)
Close();
return NS_OK;
}
@ -399,15 +403,37 @@ class nsDirEnumerator : public nsISimpleEnumerator
return NS_OK;
}
// dtor can be non-virtual since there are no subclasses, but must be
// public to use the class on the stack.
~nsDirEnumerator()
NS_IMETHOD GetNextFile(nsIFile **result)
{
*result = nsnull;
PRBool hasMore = PR_FALSE;
nsresult rv = HasMoreElements(&hasMore);
if (NS_FAILED(rv) || !hasMore)
return rv;
*result = mNext;
NS_IF_ADDREF(*result);
mNext = nsnull;
return NS_OK;
}
NS_IMETHOD Close()
{
if (mDir)
{
PRStatus status = PR_CloseDir(mDir);
NS_ASSERTION(status == PR_SUCCESS, "close failed");
if (status != PR_SUCCESS)
return NS_ERROR_FAILURE;
mDir = nsnull;
}
return NS_OK;
}
// dtor can be non-virtual since there are no subclasses, but must be
// public to use the class on the stack.
~nsDirEnumerator()
{
Close();
}
protected:
@ -416,7 +442,7 @@ class nsDirEnumerator : public nsISimpleEnumerator
nsCOMPtr<nsILocalFile> mNext;
};
NS_IMPL_ISUPPORTS1(nsDirEnumerator, nsISimpleEnumerator)
NS_IMPL_ISUPPORTS2(nsDirEnumerator, nsISimpleEnumerator, nsIDirectoryEnumerator)
//-----------------------------------------------------------------------------

Просмотреть файл

@ -505,7 +505,8 @@ extern "C" void RunInstallOnThread(void *data)
nsIExtensionManager* em = installInfo->GetExtensionManager();
if (em)
{
rv = em->InstallExtension(jarpath, nsIExtensionManager::FLAG_INSTALL_PROFILE);
rv = em->InstallItemFromFile(jarpath,
NS_INSTALL_LOCATION_APPPROFILE);
if (NS_FAILED(rv))
finalStatus = nsInstall::EXECUTION_ERROR;
} else {
@ -660,7 +661,8 @@ extern "C" void RunChromeInstallOnThread(void *data)
rv = hZip->Test("install.rdf");
nsIExtensionManager* em = info->GetExtensionManager();
if (NS_SUCCEEDED(rv) && em) {
rv = em->InstallTheme(info->GetFile(), nsIExtensionManager::FLAG_INSTALL_PROFILE);
rv = em->InstallItemFromFile(info->GetFile(),
NS_INSTALL_LOCATION_APPPROFILE);
if (NS_SUCCEEDED(rv)) {
installed = PR_TRUE;
info->GetFile()->Remove(PR_FALSE);