Skip to content

Commit 49a5981

Browse files
committed
Override lang setting from cmdline argument
1 parent fdcc9ed commit 49a5981

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

src/net/shell_url_request_context_getter.cc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "content/nw/src/net/app_protocol_handler.h"
3232
#include "content/nw/src/nw_protocol_handler.h"
3333
#include "content/nw/src/nw_shell.h"
34+
#include "content/nw/src/shell_content_browser_client.h"
3435
#include "net/cert/cert_verifier.h"
3536
#include "net/ssl/default_server_bound_cert_store.h"
3637
#include "net/dns/host_resolver.h"
@@ -109,7 +110,11 @@ net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() {
109110
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
110111

111112
if (!url_request_context_.get()) {
112-
url_request_context_.reset(new net::URLRequestContext());
113+
ShellContentBrowserClient* browser_client =
114+
static_cast<ShellContentBrowserClient*>(
115+
GetContentClient()->browser());
116+
117+
url_request_context_.reset(new net::URLRequestContext());
113118
network_delegate_.reset(new ShellNetworkDelegate);
114119
url_request_context_->set_network_delegate(network_delegate_.get());
115120
storage_.reset(
@@ -132,7 +137,7 @@ net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() {
132137
new net::DefaultServerBoundCertStore(NULL),
133138
base::WorkerPool::GetTaskRunner(true)));
134139

135-
std::string accept_lang = l10n_util::GetApplicationLocale(std::string());
140+
std::string accept_lang = browser_client->GetApplicationLocale();
136141
if (accept_lang.empty())
137142
accept_lang = "en-us,en";
138143
else

src/shell_content_browser_client.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
#include "geolocation/shell_access_token_store.h"
5757
#include "url/gurl.h"
5858
#include "ui/base/l10n/l10n_util.h"
59+
#include "ui/base/ui_base_switches.h"
5960
#include "content/common/dom_storage/dom_storage_map.h"
6061
#include "webkit/common/webpreferences.h"
6162
#include "webkit/common/user_agent/user_agent_util.h"
@@ -135,7 +136,12 @@ WebContentsViewPort* ShellContentBrowserClient::OverrideCreateWebContentsView(
135136
}
136137

137138
std::string ShellContentBrowserClient::GetApplicationLocale() {
138-
return l10n_util::GetApplicationLocale(std::string());
139+
CommandLine* cmd_line = CommandLine::ForCurrentProcess();
140+
std::string pref_locale;
141+
if (cmd_line->HasSwitch(switches::kLang)) {
142+
pref_locale = cmd_line->GetSwitchValueASCII(switches::kLang);
143+
}
144+
return l10n_util::GetApplicationLocale(pref_locale);
139145
}
140146

141147
void ShellContentBrowserClient::AppendExtraCommandLineSwitches(

src/shell_main_delegate.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ bool ShellMainDelegate::BasicStartupComplete(int* exit_code) {
137137

138138
void ShellMainDelegate::PreSandboxStartup() {
139139
breakpad::SetBreakpadClient(g_chrome_breakpad_client.Pointer());
140+
CommandLine* command_line = CommandLine::ForCurrentProcess();
140141

141142
#if defined(OS_MACOSX)
142143
OverrideFrameworkBundlePath();
@@ -145,7 +146,6 @@ void ShellMainDelegate::PreSandboxStartup() {
145146
#endif // OS_MACOSX
146147
InitializeResourceBundle();
147148

148-
CommandLine* command_line = CommandLine::ForCurrentProcess();
149149
std::string process_type =
150150
command_line->GetSwitchValueASCII(switches::kProcessType);
151151

0 commit comments

Comments
 (0)