From: csagan5 <32685696+csagan5@users.noreply.github.com> Date: Mon, 12 Feb 2018 21:28:53 +0100 Subject: ungoogled-chromium: Disable translate integration Remove translate offer License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html --- .../xml/languages_detailed_preferences.xml | 43 ------------------ .../java/res/xml/languages_preferences.xml | 5 --- .../language/settings/LanguageSettings.java | 44 +------------------ .../strings/android_chrome_strings.grd | 3 -- .../core/browser/translate_manager.cc | 5 ++- .../core/browser/translate_script.cc | 19 +++----- 6 files changed, 11 insertions(+), 108 deletions(-) diff --git a/chrome/browser/language/android/java/res/xml/languages_detailed_preferences.xml b/chrome/browser/language/android/java/res/xml/languages_detailed_preferences.xml --- a/chrome/browser/language/android/java/res/xml/languages_detailed_preferences.xml +++ b/chrome/browser/language/android/java/res/xml/languages_detailed_preferences.xml @@ -31,47 +31,4 @@ found in the LICENSE file. - - - - - - - - - - - - - - - - diff --git a/chrome/browser/language/android/java/res/xml/languages_preferences.xml b/chrome/browser/language/android/java/res/xml/languages_preferences.xml --- a/chrome/browser/language/android/java/res/xml/languages_preferences.xml +++ b/chrome/browser/language/android/java/res/xml/languages_preferences.xml @@ -13,9 +13,4 @@ found in the LICENSE file. android:layout="@layout/languages_preference" android:widgetLayout="@layout/accept_languages_list" /> - - diff --git a/chrome/browser/language/android/java/src/org/chromium/chrome/browser/language/settings/LanguageSettings.java b/chrome/browser/language/android/java/src/org/chromium/chrome/browser/language/settings/LanguageSettings.java --- a/chrome/browser/language/android/java/src/org/chromium/chrome/browser/language/settings/LanguageSettings.java +++ b/chrome/browser/language/android/java/src/org/chromium/chrome/browser/language/settings/LanguageSettings.java @@ -47,12 +47,6 @@ public class LanguageSettings extends ChromeBaseSettingsFragment static final String APP_LANGUAGE_PREFERENCE_KEY = "app_language_preference"; static final String PREFERRED_LANGUAGES_KEY = "preferred_languages"; static final String CONTENT_LANGUAGES_KEY = "content_languages_preference"; - static final String TRANSLATE_SWITCH_KEY = "translate_switch"; - - static final String TRANSLATION_ADVANCED_SECTION = "translation_advanced_settings_section"; - static final String TARGET_LANGUAGE_KEY = "translate_settings_target_language"; - static final String ALWAYS_LANGUAGES_KEY = "translate_settings_always_languages"; - static final String NEVER_LANGUAGES_KEY = "translate_settings_never_languages"; private static final String TAG = "LanguageSettings"; @@ -97,32 +91,6 @@ public class LanguageSettings extends ChromeBaseSettingsFragment ContentLanguagesPreference mLanguageListPref = (ContentLanguagesPreference) findPreference(PREFERRED_LANGUAGES_KEY); mLanguageListPref.initialize(this, getPrefService()); - - ChromeSwitchPreference translateSwitch = - (ChromeSwitchPreference) findPreference(TRANSLATE_SWITCH_KEY); - boolean isTranslateEnabled = getPrefService().getBoolean(Pref.OFFER_TRANSLATE_ENABLED); - translateSwitch.setChecked(isTranslateEnabled); - - translateSwitch.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { - @Override - public boolean onPreferenceChange(Preference preference, Object newValue) { - boolean enabled = (boolean) newValue; - getPrefService().setBoolean(Pref.OFFER_TRANSLATE_ENABLED, enabled); - mLanguageListPref.notifyPrefChanged(); - LanguagesManager.recordAction(enabled ? LanguagesManager.LanguageSettingsActionType - .ENABLE_TRANSLATE_GLOBALLY - : LanguagesManager.LanguageSettingsActionType - .DISABLE_TRANSLATE_GLOBALLY); - return true; - } - }); - translateSwitch.setManagedPreferenceDelegate(new ChromeManagedPreferenceDelegate( - getProfile()) { - @Override - public boolean isPreferenceControlledByPolicy(Preference preference) { - return getPrefService().isManagedPreference(Pref.OFFER_TRANSLATE_ENABLED); - } - }); } /** @@ -137,8 +105,6 @@ public class LanguageSettings extends ChromeBaseSettingsFragment ContentLanguagesPreference mLanguageListPref = (ContentLanguagesPreference) findPreference(CONTENT_LANGUAGES_KEY); mLanguageListPref.initialize(this, getPrefService()); - - setupTranslateSection(mLanguageListPref); } /** @@ -168,7 +134,7 @@ public class LanguageSettings extends ChromeBaseSettingsFragment * @param contentLanguagesPreference ContentLanguagesPreference reference to update about state * changes. */ - private void setupTranslateSection(ContentLanguagesPreference contentLanguagesPreference) { +/* private void setupTranslateSection(ContentLanguagesPreference contentLanguagesPreference) { // Setup expandable advanced settings section. PreferenceCategory translationAdvancedSection = (PreferenceCategory) findPreference(TRANSLATION_ADVANCED_SECTION); @@ -237,7 +203,7 @@ public class LanguageSettings extends ChromeBaseSettingsFragment return getPrefService().isManagedPreference(Pref.OFFER_TRANSLATE_ENABLED); } }); - } + } */ @Override public void onStart() { @@ -275,12 +241,6 @@ public class LanguageSettings extends ChromeBaseSettingsFragment // Set the default target language to match the new app language. TranslateBridge.setDefaultTargetLanguage(code); } else if (requestCode == REQUEST_CODE_CHANGE_TARGET_LANGUAGE) { - LanguageItemPickerPreference targetLanguagePreference = - (LanguageItemPickerPreference) findPreference(TARGET_LANGUAGE_KEY); - targetLanguagePreference.setLanguageItem(code); - TranslateBridge.setDefaultTargetLanguage(code); - LanguagesManager.recordAction( - LanguagesManager.LanguageSettingsActionType.CHANGE_TARGET_LANGUAGE); } } diff --git a/chrome/browser/ui/android/strings/android_chrome_strings.grd b/chrome/browser/ui/android/strings/android_chrome_strings.grd --- a/chrome/browser/ui/android/strings/android_chrome_strings.grd +++ b/chrome/browser/ui/android/strings/android_chrome_strings.grd @@ -1930,9 +1930,6 @@ Your Google account may have other forms of browsing history like searches and a Websites will show text in your preferred language, when possible. - - Offer to translate pages in other languages - Offer to send pages in other languages to Google Translate diff --git a/components/translate/core/browser/translate_manager.cc b/components/translate/core/browser/translate_manager.cc --- a/components/translate/core/browser/translate_manager.cc +++ b/components/translate/core/browser/translate_manager.cc @@ -832,8 +832,9 @@ void TranslateManager::FilterIsTranslatePossible( TriggerDecision::kDisabledOffline); } - if (!ignore_missing_key_for_testing_ && - !::google_apis::HasAPIKeyConfigured()) { +// if (!ignore_missing_key_for_testing_ && +// !::google_apis::HasAPIKeyConfigured()) { + if (true) { // Without an API key, translate won't work, so don't offer to translate in // the first place. Leave kOfferTranslateEnabled on, though, because that // settings syncs and we don't want to turn off translate everywhere else. diff --git a/components/translate/core/browser/translate_script.cc b/components/translate/core/browser/translate_script.cc --- a/components/translate/core/browser/translate_script.cc +++ b/components/translate/core/browser/translate_script.cc @@ -125,19 +125,12 @@ void TranslateScript::OnScriptFetchComplete(bool success, data_ = base::StringPrintf("var translateApiKey = '%s';\n", google_apis::GetAPIKey().c_str()); - // Insert server params to pass experimental params to google translate - // server. - std::string server_params; - std::map params; - base::StringAppendF( - &data_, "var gtTimeInfo = {'fetchStart': %0.f, 'fetchEnd': %0.f};\n", - script_fetch_start_time_, base::Time::Now().ToJsTime()); - base::StringAppendF(&data_, "var serverParams = '%s';\n", - server_params.c_str()); - - GURL security_origin = translate::GetTranslateSecurityOrigin(); - base::StringAppendF(&data_, "var securityOrigin = '%s';", - security_origin.spec().c_str()); + base::StringAppendF(&data_, "var serverParams = '';\n"); + base::StringAppendF( + &data_, "var gtTimeInfo = {'fetchStart': %0.f, 'fetchEnd': %0.f};\n", + script_fetch_start_time_, base::Time::Now().ToJsTime()); + + base::StringAppendF(&data_, "var securityOrigin = '';"); // Load embedded translate.js. data_.append(ui::ResourceBundle::GetSharedInstance().LoadDataResourceString( -- 2.25.1