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