1116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// Copyright 2014 The Chromium Authors. All rights reserved.
2116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// Use of this source code is governed by a BSD-style license that can be
3116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// found in the LICENSE file.
4116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
5116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "chromecast/shell/browser/cast_http_user_agent_settings.h"
6116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
7116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "base/logging.h"
8116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "chromecast/shell/common/cast_content_client.h"
9116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "content/public/browser/browser_thread.h"
106e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include "grit/chromecast_settings.h"
11116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "net/http/http_util.h"
126e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include "ui/base/l10n/l10n_util.h"
13116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
141320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#if defined(OS_ANDROID)
151320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "ui/base/l10n/l10n_util_android.h"
161320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#endif  // defined(OS_ANDROID)
171320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
18116680a4aac90f2aa7413d9095a592090648e557Ben Murdochnamespace chromecast {
19116680a4aac90f2aa7413d9095a592090648e557Ben Murdochnamespace shell {
20116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
21116680a4aac90f2aa7413d9095a592090648e557Ben MurdochCastHttpUserAgentSettings::CastHttpUserAgentSettings() {
22116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
23116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch}
24116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
25116680a4aac90f2aa7413d9095a592090648e557Ben MurdochCastHttpUserAgentSettings::~CastHttpUserAgentSettings() {
26116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
27116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch}
28116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
29116680a4aac90f2aa7413d9095a592090648e557Ben Murdochstd::string CastHttpUserAgentSettings::GetAcceptLanguage() const {
306e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
316e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  if (accept_language_.empty()) {
326e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)    accept_language_ = net::HttpUtil::GenerateAcceptLanguageHeader(
331320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#if defined(OS_ANDROID)
341320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci        l10n_util::GetDefaultLocale()
351320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#else
361320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci        l10n_util::GetStringUTF8(IDS_CHROMECAST_SETTINGS_ACCEPT_LANGUAGES)
371320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#endif  // defined(OS_ANDROID)
381320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci        );
396e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  }
40116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  return accept_language_;
41116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch}
42116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
43116680a4aac90f2aa7413d9095a592090648e557Ben Murdochstd::string CastHttpUserAgentSettings::GetUserAgent() const {
44116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  return chromecast::shell::GetUserAgent();
45116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch}
46116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
47116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch}  // namespace shell
48116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch}  // namespace chromecast
49