1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
|
<?xml version="1.0"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<!DOCTYPE window [
<!ENTITY % updateDTD SYSTEM "chrome://mozapps/locale/extensions/selectAddons.dtd">
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd">
%updateDTD;
%brandDTD;
]>
<bindings xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xbl="http://www.mozilla.org/xbl">
<binding id="addon-select">
<content>
<xul:hbox class="select-keep select-cell">
<xul:checkbox class="addon-keep-checkbox" anonid="keep"
xbl:inherits="tooltiptext=name"
oncommand="document.getBindingParent(this).keepChanged();"/>
</xul:hbox>
<xul:hbox class="select-icon select-cell">
<xul:image class="addon-icon" xbl:inherits="type"/>
</xul:hbox>
<xul:hbox class="select-name select-cell">
<xul:label class="addon-name" crop="end" style="&select.name.style;"
xbl:inherits="xbl:text=name"/>
</xul:hbox>
<xul:hbox class="select-action select-cell">
<xul:label class="addon-action-message" style="&select.action.style;"
xbl:inherits="xbl:text=action"/>
<xul:checkbox anonid="update" checked="true" class="addon-action-update"
oncommand="document.getBindingParent(this).updateChanged();"
style="&select.action.style;" xbl:inherits="label=action"/>
</xul:hbox>
<xul:hbox class="select-source select-cell">
<xul:label class="addon-source" xbl:inherits="xbl:text=source"/>
</xul:hbox>
</content>
<implementation>
<field name="_addon"/>
<field name="_disabled"/>
<field name="_install"/>
<field name="_wasActive"/>
<field name="_keep">document.getAnonymousElementByAttribute(this, "anonid", "keep");</field>
<field name="_update">document.getAnonymousElementByAttribute(this, "anonid", "update");</field>
<field name="_strings">document.getElementById("strings");</field>
<property name="action" readonly="true">
<getter><![CDATA[
if (!this._keep.checked) {
if (this._wasActive)
return "disable";
else
return null;
}
if (this._addon.appDisabled && !this._install)
return "incompatible";
if (this._install && (AddonManager.shouldAutoUpdate(this._addon) || this._update.checked))
return "update";
if (this._addon.permissions & AddonManager.PERM_CAN_ENABLE)
return "enable";
return null;
]]></getter>
</property>
<method name="setAddon">
<parameter name="aAddon"/>
<parameter name="aInstall"/>
<parameter name="aWasActive"/>
<parameter name="aDistroInstalled"/>
<body><![CDATA[
this._addon = aAddon;
this._install = aInstall;
this._wasActive = aWasActive;
this.setAttribute("name", aAddon.name);
this.setAttribute("type", aAddon.type);
// User and bundled add-ons default to staying enabled,
// others default to disabled.
switch (aAddon.scope) {
case AddonManager.SCOPE_PROFILE:
this._keep.checked = !aAddon.userDisabled;
if (aDistroInstalled)
this.setAttribute("source", this._strings.getString("source.bundled"));
else
this.setAttribute("source", this._strings.getString("source.profile"));
break;
default:
this._keep.checked = false;
this.setAttribute("source", this._strings.getString("source.other"));
}
this.updateAction();
]]></body>
</method>
<method name="setActionMessage">
<body><![CDATA[
if (!this._keep.checked) {
// If the user no longer wants this add-on then it is either being
// disabled or nothing is changing. Don't complicate matters by
// talking about updates for this case
if (this._wasActive)
this.setAttribute("action", this._strings.getString("action.disabled"));
else
this.setAttribute("action", "");
this.removeAttribute("optionalupdate");
return;
}
if (this._addon.appDisabled && !this._install) {
// If the add-on is incompatible and there is no update available
// then it will remain disabled
this.setAttribute("action", this._strings.getString("action.incompatible"));
this.removeAttribute("optionalupdate");
return;
}
if (this._install) {
if (!AddonManager.shouldAutoUpdate(this._addon)) {
this.setAttribute("optionalupdate", "true");
// If manual updating for the add-on then display the right
// text depending on whether the update is required to make
// the add-on work or not
if (this._addon.appDisabled)
this.setAttribute("action", this._strings.getString("action.neededupdate"));
else
this.setAttribute("action", this._strings.getString("action.unneededupdate"));
return;
}
this.removeAttribute("optionalupdate");
// If the update is needed to make the add-on compatible then
// say so otherwise just say nothing about it
if (this._addon.appDisabled) {
this.setAttribute("action", this._strings.getString("action.autoupdate"));
return;
}
}
else {
this.removeAttribute("optionalupdate");
}
// If the add-on didn't used to be active and it now is (via a
// compatibility update) or it can be enabled then the action is to
// enable the add-on
if (!this._wasActive && (this._addon.isActive || this._addon.permissions & AddonManager.PERM_CAN_ENABLE)) {
this.setAttribute("action", this._strings.getString("action.enabled"));
return;
}
// In all other cases the add-on is simply remaining enabled
this.setAttribute("action", "");
]]></body>
</method>
<method name="updateAction">
<body><![CDATA[
this.setActionMessage();
let installingUpdate = this._install &&
(AddonManager.shouldAutoUpdate(this._addon) ||
this._update.checked);
if (this._keep.checked && (!this._addon.appDisabled || installingUpdate))
this.setAttribute("active", "true");
else
this.removeAttribute("active");
gSelect.updateButtons();
]]></body>
</method>
<method name="updateChanged">
<body><![CDATA[
this.updateAction();
]]></body>
</method>
<method name="keepChanged">
<body><![CDATA[
this.updateAction();
]]></body>
</method>
<method name="keep">
<body><![CDATA[
this._keep.checked = true;
this.keepChanged();
]]></body>
</method>
<method name="disable">
<body><![CDATA[
this._keep.checked = false;
this.keepChanged();
]]></body>
</method>
<method name="apply">
<body><![CDATA[
this._addon.userDisabled = !this._keep.checked;
if (!this._install || !this._keep.checked)
return;
if (AddonManager.shouldAutoUpdate(this._addon) || this._update.checked)
this._install.install();
]]></body>
</method>
</implementation>
</binding>
<binding id="addon-confirm">
<content>
<xul:image class="addon-icon" xbl:inherits="type"/>
<xul:label class="addon-name" xbl:inherits="xbl:text=name"/>
</content>
</binding>
</bindings>
|