diff options
author | Szabolcs David <davidsz@inf.u-szeged.hu> | 2021-03-24 14:23:31 +0100 |
---|---|---|
committer | Szabolcs David <davidsz@inf.u-szeged.hu> | 2021-04-21 16:09:49 +0200 |
commit | 0b7510efcde8220e55b0cef5fefc1db76a3bd99a (patch) | |
tree | 5e1c9399185d2484cd880d8910d237cce4f407ea /src/core/content_browser_client_qt.cpp | |
parent | b29b245fcb9db741d14180ea7e8dcb3ad2d4f49a (diff) |
Fix application locales again
Different countries (with the same language) can have different number
formatting and navigator.language should report not only the language,
but also the country. Locale normalization often falls back by cutting
the country off, because we have common .pak files for countries with
the same language.
This patch:
- Uses the locale resolvation only for concatenating .pak file paths
and reports the full locale everywhere else.
- Properly sets default ICU locale for JS number formats and prevents
l10n_util::GetApplicationLocale() to set it sneakily to some resolved
one.
- Fixes the crashing --lang command line argument and always prefers
its value over QLocale.
Task-number: QTBUG-91225
Change-Id: I1c09798abdb523b80f0b7a3d69fa8d7a08c7c09a
Reviewed-by: Kirill Burtsev <kirill.burtsev@qt.io>
Diffstat (limited to 'src/core/content_browser_client_qt.cpp')
-rw-r--r-- | src/core/content_browser_client_qt.cpp | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp index 76f94c61f..24aa19c91 100644 --- a/src/core/content_browser_client_qt.cpp +++ b/src/core/content_browser_client_qt.cpp @@ -39,6 +39,7 @@ #include "content_browser_client_qt.h" +#include "base/files/file_util.h" #include "base/optional.h" #include "base/task/post_task.h" #include "chrome/browser/custom_handlers/protocol_handler_registry.h" @@ -479,12 +480,7 @@ std::unique_ptr<net::ClientCertStore> ContentBrowserClientQt::CreateClientCertSt std::string ContentBrowserClientQt::GetApplicationLocale() { - std::string bcp47Name = QLocale().bcp47Name().toStdString(); - if (m_cachedQtLocale != bcp47Name) { - m_cachedQtLocale = bcp47Name; - m_appLocale = WebEngineLibraryInfo::getApplicationLocale(); - } - return m_appLocale; + return WebEngineLibraryInfo::getApplicationLocale(); } std::string ContentBrowserClientQt::GetAcceptLangs(content::BrowserContext *context) @@ -500,7 +496,7 @@ void ContentBrowserClientQt::AppendExtraCommandLineSwitches(base::CommandLine* c std::string processType = command_line->GetSwitchValueASCII(switches::kProcessType); if (processType == switches::kZygoteProcess) - command_line->AppendSwitchASCII(switches::kLang, GetApplicationLocale()); + command_line->AppendSwitchASCII(switches::kLang, WebEngineLibraryInfo::getApplicationLocale()); } void ContentBrowserClientQt::GetAdditionalWebUISchemes(std::vector<std::string>* additional_schemes) @@ -528,9 +524,8 @@ void ContentBrowserClientQt::GetAdditionalAllowedSchemesForFileSystem(std::vecto #if defined(Q_OS_LINUX) void ContentBrowserClientQt::GetAdditionalMappedFilesForChildProcess(const base::CommandLine& command_line, int child_process_id, content::PosixFileDescriptorInfo* mappings) { - const std::string &locale = GetApplicationLocale(); - const base::FilePath &locale_file_path = ui::ResourceBundle::GetSharedInstance().GetLocaleFilePath(locale); - if (locale_file_path.empty()) + const base::FilePath &locale_file_path = ui::ResourceBundle::GetSharedInstance().GetLocaleFilePath(WebEngineLibraryInfo::getResolvedLocale()); + if (locale_file_path.empty() || !base::PathExists(locale_file_path)) return; // Open pak file of the current locale in the Browser process and pass its file descriptor to the sandboxed |