1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chromecast/browser/cast_http_user_agent_settings.h"
7 #include "base/logging.h"
8 #include "chromecast/common/cast_content_client.h"
9 #include "content/public/browser/browser_thread.h"
10 #include "grit/chromecast_settings.h"
11 #include "net/http/http_util.h"
12 #include "ui/base/l10n/l10n_util.h"
14 #if defined(OS_ANDROID)
15 #include "base/android/locale_utils.h"
16 #endif // defined(OS_ANDROID)
18 namespace chromecast
{
21 CastHttpUserAgentSettings::CastHttpUserAgentSettings() {
22 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI
));
25 CastHttpUserAgentSettings::~CastHttpUserAgentSettings() {
26 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI
));
29 std::string
CastHttpUserAgentSettings::GetAcceptLanguage() const {
30 DCHECK_CURRENTLY_ON(content::BrowserThread::IO
);
31 if (accept_language_
.empty()) {
32 accept_language_
= net::HttpUtil::GenerateAcceptLanguageHeader(
33 #if defined(OS_ANDROID)
34 base::android::GetDefaultLocale()
36 l10n_util::GetStringUTF8(IDS_CHROMECAST_SETTINGS_ACCEPT_LANGUAGES
)
37 #endif // defined(OS_ANDROID)
40 return accept_language_
;
43 std::string
CastHttpUserAgentSettings::GetUserAgent() const {
44 return chromecast::shell::GetUserAgent();
48 } // namespace chromecast