diff options
Diffstat (limited to 'www/chromium-uc/patches/core/ungoogled-chromium/toggle-translation-via-switch.patch')
| -rw-r--r-- | www/chromium-uc/patches/core/ungoogled-chromium/toggle-translation-via-switch.patch | 115 |
1 files changed, 0 insertions, 115 deletions
diff --git a/www/chromium-uc/patches/core/ungoogled-chromium/toggle-translation-via-switch.patch b/www/chromium-uc/patches/core/ungoogled-chromium/toggle-translation-via-switch.patch deleted file mode 100644 index 50efc58..0000000 --- a/www/chromium-uc/patches/core/ungoogled-chromium/toggle-translation-via-switch.patch +++ /dev/null | |||
| @@ -1,115 +0,0 @@ | |||
| 1 | # Disables translation and removes the "Translate to" context menu when --translate-script-url flag is not set | ||
| 2 | --- chrome/browser/renderer_context_menu/render_view_context_menu.cc.orig | ||
| 3 | +++ chrome/browser/renderer_context_menu/render_view_context_menu.cc | ||
| 4 | @@ -133,6 +133,7 @@ | ||
| 5 | #include "components/spellcheck/common/spellcheck_common.h" | ||
| 6 | #include "components/spellcheck/spellcheck_buildflags.h" | ||
| 7 | #include "components/strings/grit/components_strings.h" | ||
| 8 | +#include "components/translate/core/common/translate_switches.h" | ||
| 9 | #include "components/translate/core/browser/translate_download_manager.h" | ||
| 10 | #include "components/translate/core/browser/translate_manager.h" | ||
| 11 | #include "components/translate/core/browser/translate_prefs.h" | ||
| 12 | @@ -1751,6 +1752,8 @@ void RenderViewContextMenu::AppendPageIt | ||
| 13 | menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); | ||
| 14 | } | ||
| 15 | |||
| 16 | + const base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); | ||
| 17 | + if (command_line.HasSwitch(translate::switches::kTranslateScriptURL)) { | ||
| 18 | ChromeTranslateClient* chrome_translate_client = | ||
| 19 | ChromeTranslateClient::FromWebContents(embedder_web_contents_); | ||
| 20 | const bool canTranslate = | ||
| 21 | @@ -1772,6 +1775,7 @@ void RenderViewContextMenu::AppendPageIt | ||
| 22 | IDC_CONTENT_CONTEXT_TRANSLATE, | ||
| 23 | l10n_util::GetStringFUTF16(IDS_CONTENT_CONTEXT_TRANSLATE, language)); | ||
| 24 | } | ||
| 25 | + } // if (command_line.HasSwitch(translate::switches::kTranslateScriptURL)) | ||
| 26 | } | ||
| 27 | |||
| 28 | void RenderViewContextMenu::AppendExitFullscreenItem() { | ||
| 29 | --- components/translate/core/browser/translate_language_list.cc.orig | ||
| 30 | +++ components/translate/core/browser/translate_language_list.cc | ||
| 31 | @@ -11,6 +11,7 @@ | ||
| 32 | |||
| 33 | #include "base/bind.h" | ||
| 34 | #include "base/check.h" | ||
| 35 | +#include "base/command_line.h" | ||
| 36 | #include "base/json/json_reader.h" | ||
| 37 | #include "base/lazy_instance.h" | ||
| 38 | #include "base/notreached.h" | ||
| 39 | @@ -23,6 +24,7 @@ | ||
| 40 | #include "components/translate/core/browser/translate_event_details.h" | ||
| 41 | #include "components/translate/core/browser/translate_url_fetcher.h" | ||
| 42 | #include "components/translate/core/browser/translate_url_util.h" | ||
| 43 | +#include "components/translate/core/common/translate_switches.h" | ||
| 44 | #include "components/translate/core/common/translate_util.h" | ||
| 45 | #include "net/base/url_util.h" | ||
| 46 | #include "third_party/abseil-cpp/absl/types/optional.h" | ||
| 47 | @@ -219,6 +221,9 @@ GURL TranslateLanguageList::TranslateLan | ||
| 48 | } | ||
| 49 | |||
| 50 | void TranslateLanguageList::RequestLanguageList() { | ||
| 51 | + const base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); | ||
| 52 | + if (!command_line.HasSwitch(translate::switches::kTranslateScriptURL)) | ||
| 53 | + return; | ||
| 54 | // If resource requests are not allowed, we'll get a callback when they are. | ||
| 55 | if (!resource_requests_allowed_) { | ||
| 56 | request_pending_ = true; | ||
| 57 | --- components/translate/core/browser/translate_manager.cc.orig | ||
| 58 | +++ components/translate/core/browser/translate_manager.cc | ||
| 59 | @@ -887,8 +887,9 @@ void TranslateManager::FilterIsTranslate | ||
| 60 | ->LogAutofillAssistantDeferredTriggerDecision(); | ||
| 61 | } | ||
| 62 | |||
| 63 | - if (!ignore_missing_key_for_testing_ && | ||
| 64 | - !::google_apis::HasAPIKeyConfigured()) { | ||
| 65 | + const base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); | ||
| 66 | + if (!command_line.HasSwitch(translate::switches::kTranslateScriptURL) || | ||
| 67 | + (!ignore_missing_key_for_testing_ && !::google_apis::HasAPIKeyConfigured())) { | ||
| 68 | // Without an API key, translate won't work, so don't offer to translate in | ||
| 69 | // the first place. Leave kOfferTranslateEnabled on, though, because that | ||
| 70 | // settings syncs and we don't want to turn off translate everywhere else. | ||
| 71 | --- components/translate/core/browser/translate_ranker_impl.cc.orig | ||
| 72 | +++ components/translate/core/browser/translate_ranker_impl.cc | ||
| 73 | @@ -156,12 +156,9 @@ TranslateRankerImpl::TranslateRankerImpl | ||
| 74 | ukm::UkmRecorder* ukm_recorder) | ||
| 75 | : ukm_recorder_(ukm_recorder), | ||
| 76 | is_uma_logging_enabled_(false), | ||
| 77 | - is_query_enabled_(base::FeatureList::IsEnabled(kTranslateRankerQuery)), | ||
| 78 | - is_enforcement_enabled_( | ||
| 79 | - base::FeatureList::IsEnabled(kTranslateRankerEnforcement)), | ||
| 80 | - is_previous_language_matches_override_enabled_( | ||
| 81 | - base::FeatureList::IsEnabled( | ||
| 82 | - translate::kTranslateRankerPreviousLanguageMatchesOverride)) { | ||
| 83 | + is_query_enabled_(false), | ||
| 84 | + is_enforcement_enabled_(false), | ||
| 85 | + is_previous_language_matches_override_enabled_(false) { | ||
| 86 | if (is_query_enabled_ || is_enforcement_enabled_) { | ||
| 87 | model_loader_ = std::make_unique<assist_ranker::RankerModelLoaderImpl>( | ||
| 88 | base::BindRepeating(&ValidateModel), | ||
| 89 | @@ -235,6 +232,8 @@ bool TranslateRankerImpl::ShouldOfferTra | ||
| 90 | // (or become False). | ||
| 91 | const bool kDefaultResponse = true; | ||
| 92 | |||
| 93 | + return kDefaultResponse; | ||
| 94 | + | ||
| 95 | translate_event->set_ranker_request_timestamp_sec( | ||
| 96 | (base::TimeTicks::Now() - base::TimeTicks()).InSeconds()); | ||
| 97 | translate_event->set_ranker_version(GetModelVersion()); | ||
| 98 | --- components/translate/core/browser/translate_script.cc.orig | ||
| 99 | +++ components/translate/core/browser/translate_script.cc | ||
| 100 | @@ -137,8 +137,13 @@ void TranslateScript::OnScriptFetchCompl | ||
| 101 | server_params.c_str()); | ||
| 102 | |||
| 103 | GURL security_origin = translate::GetTranslateSecurityOrigin(); | ||
| 104 | - base::StringAppendF(&data_, "var securityOrigin = '%s';", | ||
| 105 | - security_origin.spec().c_str()); | ||
| 106 | + const base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); | ||
| 107 | + if (command_line.HasSwitch(translate::switches::kTranslateScriptURL)) { | ||
| 108 | + base::StringAppendF(&data_, "var securityOrigin = '%s';", | ||
| 109 | + security_origin.spec().c_str()); | ||
| 110 | + } else { | ||
| 111 | + base::StringAppendF(&data_, "var securityOrigin = '';"); | ||
| 112 | + } | ||
| 113 | |||
| 114 | // Load embedded translate.js. | ||
| 115 | data_.append(ui::ResourceBundle::GetSharedInstance().LoadDataResourceString( | ||
