зеркало из https://github.com/mozilla/pjs.git
170006 - show better feedback when installing/uninstalling/enable/disabling things, test out extension update.
This commit is contained in:
Родитель
eb441f872c
Коммит
11a71776d2
|
@ -19,3 +19,19 @@ extension[install-state="installing"] {
|
|||
-moz-binding: url("chrome://mozapps/content/extensions/extensions.xml#extension-installing");
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
|
|
|
@ -309,6 +309,7 @@ var gExtensionsViewController = {
|
|||
|
||||
cmd_options: function ()
|
||||
{
|
||||
if (!gExtensionsView.selected) return;
|
||||
var optionsURL = gExtensionsView.selected.getAttribute("optionsURL");
|
||||
if (optionsURL != "")
|
||||
openDialog(optionsURL, "", "chrome,modal");
|
||||
|
@ -396,7 +397,7 @@ var gExtensionsViewController = {
|
|||
|
||||
cmd_update: function ()
|
||||
{
|
||||
var id = stripPrefix(gExtensionsView.selected.id);
|
||||
var id = gExtensionsView.selected ? stripPrefix(gExtensionsView.selected.id) : null;
|
||||
var itemType = gWindowState == "extensions" ? nsIUpdateItem.TYPE_EXTENSION : nsIUpdateItem.TYPE_THEME;
|
||||
var items = gExtensionManager.getItemList(id, itemType, { });
|
||||
var updates = Components.classes["@mozilla.org/updates/update-service;1"]
|
||||
|
@ -438,56 +439,16 @@ var gExtensionsViewController = {
|
|||
gExtensionManager.uninstallTheme(stripPrefix(selectedID));
|
||||
|
||||
gExtensionsView.selected = document.getElementById(nextElement);
|
||||
|
||||
#if ANNOYING_ASS_ALERTS
|
||||
// Show an alert message telling the user they need to restart for the
|
||||
// action to take effect.
|
||||
message = extensionsStrings.getFormattedString("restartBeforeUninstallMessage",
|
||||
[gExtensionsView.selected.getAttribute("name"),
|
||||
brandStrings.getString("brandShortName")]);
|
||||
|
||||
promptSvc.alert(window, extensionsStrings.getString("restartBeforeUninstallTitle"), message);
|
||||
#endif
|
||||
},
|
||||
|
||||
cmd_disable: function ()
|
||||
{
|
||||
gExtensionManager.disableExtension(stripPrefix(gExtensionsView.selected.id));
|
||||
|
||||
#if ANNOYING_ASS_ALERTS
|
||||
// Show an alert message telling the user they need to restart for the
|
||||
// action to take effect.
|
||||
var extensionsStrings = document.getElementById("extensionsStrings");
|
||||
var brandStrings = document.getElementById("brandStrings");
|
||||
|
||||
var message = extensionsStrings.getFormattedString("restartBeforeDisableMessage",
|
||||
[gExtensionsView.selected.getAttribute("name"),
|
||||
brandStrings.getString("brandShortName")]);
|
||||
|
||||
var promptSvc = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
||||
.getService(Components.interfaces.nsIPromptService);
|
||||
promptSvc.alert(window, extensionsStrings.getString("restartBeforeDisableTitle"), message);
|
||||
#endif
|
||||
},
|
||||
|
||||
cmd_enable: function ()
|
||||
{
|
||||
gExtensionManager.enableExtension(stripPrefix(gExtensionsView.selected.id));
|
||||
|
||||
#if ANNOYING_ASS_ALERTS
|
||||
// Show an alert message telling the user they need to restart for the
|
||||
// action to take effect.
|
||||
var extensionsStrings = document.getElementById("extensionsStrings");
|
||||
var brandStrings = document.getElementById("brandStrings");
|
||||
|
||||
var message = extensionsStrings.getFormattedString("restartBeforeEnableMessage",
|
||||
[gExtensionsView.selected.getAttribute("name"),
|
||||
brandStrings.getString("brandShortName")]);
|
||||
|
||||
var promptSvc = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
||||
.getService(Components.interfaces.nsIPromptService);
|
||||
promptSvc.alert(window, extensionsStrings.getString("restartBeforeEnableTitle"), message);
|
||||
#endif
|
||||
},
|
||||
}
|
||||
};
|
||||
|
|
|
@ -37,8 +37,10 @@
|
|||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
|
||||
<!DOCTYPE window [
|
||||
<!DOCTYPE bindings [
|
||||
<!ENTITY % brandDTD SYSTEM "chrome://global/locale/brand.dtd" >
|
||||
<!ENTITY % extensionsDTD SYSTEM "chrome://mozapps/locale/extensions/extensions.dtd" >
|
||||
%brandDTD;
|
||||
%extensionsDTD;
|
||||
]>
|
||||
|
||||
|
@ -83,5 +85,109 @@
|
|||
</implementation>
|
||||
</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>
|
||||
|
||||
</bindings>
|
||||
|
||||
|
|
|
@ -121,7 +121,8 @@
|
|||
<view id="extensionsView" flex="1" style="overflow: auto;"
|
||||
datasources="rdf:null" persist="last-selected"
|
||||
ondragover="nsDragAndDrop.dragOver(event, gExtensionsDNDObserver);"
|
||||
ondragdrop="nsDragAndDrop.drop(event, gExtensionsDNDObserver);">
|
||||
ondragdrop="nsDragAndDrop.drop(event, gExtensionsDNDObserver);"
|
||||
ondblclick="gExtensionsViewController.doCommand('cmd_options');">
|
||||
<template>
|
||||
<rule>
|
||||
<conditions>
|
||||
|
@ -162,6 +163,18 @@
|
|||
<binding subject="?extension"
|
||||
predicate="http://www.mozilla.org/2004/em-rdf#locked"
|
||||
object="?locked"/>
|
||||
<binding subject="?extension"
|
||||
predicate="http://www.mozilla.org/2004/em-rdf#toBeInstalled"
|
||||
object="?toBeInstalled"/>
|
||||
<binding subject="?extension"
|
||||
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"/>
|
||||
<binding subject="?extension"
|
||||
predicate="http://www.mozilla.org/2004/em-rdf#toBeDisabled"
|
||||
object="?toBeDisabled"/>
|
||||
</bindings>
|
||||
<action>
|
||||
<extension uri="?extension" context="extensionContextMenu"
|
||||
|
@ -169,7 +182,9 @@
|
|||
description="?description" creator="?creator"
|
||||
disabled="?disabled" locked="?locked"
|
||||
optionsURL="?options-url" homepageURL="?homepage-url"
|
||||
aboutURL="?about-url" updateURL="?update-url"/>
|
||||
aboutURL="?about-url" updateURL="?update-url"
|
||||
toBeInstalled="?toBeInstalled" toBeUninstalled="?toBeUninstalled"
|
||||
toBeEnabled="?toBeEnabled" toBeDisabled="?toBeDisabled"/>
|
||||
</action>
|
||||
</rule>
|
||||
</template>
|
||||
|
|
|
@ -39,3 +39,7 @@
|
|||
<!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;.">
|
|
@ -1084,14 +1084,14 @@ nsExtensionManager.prototype = {
|
|||
var currAppID = pref.getCharPref(PREF_EM_APP_ID);
|
||||
var items = this._ds.getIncompatibleItemList(currAppID, currAppVersion,
|
||||
nsIUpdateItem.TYPE_ADDON);
|
||||
|
||||
if (items.length > 0) {
|
||||
for (var i = 0; i < items.length; ++i) {
|
||||
// Now disable the extension so it won't hurt anything.
|
||||
this.disableExtension(items[i].id);
|
||||
// XXXben - this is going to fail on themes - if we discover
|
||||
// a theme in this list we need to select the default
|
||||
// theme.
|
||||
var itemType = getItemType(this._ds._getResourceForItem(items[i].id).Value);
|
||||
if (itemType == nsIUpdateItem.TYPE_EXTENSION)
|
||||
this.disableExtension(items[i].id);
|
||||
else (itemType == nsIUpdateItem.TYPE_THEME) ;
|
||||
// XXXben need to deselect theme and reselect default.
|
||||
}
|
||||
var updates = Components.classes["@mozilla.org/updates/update-service;1"]
|
||||
.getService(Components.interfaces.nsIUpdateService);
|
||||
|
@ -1104,8 +1104,8 @@ nsExtensionManager.prototype = {
|
|||
}
|
||||
|
||||
// Now update the last app version so we don't do this checking
|
||||
// again.
|
||||
pref.setCharPref(PREF_EM_LAST_APP_VERSION, currAppVersion);
|
||||
// again. goats
|
||||
// pref.setCharPref(PREF_EM_LAST_APP_VERSION, currAppVersion);
|
||||
|
||||
return rv;
|
||||
},
|
||||
|
@ -1244,9 +1244,19 @@ nsExtensionManager.prototype = {
|
|||
this._ensureDS();
|
||||
var extensionID = this.canInstallItem(ds);
|
||||
if (extensionID) {
|
||||
this._ds.setItemProperty(extensionID, this._ds._emR("toBeInstalled"),
|
||||
this._ds._emL("true"), installProfile,
|
||||
nsIUpdateItem.TYPE_EXTENSION);
|
||||
// Clear any "disabled" flags that may have been set by the mismatch
|
||||
// checking code at startup.
|
||||
var props = { toBeDisabled : null,
|
||||
disabled : null,
|
||||
toBeInstalled : this._ds._emL("true"),
|
||||
name : this.getManifestProperty(ds, "name"),
|
||||
version : this.getManifestProperty(ds, "version") };
|
||||
for (var p in props) {
|
||||
this._ds.setItemProperty(extensionID, this._ds._emR(p),
|
||||
props[p], installProfile,
|
||||
nsIUpdateItem.TYPE_EXTENSION);
|
||||
}
|
||||
|
||||
// Then we stage the extension's XPI into a temporary directory so we
|
||||
// can extract them after the next restart.
|
||||
this._stageExtensionXPI(zipReader, extensionID, installProfile);
|
||||
|
@ -1281,6 +1291,15 @@ nsExtensionManager.prototype = {
|
|||
return null;
|
||||
},
|
||||
|
||||
getManifestProperty: function (aDataSource, aProperty)
|
||||
{
|
||||
var rdf = Components.classes["@mozilla.org/rdf/rdf-service;1"]
|
||||
.getService(Components.interfaces.nsIRDFService);
|
||||
var manifestRoot = rdf.GetResource("urn:mozilla:install-manifest");
|
||||
var arc = rdf.GetResource(EM_NS(aProperty));
|
||||
return aDataSource.GetTarget(manifestRoot, arc, true);
|
||||
},
|
||||
|
||||
_stageExtensionXPI: function (aZipReader, aExtensionID, aInstallProfile)
|
||||
{
|
||||
// Get the staging dir
|
||||
|
@ -1323,6 +1342,9 @@ nsExtensionManager.prototype = {
|
|||
var isProfile = this._ds.isProfileItem(aExtensionID);
|
||||
this._extUninstaller.uninstall(aExtensionID, isProfile);
|
||||
|
||||
// Clean the extension resource
|
||||
this._ds.removeItemMetadata(aExtensionID, nsIUpdateItem.TYPE_EXTENSION);
|
||||
|
||||
// Update the Defaults Manifest
|
||||
this._writeDefaults();
|
||||
|
||||
|
@ -1733,7 +1755,7 @@ nsExtensionsDataSource.prototype = {
|
|||
for (var i = 0; i < roots.length; ++i) {
|
||||
var ctr = Components.classes["@mozilla.org/rdf/container;1"]
|
||||
.createInstance(Components.interfaces.nsIRDFContainer);
|
||||
ctr.Init(this, this._rdf.GetResource(roots[i]));
|
||||
ctr.Init(this._composite, this._rdf.GetResource(roots[i]));
|
||||
|
||||
var elements = ctr.GetElements();
|
||||
while (elements.hasMoreElements()) {
|
||||
|
@ -1743,9 +1765,9 @@ nsExtensionsDataSource.prototype = {
|
|||
var id = stripPrefix(e.Value, itemType);
|
||||
var item = Components.classes["@mozilla.org/updates/item;1"]
|
||||
.createInstance(Components.interfaces.nsIUpdateItem);
|
||||
item.init(id, this.getItemProperty(id, "version"),
|
||||
this.getItemProperty(id, "name"),
|
||||
-1, "", "", this.getItemProperty(id, "updateURL"),
|
||||
item.init(id, this._getItemProperty(e, "version"),
|
||||
this._getItemProperty(e, "name"),
|
||||
-1, "", "", this._getItemProperty(e, "updateURL"),
|
||||
itemType);
|
||||
items.push(item);
|
||||
}
|
||||
|
@ -1874,8 +1896,13 @@ nsExtensionsDataSource.prototype = {
|
|||
dump("*** getItemProperty failing for lack of an item. This means _getResourceForItem \
|
||||
failed to locate a resource for aItemID (" + aItemID + ")\n");
|
||||
}
|
||||
var val = this._getItemProperty(item, aProperty);
|
||||
},
|
||||
|
||||
_getItemProperty: function (aItemResource, aProperty)
|
||||
{
|
||||
try {
|
||||
return this.GetTarget(item, this._emR(aProperty), true).QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
|
||||
return this.GetTarget(aItemResource, this._emR(aProperty), true).QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
|
||||
}
|
||||
catch (e) {}
|
||||
return "";
|
||||
|
@ -2019,9 +2046,6 @@ nsExtensionsDataSource.prototype = {
|
|||
// extension's resource, otherwise we'll think it's a global extension.
|
||||
var isProfile = this.isProfileItem(aExtensionID);
|
||||
|
||||
// Clean the extension resource
|
||||
this.removeItemMetadata(aExtensionID, nsIUpdateItem.TYPE_EXTENSION);
|
||||
|
||||
this.setItemProperty(aExtensionID, this._emR("toBeUninstalled"),
|
||||
this._emL("true"), isProfile,
|
||||
nsIUpdateItem.TYPE_EXTENSION);
|
||||
|
@ -2078,6 +2102,7 @@ nsExtensionsDataSource.prototype = {
|
|||
.getService(Components.interfaces.nsIProperties);
|
||||
var extensionsFile = getFile(getDirKey(aProfile),
|
||||
[DIR_EXTENSIONS, FILE_EXTENSIONS]);
|
||||
dumpFile(extensionsFile);
|
||||
|
||||
// If the file does not exist at the current location, copy the default
|
||||
// version over so we can access the various roots.
|
||||
|
|
Загрузка…
Ссылка в новой задаче