| 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.h" |
| 14 #include "net/http/http_util_icu.h" |
| 14 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
| 15 | 16 |
| 16 #if defined(OS_ANDROID) | 17 #if defined(OS_ANDROID) |
| 17 #include "base/android/locale_utils.h" | 18 #include "base/android/locale_utils.h" |
| 18 #endif // defined(OS_ANDROID) | 19 #endif // defined(OS_ANDROID) |
| 19 | 20 |
| 20 namespace chromecast { | 21 namespace chromecast { |
| 21 namespace shell { | 22 namespace shell { |
| 22 | 23 |
| 23 CastHttpUserAgentSettings::CastHttpUserAgentSettings() { | 24 CastHttpUserAgentSettings::CastHttpUserAgentSettings() { |
| 24 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 25 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 25 } | 26 } |
| 26 | 27 |
| 27 CastHttpUserAgentSettings::~CastHttpUserAgentSettings() { | 28 CastHttpUserAgentSettings::~CastHttpUserAgentSettings() { |
| 28 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 29 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 29 } | 30 } |
| 30 | 31 |
| 31 std::string CastHttpUserAgentSettings::GetAcceptLanguage() const { | 32 std::string CastHttpUserAgentSettings::GetAcceptLanguage() const { |
| 32 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 33 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 33 std::string new_locale( | 34 std::string new_locale( |
| 34 #if defined(OS_ANDROID) | 35 #if defined(OS_ANDROID) |
| 35 // TODO(byungchul): Use transient locale set when new app starts. | 36 // TODO(byungchul): Use transient locale set when new app starts. |
| 36 base::android::GetDefaultLocaleString() | 37 base::android::GetDefaultLocaleString() |
| 37 #else | 38 #else |
| 38 base::i18n::GetConfiguredLocale() | 39 base::i18n::GetConfiguredLocale() |
| 39 #endif | 40 #endif |
| 40 ); | 41 ); |
| 41 if (new_locale != last_locale_ || accept_language_.empty()) { | 42 if (new_locale != last_locale_ || accept_language_.empty()) { |
| 42 last_locale_ = new_locale; | 43 last_locale_ = new_locale; |
| 43 accept_language_ = net::HttpUtil::GenerateAcceptLanguageHeader( | 44 accept_language_ = net::HttpUtilIcu::GenerateAcceptLanguageHeader( |
| 44 #if defined(OS_ANDROID) | 45 #if defined(OS_ANDROID) |
| 45 last_locale_ | 46 last_locale_ |
| 46 #else | 47 #else |
| 47 l10n_util::GetStringUTF8(IDS_CHROMECAST_SETTINGS_ACCEPT_LANGUAGES) | 48 l10n_util::GetStringUTF8(IDS_CHROMECAST_SETTINGS_ACCEPT_LANGUAGES) |
| 48 #endif | 49 #endif |
| 49 ); | 50 ); |
| 50 LOG(INFO) << "Locale changed: accept_language=" << accept_language_; | 51 LOG(INFO) << "Locale changed: accept_language=" << accept_language_; |
| 51 } | 52 } |
| 52 return accept_language_; | 53 return accept_language_; |
| 53 } | 54 } |
| 54 | 55 |
| 55 std::string CastHttpUserAgentSettings::GetUserAgent() const { | 56 std::string CastHttpUserAgentSettings::GetUserAgent() const { |
| 56 return chromecast::shell::GetUserAgent(); | 57 return chromecast::shell::GetUserAgent(); |
| 57 } | 58 } |
| 58 | 59 |
| 59 } // namespace shell | 60 } // namespace shell |
| 60 } // namespace chromecast | 61 } // namespace chromecast |
| OLD | NEW |