Skip to content

Commit

Permalink
#639: site-specific user agent exposed interface plus locale changes
Browse files Browse the repository at this point in the history
  • Loading branch information
classilla committed Mar 11, 2021
1 parent 7b40324 commit 355d707
Show file tree
Hide file tree
Showing 8 changed files with 518 additions and 10 deletions.
30 changes: 21 additions & 9 deletions browser/components/preferences/in-content/tenfourfox.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,29 @@ var gTenFourFoxPane = {

init: function ()
{
function setEventListener(aId, aEventType, aCallback) /* future expansion */
function setEventListener(aId, aEventType, aCallback)
{
document.getElementById(aId)
.addEventListener(aEventType, aCallback.bind(gTenFourFoxPane));
}

/* setEventListener("historyDontRememberClear", "click", function () {
gPrivacyPane.clearPrivateDataNow(true);
return false;
}); */
setEventListener("siteSpecificUAs", "command", gTenFourFoxPane.showSSUAs);
},

showSSUAs: function ()
{
let bundle = document.getElementById("tenFourFoxBundle");
let params = { blockVisible : true,
sessionVisible : true,
allowVisible : true,
prefilledHost : "",
type : "ssua",
windowTitle : bundle.getString("TFFsiteSpecificUAs.title"),
introText : bundle.getString("TFFsiteSpecificUAs.prompt") };
gSubDialog.open("chrome://browser/content/preferences/tenfourfox-ssua.xul",
null, params);
},


// We have to invert the sense for the pdfjs.disabled pref, since true equals DISabled.

Expand All @@ -37,6 +49,7 @@ var gTenFourFoxPane = {
},

// Find and set the appropriate UA string based on the UA template.
// Keep in sync with tenfourfox-ssua.xul and tenfourfox.xul
validUA : {
"fx" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Firefox/52.0",
"fx60" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Firefox/60.0",
Expand All @@ -48,7 +61,6 @@ var gTenFourFoxPane = {
"android" : "Mozilla/5.0 (Linux; Android 8.1.0; Pixel XL Build/OPM1.171019.021) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.109 Mobile Safari/537.36",
"ipad" : "Mozilla/5.0 (iPhone; CPU iPhone OS 11_2_6 like Mac OS X) AppleWebKit/604.5.6 (KHTML, like Gecko) Version/11.0 Mobile/15D100 Safari/604.1"
},
_prefSvc: Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch),
readUA: function ()
{
var pref = document.getElementById("tenfourfox.ua.template");
Expand All @@ -57,7 +69,7 @@ var gTenFourFoxPane = {
// Synchronize the pref on entry in case it's stale.
pref = pref.value;
if (this.validUA[pref]) {
this._prefSvc.setCharPref("general.useragent.override", this.validUA[pref]);
Services.prefs.setCharPref("general.useragent.override", this.validUA[pref]);
return pref;
}
return "";
Expand All @@ -66,10 +78,10 @@ var gTenFourFoxPane = {
{
var nupref = document.getElementById("uaBox").value;
if (this.validUA[nupref]) {
this._prefSvc.setCharPref("general.useragent.override", this.validUA[nupref]);
Services.prefs.setCharPref("general.useragent.override", this.validUA[nupref]);
return nupref;
}
this._prefSvc.clearUserPref("general.useragent.override");
Services.prefs.clearUserPref("general.useragent.override");
return "";
},
};
5 changes: 5 additions & 0 deletions browser/components/preferences/in-content/tenfourfox.xul
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@

</preferences>

<stringbundle id="tenFourFoxBundle"
src="chrome://browser/locale/TenFourFox.properties"/>

<hbox id="header-tenfourfox"
class="header"
hidden="true"
Expand Down Expand Up @@ -74,6 +77,8 @@
<menuitem label="iOS Safari (iPad)" value="ipad"/>
</menupopup>
</menulist>
<spacer flex="1"/>
<button id="siteSpecificUAs" label="&TFFsiteSpecificUAs.label;"/>
</hbox>
</groupbox>

Expand Down
2 changes: 2 additions & 0 deletions browser/components/preferences/jar.mn
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,7 @@ browser.jar:
content/browser/preferences/sanitize.js
content/browser/preferences/selectBookmark.xul
content/browser/preferences/selectBookmark.js
content/browser/preferences/tenfourfox-ssua.xul
* content/browser/preferences/tenfourfox-ssua.js
content/browser/preferences/translation.xul
content/browser/preferences/translation.js
Loading

0 comments on commit 355d707

Please sign in to comment.