diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 3f1a8b594f7c..0b8a9882cd1b 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -52,6 +52,7 @@ #include "net/url_request/static_http_user_agent_settings.h" #include "net/url_request/url_request_context.h" #include "third_party/WebKit/public/web/WebInputEvent.h" +#include "ui/base/l10n/l10n_util.h" #include "atom/common/node_includes.h" @@ -63,9 +64,12 @@ struct PrintSettings { }; void SetUserAgentInIO(scoped_refptr getter, + std::string accept_lang, std::string user_agent) { 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( @@ -647,8 +651,10 @@ void WebContents::SetUserAgent(const std::string& user_agent) { web_contents()->SetUserAgentOverride(user_agent); scoped_refptr getter = web_contents()->GetBrowserContext()->GetRequestContext(); + + auto accept_lang = l10n_util::GetApplicationLocale(""); getter->GetNetworkTaskRunner()->PostTask(FROM_HERE, - base::Bind(&SetUserAgentInIO, getter, user_agent)); + base::Bind(&SetUserAgentInIO, getter, accept_lang, user_agent)); } std::string WebContents::GetUserAgent() {