browser: get accept-language header from system locale
This commit is contained in:
parent
442db4c5ba
commit
fb5260eb30
1 changed files with 8 additions and 2 deletions
|
@ -52,6 +52,7 @@
|
||||||
#include "net/url_request/static_http_user_agent_settings.h"
|
#include "net/url_request/static_http_user_agent_settings.h"
|
||||||
#include "net/url_request/url_request_context.h"
|
#include "net/url_request/url_request_context.h"
|
||||||
#include "third_party/WebKit/public/web/WebInputEvent.h"
|
#include "third_party/WebKit/public/web/WebInputEvent.h"
|
||||||
|
#include "ui/base/l10n/l10n_util.h"
|
||||||
|
|
||||||
#include "atom/common/node_includes.h"
|
#include "atom/common/node_includes.h"
|
||||||
|
|
||||||
|
@ -63,9 +64,12 @@ struct PrintSettings {
|
||||||
};
|
};
|
||||||
|
|
||||||
void SetUserAgentInIO(scoped_refptr<net::URLRequestContextGetter> getter,
|
void SetUserAgentInIO(scoped_refptr<net::URLRequestContextGetter> getter,
|
||||||
|
std::string accept_lang,
|
||||||
std::string user_agent) {
|
std::string user_agent) {
|
||||||
getter->GetURLRequestContext()->set_http_user_agent_settings(
|
getter->GetURLRequestContext()->set_http_user_agent_settings(
|
||||||
new net::StaticHttpUserAgentSettings("en-us,en", user_agent));
|
new net::StaticHttpUserAgentSettings(
|
||||||
|
net::HttpUtil::GenerateAcceptLanguageHeader(accept_lang),
|
||||||
|
user_agent));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NotifyZoomLevelChanged(
|
bool NotifyZoomLevelChanged(
|
||||||
|
@ -647,8 +651,10 @@ void WebContents::SetUserAgent(const std::string& user_agent) {
|
||||||
web_contents()->SetUserAgentOverride(user_agent);
|
web_contents()->SetUserAgentOverride(user_agent);
|
||||||
scoped_refptr<net::URLRequestContextGetter> getter =
|
scoped_refptr<net::URLRequestContextGetter> getter =
|
||||||
web_contents()->GetBrowserContext()->GetRequestContext();
|
web_contents()->GetBrowserContext()->GetRequestContext();
|
||||||
|
|
||||||
|
auto accept_lang = l10n_util::GetApplicationLocale("");
|
||||||
getter->GetNetworkTaskRunner()->PostTask(FROM_HERE,
|
getter->GetNetworkTaskRunner()->PostTask(FROM_HERE,
|
||||||
base::Bind(&SetUserAgentInIO, getter, user_agent));
|
base::Bind(&SetUserAgentInIO, getter, accept_lang, user_agent));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string WebContents::GetUserAgent() {
|
std::string WebContents::GetUserAgent() {
|
||||||
|
|
Loading…
Reference in a new issue