Index: content/browser/shared_worker/shared_worker_host.cc |
diff --git a/content/browser/shared_worker/shared_worker_host.cc b/content/browser/shared_worker/shared_worker_host.cc |
index 3dd43eb1eae2d890187c2525d4d0a644eac94251..90f90bae3a95939c436a9f8e701e2cdb3bd180a1 100644 |
--- a/content/browser/shared_worker/shared_worker_host.cc |
+++ b/content/browser/shared_worker/shared_worker_host.cc |
@@ -5,6 +5,8 @@ |
#include "content/browser/shared_worker/shared_worker_host.h" |
#include "base/metrics/histogram.h" |
+#include "base/strings/string_split.h" |
+#include "base/strings/utf_string_conversions.h" |
#include "content/browser/devtools/embedded_worker_devtools_manager.h" |
#include "content/browser/frame_host/render_frame_host_delegate.h" |
#include "content/browser/frame_host/render_frame_host_impl.h" |
@@ -18,7 +20,10 @@ |
#include "content/public/browser/browser_thread.h" |
#include "content/public/browser/content_browser_client.h" |
#include "content/public/browser/render_process_host.h" |
+#include "content/public/browser/resource_context.h" |
#include "content/public/common/content_client.h" |
+#include "net/url_request/static_http_user_agent_settings.h" |
+#include "net/url_request/url_request_context.h" |
namespace content { |
namespace { |
@@ -72,6 +77,30 @@ void NotifyWorkerDestroyed(int worker_process_id, int worker_route_id) { |
} // namespace |
+static std::string HttpAcceptHeaderToAcceptLanguagesString( |
+ const std::string& http_accept_languages,const std::string& default_language) |
+{ |
+ std::vector<string> languages; |
+ |
+ if (!http_accept_languages.length()) { |
+ return default_language; |
+ } |
+ base::SplitString(http_accept_languages, ',', &languages); |
+ |
+ std::string accept_languages_string; |
+ for(unsigned int i = 0; i < languages.size(); i++) { |
+ std::string lang = languages[i]; |
+ size_t semi_colon_pos = lang.find(";"); |
+ if(semi_colon_pos != string::npos) |
+ lang.erase(semi_colon_pos, lang.length() - semi_colon_pos); |
+ accept_languages_string.append(lang); |
+ if(i != languages.size() - 1){ |
+ accept_languages_string.append(1, ','); |
+ } |
+ } |
+ return accept_languages_string; |
+} |
+ |
SharedWorkerHost::SharedWorkerHost(SharedWorkerInstance* instance, |
SharedWorkerMessageFilter* filter, |
int worker_route_id) |
@@ -128,6 +157,12 @@ void SharedWorkerHost::Start(bool pause_on_start) { |
params.security_policy_type = instance_->security_policy_type(); |
params.pause_on_start = pause_on_start; |
params.route_id = worker_route_id_; |
+ net::URLRequestContext* req_context = |
+ instance_->resource_context()->GetRequestContext(); |
+ std::string accept_languages_string = HttpAcceptHeaderToAcceptLanguagesString( |
+ req_context->http_user_agent_settings()->GetAcceptLanguage() |
+ , GetContentClient()->browser()->GetApplicationLocale()); |
+ params.accept_languages = base::UTF8ToUTF16(accept_languages_string); |
Send(new WorkerProcessMsg_CreateWorker(params)); |
for (FilterList::const_iterator i = filters_.begin(); i != filters_.end(); |
@@ -366,4 +401,18 @@ void SharedWorkerHost::SetMessagePortID(SharedWorkerMessageFilter* filter, |
} |
} |
+void SharedWorkerHost::AcceptLanguageChanged(const base::string16& languages) |
+{ |
+ WorkerProcessMsg_LanguageChange_Params params; |
+ params.route_id = worker_route_id_; |
+ net::URLRequestContext* req_context = |
+ instance_->resource_context()->GetRequestContext(); |
+ std::string accept_languages_string = HttpAcceptHeaderToAcceptLanguagesString( |
+ req_context->http_user_agent_settings()->GetAcceptLanguage() |
+ , GetContentClient()->browser()->GetApplicationLocale()); |
+ params.accept_languages = base::UTF8ToUTF16(accept_languages_string); |
+ Send(new WorkerProcessMsg_LanguageChange(params)); |
+} |
+ |
+ |
} // namespace content |