diff options
author | Peter Varga <pvarga@inf.u-szeged.hu> | 2015-04-22 17:00:09 +0200 |
---|---|---|
committer | Peter Varga <pvarga@inf.u-szeged.hu> | 2015-04-23 07:58:07 +0000 |
commit | 611734729f590623455965017567ec7c9db4f9a4 (patch) | |
tree | ffc855ce13ab9ce10af4b16541582944fe0027e5 /src | |
parent | d7ee26965f5fac77e8609c1d812198421023c11c (diff) |
Force to use English language for QML auto tests
Moreover, localization setting via QtWebEngine is fixed. System
localization setting can be overridden by --lang command line argument.
Task-number: QTBUG-45715
Change-Id: I39f3a891e55ee47a57afc394e849ea02b0c76ad5
Reviewed-by: Andras Becsi <andras.becsi@theqtcompany.com>
Reviewed-by: Pierre Rossi <pierre.rossi@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/core/content_browser_client_qt.cpp | 14 | ||||
-rw-r--r-- | src/core/content_browser_client_qt.h | 1 | ||||
-rw-r--r-- | src/core/content_main_delegate_qt.cpp | 2 | ||||
-rw-r--r-- | src/core/web_engine_library_info.cpp | 11 | ||||
-rw-r--r-- | src/core/web_engine_library_info.h | 1 |
5 files changed, 27 insertions, 2 deletions
diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp index 60ca493ca..3d318047b 100644 --- a/src/core/content_browser_client_qt.cpp +++ b/src/core/content_browser_client_qt.cpp @@ -48,8 +48,10 @@ #include "content/public/browser/render_view_host.h" #include "content/public/browser/resource_dispatcher_host.h" #include "content/public/browser/web_contents.h" +#include "content/public/common/content_switches.h" #include "content/public/common/main_function_params.h" #include "content/public/common/url_constants.h" +#include "ui/base/ui_base_switches.h" #include "ui/gfx/screen.h" #include "ui/gl/gl_context.h" #include "ui/gl/gl_implementation.h" @@ -69,6 +71,7 @@ #include "resource_dispatcher_host_delegate_qt.h" #include "user_script_controller_host.h" #include "web_contents_delegate_qt.h" +#include "web_engine_library_info.h" #include <QGuiApplication> #include <QLocale> @@ -441,7 +444,16 @@ content::LocationProvider *ContentBrowserClientQt::OverrideSystemLocationProvide std::string ContentBrowserClientQt::GetApplicationLocale() { - return QLocale().bcp47Name().toStdString(); + return WebEngineLibraryInfo::getApplicationLocale(); +} + +void ContentBrowserClientQt::AppendExtraCommandLineSwitches(base::CommandLine* command_line, int child_process_id) +{ + Q_UNUSED(child_process_id); + + std::string processType = command_line->GetSwitchValueASCII(switches::kProcessType); + if (processType == switches::kZygoteProcess) + command_line->AppendSwitchASCII(switches::kLang, GetApplicationLocale()); } content::DevToolsManagerDelegate* ContentBrowserClientQt::GetDevToolsManagerDelegate() diff --git a/src/core/content_browser_client_qt.h b/src/core/content_browser_client_qt.h index bce8f70e9..0af5ae9d3 100644 --- a/src/core/content_browser_client_qt.h +++ b/src/core/content_browser_client_qt.h @@ -114,6 +114,7 @@ public: virtual blink::WebNotificationPermission CheckDesktopNotificationPermission(const GURL& source_origin, content::ResourceContext* context, int render_process_id) Q_DECL_OVERRIDE; virtual std::string GetApplicationLocale() Q_DECL_OVERRIDE; + virtual void AppendExtraCommandLineSwitches(base::CommandLine* command_line, int child_process_id) Q_DECL_OVERRIDE; private: BrowserMainPartsQt* m_browserMainParts; diff --git a/src/core/content_main_delegate_qt.cpp b/src/core/content_main_delegate_qt.cpp index b8e40a448..4003823b1 100644 --- a/src/core/content_main_delegate_qt.cpp +++ b/src/core/content_main_delegate_qt.cpp @@ -67,7 +67,7 @@ static base::StringPiece PlatformResourceProvider(int key) { void ContentMainDelegateQt::PreSandboxStartup() { net::NetModule::SetResourceProvider(PlatformResourceProvider); - ui::ResourceBundle::InitSharedInstanceWithLocale(QLocale().name().toStdString(), 0, ui::ResourceBundle::LOAD_COMMON_RESOURCES); + ui::ResourceBundle::InitSharedInstanceWithLocale(WebEngineLibraryInfo::getApplicationLocale(), 0, ui::ResourceBundle::LOAD_COMMON_RESOURCES); // Suppress info, warning and error messages per default. int logLevel = logging::LOG_FATAL; diff --git a/src/core/web_engine_library_info.cpp b/src/core/web_engine_library_info.cpp index 17f6b2a05..e78ab09e7 100644 --- a/src/core/web_engine_library_info.cpp +++ b/src/core/web_engine_library_info.cpp @@ -38,9 +38,11 @@ #include "web_engine_library_info.h" #include "base/base_paths.h" +#include "base/command_line.h" #include "base/files/file_util.h" #include "content/public/common/content_paths.h" #include "ui/base/ui_base_paths.h" +#include "ui/base/ui_base_switches.h" #include "type_conversion.h" #include <QByteArray> @@ -289,3 +291,12 @@ base::string16 WebEngineLibraryInfo::getApplicationName() { return toString16(qApp->applicationName()); } + +std::string WebEngineLibraryInfo::getApplicationLocale() +{ + CommandLine *parsedCommandLine = CommandLine::ForCurrentProcess(); + if (!parsedCommandLine->HasSwitch(switches::kLang)) + return QLocale().bcp47Name().toStdString(); + + return parsedCommandLine->GetSwitchValueASCII(switches::kLang); +} diff --git a/src/core/web_engine_library_info.h b/src/core/web_engine_library_info.h index cb7301b63..e85258078 100644 --- a/src/core/web_engine_library_info.h +++ b/src/core/web_engine_library_info.h @@ -49,6 +49,7 @@ public: static base::FilePath getPath(int key); // Called by localized_error in our custom chrome layer static base::string16 getApplicationName(); + static std::string getApplicationLocale(); }; |