toolkit/mozapps/extensions/content/setting.xml

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 <?xml version="1.0"?>
michael@0 2 <!-- This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 - License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
michael@0 5
michael@0 6 <!DOCTYPE page [
michael@0 7 <!ENTITY % extensionsDTD SYSTEM "chrome://mozapps/locale/extensions/extensions.dtd">
michael@0 8 %extensionsDTD;
michael@0 9 ]>
michael@0 10
michael@0 11 <bindings xmlns="http://www.mozilla.org/xbl"
michael@0 12 xmlns:xbl="http://www.mozilla.org/xbl"
michael@0 13 xmlns:html="http://www.w3.org/1999/xhtml"
michael@0 14 xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
michael@0 15
michael@0 16 <binding id="settings">
michael@0 17 <content orient="vertical">
michael@0 18 <xul:label class="settings-title" xbl:inherits="xbl:text=label" flex="1"/>
michael@0 19 <children/>
michael@0 20 </content>
michael@0 21 </binding>
michael@0 22
michael@0 23 <binding id="setting-base">
michael@0 24 <implementation>
michael@0 25 <constructor><![CDATA[
michael@0 26 this.preferenceChanged();
michael@0 27
michael@0 28 this.addEventListener("keypress", function(event) {
michael@0 29 event.stopPropagation();
michael@0 30 }, false);
michael@0 31
michael@0 32 if (this.usePref)
michael@0 33 Services.prefs.addObserver(this.pref, this._observer, true);
michael@0 34 ]]></constructor>
michael@0 35
michael@0 36 <field name="_observer"><![CDATA[({
michael@0 37 _self: this,
michael@0 38
michael@0 39 QueryInterface: function(aIID) {
michael@0 40 const Ci = Components.interfaces;
michael@0 41 if (aIID.equals(Ci.nsIObserver) ||
michael@0 42 aIID.equals(Ci.nsISupportsWeakReference) ||
michael@0 43 aIID.equals(Ci.nsISupports))
michael@0 44 return this;
michael@0 45
michael@0 46 throw Components.Exception("No interface", Components.results.NS_ERROR_NO_INTERFACE);
michael@0 47 },
michael@0 48
michael@0 49 observe: function(aSubject, aTopic, aPrefName) {
michael@0 50 if (aTopic != "nsPref:changed")
michael@0 51 return;
michael@0 52
michael@0 53 if (this._self.pref == aPrefName)
michael@0 54 this._self.preferenceChanged();
michael@0 55 }
michael@0 56 })]]>
michael@0 57 </field>
michael@0 58
michael@0 59 <method name="fireEvent">
michael@0 60 <parameter name="eventName"/>
michael@0 61 <parameter name="funcStr"/>
michael@0 62 <body>
michael@0 63 <![CDATA[
michael@0 64 let body = funcStr || this.getAttribute(eventName);
michael@0 65 if (!body)
michael@0 66 return;
michael@0 67
michael@0 68 try {
michael@0 69 let event = document.createEvent("Events");
michael@0 70 event.initEvent(eventName, true, true);
michael@0 71 let f = new Function("event", body);
michael@0 72 f.call(this, event);
michael@0 73 }
michael@0 74 catch (e) {
michael@0 75 Cu.reportError(e);
michael@0 76 }
michael@0 77 ]]>
michael@0 78 </body>
michael@0 79 </method>
michael@0 80
michael@0 81 <method name="valueFromPreference">
michael@0 82 <body>
michael@0 83 <![CDATA[
michael@0 84 // Should be code to set the from the preference input.value
michael@0 85 throw Components.Exception("No valueFromPreference implementation",
michael@0 86 Components.results.NS_ERROR_NOT_IMPLEMENTED);
michael@0 87 ]]>
michael@0 88 </body>
michael@0 89 </method>
michael@0 90
michael@0 91 <method name="valueToPreference">
michael@0 92 <body>
michael@0 93 <![CDATA[
michael@0 94 // Should be code to set the input.value from the preference
michael@0 95 throw Components.Exception("No valueToPreference implementation",
michael@0 96 Components.results.NS_ERROR_NOT_IMPLEMENTED);
michael@0 97 ]]>
michael@0 98 </body>
michael@0 99 </method>
michael@0 100
michael@0 101 <method name="inputChanged">
michael@0 102 <body>
michael@0 103 <![CDATA[
michael@0 104 if (this.usePref && !this._updatingInput) {
michael@0 105 this.valueToPreference();
michael@0 106 this.fireEvent("oninputchanged");
michael@0 107 }
michael@0 108 ]]>
michael@0 109 </body>
michael@0 110 </method>
michael@0 111
michael@0 112 <method name="preferenceChanged">
michael@0 113 <body>
michael@0 114 <![CDATA[
michael@0 115 if (this.usePref) {
michael@0 116 this._updatingInput = true;
michael@0 117 try {
michael@0 118 this.valueFromPreference();
michael@0 119 this.fireEvent("onpreferencechanged");
michael@0 120 } catch (e) {}
michael@0 121 this._updatingInput = false;
michael@0 122 }
michael@0 123 ]]>
michael@0 124 </body>
michael@0 125 </method>
michael@0 126
michael@0 127 <property name="usePref" readonly="true" onget="return this.hasAttribute('pref');"/>
michael@0 128 <property name="pref" readonly="true" onget="return this.getAttribute('pref');"/>
michael@0 129 <property name="type" readonly="true" onget="return this.getAttribute('type');"/>
michael@0 130 <property name="value" onget="return this.input.value;" onset="return this.input.value = val;"/>
michael@0 131
michael@0 132 <field name="_updatingInput">false</field>
michael@0 133 <field name="input">document.getAnonymousElementByAttribute(this, "anonid", "input");</field>
michael@0 134 <field name="settings">
michael@0 135 this.parentNode.localName == "settings" ? this.parentNode : null;
michael@0 136 </field>
michael@0 137 </implementation>
michael@0 138 </binding>
michael@0 139
michael@0 140 <binding id="setting-bool" extends="chrome://mozapps/content/extensions/setting.xml#setting-base">
michael@0 141 <content>
michael@0 142 <xul:vbox>
michael@0 143 <xul:hbox class="preferences-alignment">
michael@0 144 <xul:label class="preferences-title" flex="1" xbl:inherits="xbl:text=title"/>
michael@0 145 </xul:hbox>
michael@0 146 <xul:description class="preferences-description" flex="1" xbl:inherits="xbl:text=desc"/>
michael@0 147 </xul:vbox>
michael@0 148 <xul:hbox class="preferences-alignment">
michael@0 149 <xul:checkbox anonid="input" xbl:inherits="disabled,onlabel,offlabel,label=checkboxlabel" oncommand="inputChanged();"/>
michael@0 150 </xul:hbox>
michael@0 151 </content>
michael@0 152
michael@0 153 <implementation>
michael@0 154 <method name="valueFromPreference">
michael@0 155 <body>
michael@0 156 <![CDATA[
michael@0 157 let val = Services.prefs.getBoolPref(this.pref);
michael@0 158 this.value = this.inverted ? !val : val;
michael@0 159 ]]>
michael@0 160 </body>
michael@0 161 </method>
michael@0 162
michael@0 163 <method name="valueToPreference">
michael@0 164 <body>
michael@0 165 <![CDATA[
michael@0 166 let val = this.value;
michael@0 167 Services.prefs.setBoolPref(this.pref, this.inverted ? !val : val);
michael@0 168 ]]>
michael@0 169 </body>
michael@0 170 </method>
michael@0 171
michael@0 172 <property name="value" onget="return this.input.checked;" onset="return this.input.setChecked(val);"/>
michael@0 173 <property name="inverted" readonly="true" onget="return this.getAttribute('inverted');"/>
michael@0 174 </implementation>
michael@0 175 </binding>
michael@0 176
michael@0 177 <binding id="setting-boolint" extends="chrome://mozapps/content/extensions/setting.xml#setting-bool">
michael@0 178 <implementation>
michael@0 179 <method name="valueFromPreference">
michael@0 180 <body>
michael@0 181 <![CDATA[
michael@0 182 let val = Services.prefs.getIntPref(this.pref);
michael@0 183 this.value = (val == this.getAttribute("on"));
michael@0 184 ]]>
michael@0 185 </body>
michael@0 186 </method>
michael@0 187
michael@0 188 <method name="valueToPreference">
michael@0 189 <body>
michael@0 190 <![CDATA[
michael@0 191 Services.prefs.setIntPref(this.pref, this.getAttribute(this.value ? "on" : "off"));
michael@0 192 ]]>
michael@0 193 </body>
michael@0 194 </method>
michael@0 195 </implementation>
michael@0 196 </binding>
michael@0 197
michael@0 198 <binding id="setting-localized-bool" extends="chrome://mozapps/content/extensions/setting.xml#setting-bool">
michael@0 199 <implementation>
michael@0 200 <method name="valueFromPreference">
michael@0 201 <body>
michael@0 202 <![CDATA[
michael@0 203 let val = Services.prefs.getComplexValue(this.pref, Components.interfaces.nsIPrefLocalizedString).data;
michael@0 204 if(this.inverted) val = !val;
michael@0 205 this.value = (val == "true");
michael@0 206 ]]>
michael@0 207 </body>
michael@0 208 </method>
michael@0 209
michael@0 210 <method name="valueToPreference">
michael@0 211 <body>
michael@0 212 <![CDATA[
michael@0 213 let val = this.value;
michael@0 214 if(this.inverted) val = !val;
michael@0 215 let pref = Components.classes["@mozilla.org/pref-localizedstring;1"].createInstance(Components.interfaces.nsIPrefLocalizedString);
michael@0 216 pref.data = this.inverted ? (!val).toString() : val.toString();
michael@0 217 Services.prefs.setComplexValue(this.pref, Components.interfaces.nsIPrefLocalizedString, pref);
michael@0 218 ]]>
michael@0 219 </body>
michael@0 220 </method>
michael@0 221 </implementation>
michael@0 222 </binding>
michael@0 223
michael@0 224 <binding id="setting-integer" extends="chrome://mozapps/content/extensions/setting.xml#setting-base">
michael@0 225 <content>
michael@0 226 <xul:vbox>
michael@0 227 <xul:hbox class="preferences-alignment">
michael@0 228 <xul:label class="preferences-title" flex="1" xbl:inherits="xbl:text=title"/>
michael@0 229 </xul:hbox>
michael@0 230 <xul:description class="preferences-description" flex="1" xbl:inherits="xbl:text=desc"/>
michael@0 231 </xul:vbox>
michael@0 232 <xul:hbox class="preferences-alignment">
michael@0 233 <xul:textbox type="number" anonid="input" oninput="inputChanged();" onchange="inputChanged();"
michael@0 234 xbl:inherits="disabled,emptytext,min,max,increment,hidespinbuttons,wraparound,size"/>
michael@0 235 </xul:hbox>
michael@0 236 </content>
michael@0 237
michael@0 238 <implementation>
michael@0 239 <method name="valueFromPreference">
michael@0 240 <body>
michael@0 241 <![CDATA[
michael@0 242 let val = Services.prefs.getIntPref(this.pref);
michael@0 243 this.value = val;
michael@0 244 ]]>
michael@0 245 </body>
michael@0 246 </method>
michael@0 247
michael@0 248 <method name="valueToPreference">
michael@0 249 <body>
michael@0 250 <![CDATA[
michael@0 251 Services.prefs.setIntPref(this.pref, this.value);
michael@0 252 ]]>
michael@0 253 </body>
michael@0 254 </method>
michael@0 255 </implementation>
michael@0 256 </binding>
michael@0 257
michael@0 258 <binding id="setting-control" extends="chrome://mozapps/content/extensions/setting.xml#setting-base">
michael@0 259 <content>
michael@0 260 <xul:vbox>
michael@0 261 <xul:hbox class="preferences-alignment">
michael@0 262 <xul:label class="preferences-title" flex="1" xbl:inherits="xbl:text=title"/>
michael@0 263 </xul:hbox>
michael@0 264 <xul:description class="preferences-description" flex="1" xbl:inherits="xbl:text=desc"/>
michael@0 265 </xul:vbox>
michael@0 266 <xul:hbox class="preferences-alignment">
michael@0 267 <children/>
michael@0 268 </xul:hbox>
michael@0 269 </content>
michael@0 270 </binding>
michael@0 271
michael@0 272 <binding id="setting-string" extends="chrome://mozapps/content/extensions/setting.xml#setting-base">
michael@0 273 <content>
michael@0 274 <xul:vbox>
michael@0 275 <xul:hbox class="preferences-alignment">
michael@0 276 <xul:label class="preferences-title" flex="1" xbl:inherits="xbl:text=title"/>
michael@0 277 </xul:hbox>
michael@0 278 <xul:description class="preferences-description" flex="1" xbl:inherits="xbl:text=desc"/>
michael@0 279 </xul:vbox>
michael@0 280 <xul:hbox class="preferences-alignment">
michael@0 281 <xul:textbox anonid="input" flex="1" oninput="inputChanged();"
michael@0 282 xbl:inherits="disabled,emptytext,type=inputtype,min,max,increment,hidespinbuttons,decimalplaces,wraparound"/>
michael@0 283 </xul:hbox>
michael@0 284 </content>
michael@0 285
michael@0 286 <implementation>
michael@0 287 <method name="valueFromPreference">
michael@0 288 <body>
michael@0 289 <![CDATA[
michael@0 290 const nsISupportsString = Components.interfaces.nsISupportsString;
michael@0 291 this.value = Services.prefs.getComplexValue(this.pref, nsISupportsString).data;
michael@0 292 ]]>
michael@0 293 </body>
michael@0 294 </method>
michael@0 295
michael@0 296 <method name="valueToPreference">
michael@0 297 <body>
michael@0 298 <![CDATA[
michael@0 299 const nsISupportsString = Components.interfaces.nsISupportsString;
michael@0 300 let iss = Components.classes["@mozilla.org/supports-string;1"].createInstance(nsISupportsString);
michael@0 301 iss.data = this.value;
michael@0 302 Services.prefs.setComplexValue(this.pref, nsISupportsString, iss);
michael@0 303 ]]>
michael@0 304 </body>
michael@0 305 </method>
michael@0 306 </implementation>
michael@0 307 </binding>
michael@0 308
michael@0 309 <binding id="setting-color" extends="chrome://mozapps/content/extensions/setting.xml#setting-base">
michael@0 310 <content>
michael@0 311 <xul:vbox>
michael@0 312 <xul:hbox class="preferences-alignment">
michael@0 313 <xul:label class="preferences-title" flex="1" xbl:inherits="xbl:text=title"/>
michael@0 314 </xul:hbox>
michael@0 315 <xul:description class="preferences-description" flex="1" xbl:inherits="xbl:text=desc"/>
michael@0 316 </xul:vbox>
michael@0 317 <xul:hbox class="preferences-alignment">
michael@0 318 <xul:colorpicker type="button" anonid="input" xbl:inherits="disabled" onchange="document.getBindingParent(this).inputChanged();"/>
michael@0 319 </xul:hbox>
michael@0 320 </content>
michael@0 321
michael@0 322 <implementation>
michael@0 323 <method name="valueFromPreference">
michael@0 324 <body>
michael@0 325 <![CDATA[
michael@0 326 // We must wait for the colorpicker's binding to be applied before setting the value
michael@0 327 if (!this.input.color)
michael@0 328 this.input.initialize();
michael@0 329 this.value = Services.prefs.getCharPref(this.pref);
michael@0 330 ]]>
michael@0 331 </body>
michael@0 332 </method>
michael@0 333
michael@0 334 <method name="valueToPreference">
michael@0 335 <body>
michael@0 336 <![CDATA[
michael@0 337 Services.prefs.setCharPref(this.pref, this.value);
michael@0 338 ]]>
michael@0 339 </body>
michael@0 340 </method>
michael@0 341
michael@0 342 <property name="value" onget="return this.input.color;" onset="return this.input.color = val;"/>
michael@0 343 </implementation>
michael@0 344 </binding>
michael@0 345
michael@0 346 <binding id="setting-path" extends="chrome://mozapps/content/extensions/setting.xml#setting-base">
michael@0 347 <content>
michael@0 348 <xul:vbox>
michael@0 349 <xul:hbox class="preferences-alignment">
michael@0 350 <xul:label class="preferences-title" flex="1" xbl:inherits="xbl:text=title"/>
michael@0 351 </xul:hbox>
michael@0 352 <xul:description class="preferences-description" flex="1" xbl:inherits="xbl:text=desc"/>
michael@0 353 </xul:vbox>
michael@0 354 <xul:hbox class="preferences-alignment">
michael@0 355 <xul:button type="button" anonid="button" label="&settings.path.button.label;" xbl:inherits="disabled" oncommand="showPicker();"/>
michael@0 356 <xul:label anonid="input" flex="1" crop="center" xbl:inherits="disabled"/>
michael@0 357 </xul:hbox>
michael@0 358 </content>
michael@0 359
michael@0 360 <implementation>
michael@0 361 <method name="showPicker">
michael@0 362 <body>
michael@0 363 <![CDATA[
michael@0 364 var filePicker = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
michael@0 365 filePicker.init(window, this.getAttribute("title"),
michael@0 366 this.type == "file" ? Ci.nsIFilePicker.modeOpen : Ci.nsIFilePicker.modeGetFolder);
michael@0 367 if (this.value) {
michael@0 368 try {
michael@0 369 let file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
michael@0 370 file.initWithPath(this.value);
michael@0 371 filePicker.displayDirectory = this.type == "file" ? file.parent : file;
michael@0 372 if (this.type == "file") {
michael@0 373 filePicker.defaultString = file.leafName;
michael@0 374 }
michael@0 375 } catch (e) {}
michael@0 376 }
michael@0 377 if (filePicker.show() != Ci.nsIFilePicker.returnCancel) {
michael@0 378 this.value = filePicker.file.path;
michael@0 379 this.inputChanged();
michael@0 380 }
michael@0 381 ]]>
michael@0 382 </body>
michael@0 383 </method>
michael@0 384
michael@0 385 <method name="valueFromPreference">
michael@0 386 <body>
michael@0 387 <![CDATA[
michael@0 388 this.value = Services.prefs.getCharPref(this.pref);
michael@0 389 ]]>
michael@0 390 </body>
michael@0 391 </method>
michael@0 392
michael@0 393 <method name="valueToPreference">
michael@0 394 <body>
michael@0 395 <![CDATA[
michael@0 396 Services.prefs.setCharPref(this.pref, this.value);
michael@0 397 ]]>
michael@0 398 </body>
michael@0 399 </method>
michael@0 400
michael@0 401 <field name="_value"></field>
michael@0 402
michael@0 403 <property name="value">
michael@0 404 <getter>
michael@0 405 <![CDATA[
michael@0 406 return this._value;
michael@0 407 ]]>
michael@0 408 </getter>
michael@0 409 <setter>
michael@0 410 <![CDATA[
michael@0 411 this._value = val;
michael@0 412 let label = "";
michael@0 413 if (val) {
michael@0 414 try {
michael@0 415 let file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
michael@0 416 file.initWithPath(val);
michael@0 417 label = this.hasAttribute("fullpath") ? file.path : file.leafName;
michael@0 418 } catch (e) {}
michael@0 419 }
michael@0 420 this.input.tooltipText = val;
michael@0 421 return this.input.value = label;
michael@0 422 ]]>
michael@0 423 </setter>
michael@0 424 </property>
michael@0 425 </implementation>
michael@0 426 </binding>
michael@0 427
michael@0 428 <binding id="setting-multi" extends="chrome://mozapps/content/extensions/setting.xml#setting-base">
michael@0 429 <content>
michael@0 430 <xul:vbox>
michael@0 431 <xul:hbox class="preferences-alignment">
michael@0 432 <xul:label class="preferences-title" flex="1" xbl:inherits="xbl:text=title"/>
michael@0 433 </xul:hbox>
michael@0 434 <xul:description class="preferences-description" flex="1" xbl:inherits="xbl:text=desc"/>
michael@0 435 </xul:vbox>
michael@0 436 <xul:hbox class="preferences-alignment">
michael@0 437 <children includes="radiogroup|menulist"/>
michael@0 438 </xul:hbox>
michael@0 439 </content>
michael@0 440
michael@0 441 <implementation>
michael@0 442 <constructor>
michael@0 443 <![CDATA[
michael@0 444 this.control.addEventListener("command", this.inputChanged.bind(this), false);
michael@0 445 ]]>
michael@0 446 </constructor>
michael@0 447
michael@0 448 <method name="valueFromPreference">
michael@0 449 <body>
michael@0 450 <![CDATA[
michael@0 451 let val;
michael@0 452 switch (Services.prefs.getPrefType(this.pref)) {
michael@0 453 case Ci.nsIPrefBranch.PREF_STRING:
michael@0 454 val = Services.prefs.getCharPref(this.pref);
michael@0 455 break;
michael@0 456 case Ci.nsIPrefBranch.PREF_INT:
michael@0 457 val = Services.prefs.getIntPref(this.pref);
michael@0 458 break;
michael@0 459 case Ci.nsIPrefBranch.PREF_BOOL:
michael@0 460 val = Services.prefs.getBoolPref(this.pref).toString();
michael@0 461 break;
michael@0 462 default:
michael@0 463 return;
michael@0 464 }
michael@0 465
michael@0 466 if ("itemCount" in this.control) {
michael@0 467 for (let i = 0; i < this.control.itemCount; i++) {
michael@0 468 if (this.control.getItemAtIndex(i).value == val) {
michael@0 469 this.control.selectedIndex = i;
michael@0 470 break;
michael@0 471 }
michael@0 472 }
michael@0 473 } else {
michael@0 474 this.control.setAttribute("value", val);
michael@0 475 }
michael@0 476 ]]>
michael@0 477 </body>
michael@0 478 </method>
michael@0 479
michael@0 480 <method name="valueToPreference">
michael@0 481 <body>
michael@0 482 <![CDATA[
michael@0 483 // We might not have a pref already set, so we guess the type from the value attribute
michael@0 484 let val = this.control.selectedItem.value;
michael@0 485 if (val == "true" || val == "false")
michael@0 486 Services.prefs.setBoolPref(this.pref, val == "true");
michael@0 487 else if (/^-?\d+$/.test(val))
michael@0 488 Services.prefs.setIntPref(this.pref, val);
michael@0 489 else
michael@0 490 Services.prefs.setCharPref(this.pref, val);
michael@0 491 ]]>
michael@0 492 </body>
michael@0 493 </method>
michael@0 494
michael@0 495 <field name="control">this.getElementsByTagName(this.getAttribute("type") == "radio" ? "radiogroup" : "menulist")[0];</field>
michael@0 496 </implementation>
michael@0 497 </binding>
michael@0 498 </bindings>

mercurial