fix: add patch to set the base download URL rather than override it completely (#22382)
This commit is contained in:
parent
3bc6809759
commit
7cae73fe7a
3 changed files with 60 additions and 1 deletions
|
@ -86,3 +86,4 @@ fix_use_native_window_button_positions_when_macos_locale_is_rtl.patch
|
||||||
use_electron_resources_in_pdf_util.patch
|
use_electron_resources_in_pdf_util.patch
|
||||||
hack_plugin_response_interceptor_to_point_to_electron.patch
|
hack_plugin_response_interceptor_to_point_to_electron.patch
|
||||||
fix_route_mouse_event_navigations_through_the_web_contents_delegate.patch
|
fix_route_mouse_event_navigations_through_the_web_contents_delegate.patch
|
||||||
|
feat_add_support_for_overriding_the_base_spellchecker_download_url.patch
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Samuel Attard <sattard@slack-corp.com>
|
||||||
|
Date: Tue, 25 Feb 2020 13:28:30 -0800
|
||||||
|
Subject: feat: add support for overriding the base spellchecker download URL
|
||||||
|
|
||||||
|
This patch is required as the testing-only method we were using does not
|
||||||
|
take into account the dictionary name and therefore will not work for
|
||||||
|
production use cases. This is unlikely to be upstreamed as the change
|
||||||
|
is entirely in //chrome.
|
||||||
|
|
||||||
|
diff --git a/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc b/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc
|
||||||
|
index 0fb84989f9b2f84ec2a2589dda3d91cf59c0adda..9ff5b33d2885c5532e1496711c27a01c8502725c 100644
|
||||||
|
--- a/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc
|
||||||
|
+++ b/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc
|
||||||
|
@@ -48,6 +48,9 @@ namespace {
|
||||||
|
base::LazyInstance<GURL>::Leaky g_download_url_for_testing =
|
||||||
|
LAZY_INSTANCE_INITIALIZER;
|
||||||
|
|
||||||
|
+base::LazyInstance<GURL>::Leaky g_base_download_url_override =
|
||||||
|
+ LAZY_INSTANCE_INITIALIZER;
|
||||||
|
+
|
||||||
|
// Close the file.
|
||||||
|
void CloseDictionary(base::File file) {
|
||||||
|
base::ScopedBlockingCall scoped_blocking_call(FROM_HERE,
|
||||||
|
@@ -247,6 +250,10 @@ void SpellcheckHunspellDictionary::SetDownloadURLForTesting(const GURL url) {
|
||||||
|
g_download_url_for_testing.Get() = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
+void SpellcheckHunspellDictionary::SetBaseDownloadURL(const GURL url) {
|
||||||
|
+ g_base_download_url_override.Get() = url;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
GURL SpellcheckHunspellDictionary::GetDictionaryURL() {
|
||||||
|
if (g_download_url_for_testing.Get() != GURL())
|
||||||
|
return g_download_url_for_testing.Get();
|
||||||
|
@@ -254,6 +261,9 @@ GURL SpellcheckHunspellDictionary::GetDictionaryURL() {
|
||||||
|
std::string bdict_file = dictionary_file_.path.BaseName().MaybeAsASCII();
|
||||||
|
DCHECK(!bdict_file.empty());
|
||||||
|
|
||||||
|
+ if (g_base_download_url_override.Get() != GURL())
|
||||||
|
+ return GURL(g_base_download_url_override.Get().spec() + base::ToLowerASCII(bdict_file));
|
||||||
|
+
|
||||||
|
static const char kDownloadServerUrl[] =
|
||||||
|
"https://redirector.gvt1.com/edgedl/chrome/dict/";
|
||||||
|
|
||||||
|
diff --git a/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.h b/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.h
|
||||||
|
index 4af3201238dfec14bd5a4241b662ca52799e6862..4662bdc08b54304a7f8b2995f60fea9dc5617fff 100644
|
||||||
|
--- a/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.h
|
||||||
|
+++ b/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.h
|
||||||
|
@@ -85,6 +85,8 @@ class SpellcheckHunspellDictionary
|
||||||
|
// Tests use this method to set a custom URL for downloading dictionaries.
|
||||||
|
static void SetDownloadURLForTesting(const GURL url);
|
||||||
|
|
||||||
|
+ static void SetBaseDownloadURL(const GURL url);
|
||||||
|
+
|
||||||
|
private:
|
||||||
|
// Dictionary download status.
|
||||||
|
enum DownloadStatus {
|
|
@ -816,7 +816,7 @@ void SetSpellCheckerDictionaryDownloadURL(gin_helper::ErrorThrower thrower,
|
||||||
"valid URL");
|
"valid URL");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SpellcheckHunspellDictionary::SetDownloadURLForTesting(url);
|
SpellcheckHunspellDictionary::SetBaseDownloadURL(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
v8::Local<v8::Promise> Session::ListWordsInSpellCheckerDictionary() {
|
v8::Local<v8::Promise> Session::ListWordsInSpellCheckerDictionary() {
|
||||||
|
|
Loading…
Reference in a new issue