diff options
author | Peter Varga <pvarga@inf.u-szeged.hu> | 2016-05-24 17:08:09 +0200 |
---|---|---|
committer | Peter Varga <pvarga@inf.u-szeged.hu> | 2016-07-13 21:12:03 +0000 |
commit | 89319455c36d48fe46a8501edd3c174c1de291fb (patch) | |
tree | 8ba7c33284a0b973090eb5de322ef466a859fbcf /src/core/content_browser_client_qt.cpp | |
parent | 9bb9076c50048913075f11692f784ebb959d63cf (diff) |
Fix changing locale of ResourceBundle on Linux
The ResourceBundle is not re-initialized for new Renderer Processes
because it is initialized only once in Zygote Process. This means runtime
locale changes do not affect new Renderer Processes. Zygote Process is
supported on Linux only thus other platforms don't need this fix.
With this change the locale of the ResourceBundle is reloaded when
new Renderer Process is started. For accessing the pak file of the locale
in the sandboxed environment the file descriptor is passed via the Chromium's
GlobalDescriptor solution.
Task-number: QTBUG-53000
Change-Id: I57e84078db9d0795d16d930aa1b3e93a6e86ec39
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/core/content_browser_client_qt.cpp')
-rw-r--r-- | src/core/content_browser_client_qt.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp index 8da5e2611..0c3acd37b 100644 --- a/src/core/content_browser_client_qt.cpp +++ b/src/core/content_browser_client_qt.cpp @@ -85,6 +85,11 @@ #include "web_engine_context.h" #include "web_engine_library_info.h" +#if defined(Q_OS_LINUX) +#include "global_descriptors_qt.h" +#include "ui/base/resource/resource_bundle.h" +#endif + #if defined(ENABLE_PLUGINS) #include "content/public/browser/browser_ppapi_host.h" #include "ppapi/host/ppapi_host.h" @@ -457,6 +462,22 @@ void ContentBrowserClientQt::AppendExtraCommandLineSwitches(base::CommandLine* c command_line->AppendSwitchASCII(switches::kLang, GetApplicationLocale()); } +#if defined(Q_OS_LINUX) +void ContentBrowserClientQt::GetAdditionalMappedFilesForChildProcess(const base::CommandLine& command_line, int child_process_id, content::FileDescriptorInfo* mappings) +{ + const std::string &locale = GetApplicationLocale(); + const base::FilePath &locale_file_path = ui::ResourceBundle::GetSharedInstance().GetLocaleFilePath(locale, true); + if (locale_file_path.empty()) + return; + + // Open pak file of the current locale in the Browser process and pass its file descriptor to the sandboxed + // Renderer Process. FileDescriptorInfo is responsible for closing the file descriptor. + int flags = base::File::FLAG_OPEN | base::File::FLAG_READ; + base::File locale_file = base::File(locale_file_path, flags); + mappings->Transfer(kWebEngineLocale, base::ScopedFD(locale_file.TakePlatformFile())); +} +#endif + #if defined(ENABLE_PLUGINS) void ContentBrowserClientQt::DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) { browser_host->GetPpapiHost()->AddHostFactoryFilter( |