Bug 1013861: add pref to control showing the translation UI. r=felipe

This commit is contained in:
Mike de Boer 2014-05-23 17:16:27 +02:00
parent d879c7b93f
commit 26f2ac1137
2 changed files with 7 additions and 0 deletions

View File

@ -1568,6 +1568,8 @@ pref("browser.cache.frecency_experiment", 0);
pref("browser.translation.detectLanguage", false); pref("browser.translation.detectLanguage", false);
pref("browser.translation.neverForLanguages", ""); pref("browser.translation.neverForLanguages", "");
// Show the translation UI bits, like the info bar, notification icon and preferences.
pref("browser.translation.ui.show", false);
// Telemetry experiments settings. // Telemetry experiments settings.
pref("experiments.enabled", true); pref("experiments.enabled", true);

View File

@ -8,6 +8,8 @@ this.EXPORTED_SYMBOLS = ["Translation"];
const {classes: Cc, interfaces: Ci, utils: Cu} = Components; const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
const TRANSLATION_PREF_SHOWUI = "browser.translation.ui.show";
Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/Services.jsm");
this.Translation = { this.Translation = {
@ -26,6 +28,9 @@ this.Translation = {
}, },
languageDetected: function(aBrowser, aDetectedLanguage) { languageDetected: function(aBrowser, aDetectedLanguage) {
if (!Services.prefs.getBoolPref(TRANSLATION_PREF_SHOWUI))
return;
if (this.supportedSourceLanguages.indexOf(aDetectedLanguage) != -1 && if (this.supportedSourceLanguages.indexOf(aDetectedLanguage) != -1 &&
aDetectedLanguage != this.defaultTargetLanguage) { aDetectedLanguage != this.defaultTargetLanguage) {
if (!aBrowser.translationUI) if (!aBrowser.translationUI)