| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chromecast/browser/cast_http_user_agent_settings.h" | 5 #include "chromecast/browser/cast_http_user_agent_settings.h" |
| 6 | 6 |
| 7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "chromecast/common/cast_content_client.h" | 10 #include "chromecast/common/cast_content_client.h" |
| 11 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
| 12 #include "grit/chromecast_settings.h" | 12 #include "grit/chromecast_settings.h" |
| 13 #include "net/http/http_util.h" | 13 #include "net/http/http_util_icu.h" |
| 14 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
| 15 | 15 |
| 16 #if defined(OS_ANDROID) | 16 #if defined(OS_ANDROID) |
| 17 #include "base/android/locale_utils.h" | 17 #include "base/android/locale_utils.h" |
| 18 #endif // defined(OS_ANDROID) | 18 #endif // defined(OS_ANDROID) |
| 19 | 19 |
| 20 namespace chromecast { | 20 namespace chromecast { |
| 21 namespace shell { | 21 namespace shell { |
| 22 | 22 |
| 23 CastHttpUserAgentSettings::CastHttpUserAgentSettings() { | 23 CastHttpUserAgentSettings::CastHttpUserAgentSettings() { |
| 24 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 24 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 25 } | 25 } |
| 26 | 26 |
| 27 CastHttpUserAgentSettings::~CastHttpUserAgentSettings() { | 27 CastHttpUserAgentSettings::~CastHttpUserAgentSettings() { |
| 28 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 28 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 29 } | 29 } |
| 30 | 30 |
| 31 std::string CastHttpUserAgentSettings::GetAcceptLanguage() const { | 31 std::string CastHttpUserAgentSettings::GetAcceptLanguage() const { |
| 32 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 32 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 33 std::string new_locale( | 33 std::string new_locale( |
| 34 #if defined(OS_ANDROID) | 34 #if defined(OS_ANDROID) |
| 35 // TODO(byungchul): Use transient locale set when new app starts. | 35 // TODO(byungchul): Use transient locale set when new app starts. |
| 36 base::android::GetDefaultLocaleString() | 36 base::android::GetDefaultLocaleString() |
| 37 #else | 37 #else |
| 38 base::i18n::GetConfiguredLocale() | 38 base::i18n::GetConfiguredLocale() |
| 39 #endif | 39 #endif |
| 40 ); | 40 ); |
| 41 if (new_locale != last_locale_ || accept_language_.empty()) { | 41 if (new_locale != last_locale_ || accept_language_.empty()) { |
| 42 last_locale_ = new_locale; | 42 last_locale_ = new_locale; |
| 43 accept_language_ = net::HttpUtil::GenerateAcceptLanguageHeader( | 43 accept_language_ = net::http_util_icu::GenerateAcceptLanguageHeader( |
| 44 #if defined(OS_ANDROID) | 44 #if defined(OS_ANDROID) |
| 45 last_locale_ | 45 last_locale_ |
| 46 #else | 46 #else |
| 47 l10n_util::GetStringUTF8(IDS_CHROMECAST_SETTINGS_ACCEPT_LANGUAGES) | 47 l10n_util::GetStringUTF8(IDS_CHROMECAST_SETTINGS_ACCEPT_LANGUAGES) |
| 48 #endif | 48 #endif |
| 49 ); | 49 ); |
| 50 LOG(INFO) << "Locale changed: accept_language=" << accept_language_; | 50 LOG(INFO) << "Locale changed: accept_language=" << accept_language_; |
| 51 } | 51 } |
| 52 return accept_language_; | 52 return accept_language_; |
| 53 } | 53 } |
| 54 | 54 |
| 55 std::string CastHttpUserAgentSettings::GetUserAgent() const { | 55 std::string CastHttpUserAgentSettings::GetUserAgent() const { |
| 56 return chromecast::shell::GetUserAgent(); | 56 return chromecast::shell::GetUserAgent(); |
| 57 } | 57 } |
| 58 | 58 |
| 59 } // namespace shell | 59 } // namespace shell |
| 60 } // namespace chromecast | 60 } // namespace chromecast |
| OLD | NEW |