Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: chromecast/browser/cast_http_user_agent_settings.cc

Issue 964713002: Chromecast: get locale from ICU instead of caching permanently. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chromecast/browser/cast_http_user_agent_settings.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/logging.h" 8 #include "base/logging.h"
8 #include "chromecast/common/cast_content_client.h" 9 #include "chromecast/common/cast_content_client.h"
9 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
10 #include "grit/chromecast_settings.h" 11 #include "grit/chromecast_settings.h"
11 #include "net/http/http_util.h" 12 #include "net/http/http_util.h"
12 #include "ui/base/l10n/l10n_util.h" 13 #include "ui/base/l10n/l10n_util.h"
13 14
14 #if defined(OS_ANDROID) 15 #if defined(OS_ANDROID)
15 #include "base/android/locale_utils.h" 16 #include "base/android/locale_utils.h"
16 #endif // defined(OS_ANDROID) 17 #endif // defined(OS_ANDROID)
17 18
18 namespace chromecast { 19 namespace chromecast {
19 namespace shell { 20 namespace shell {
20 21
21 CastHttpUserAgentSettings::CastHttpUserAgentSettings() { 22 CastHttpUserAgentSettings::CastHttpUserAgentSettings() {
22 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 23 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
23 } 24 }
24 25
25 CastHttpUserAgentSettings::~CastHttpUserAgentSettings() { 26 CastHttpUserAgentSettings::~CastHttpUserAgentSettings() {
26 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 27 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
27 } 28 }
28 29
29 std::string CastHttpUserAgentSettings::GetAcceptLanguage() const { 30 std::string CastHttpUserAgentSettings::GetAcceptLanguage() const {
30 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 31 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
31 if (accept_language_.empty()) { 32 std::string new_locale(
33 #if defined(OS_ANDROID)
34 // TODO(byungchul): Use transient locale set when new app starts.
35 base::android::GetDefaultLocale()
36 #else
37 base::i18n::GetConfiguredLocale()
38 #endif
39 );
40 if (new_locale != last_locale_ || accept_language_.empty()) {
41 last_locale_ = new_locale;
32 accept_language_ = net::HttpUtil::GenerateAcceptLanguageHeader( 42 accept_language_ = net::HttpUtil::GenerateAcceptLanguageHeader(
33 #if defined(OS_ANDROID) 43 #if defined(OS_ANDROID)
34 base::android::GetDefaultLocale() 44 last_locale_
35 #else 45 #else
36 l10n_util::GetStringUTF8(IDS_CHROMECAST_SETTINGS_ACCEPT_LANGUAGES) 46 l10n_util::GetStringUTF8(IDS_CHROMECAST_SETTINGS_ACCEPT_LANGUAGES)
37 #endif // defined(OS_ANDROID) 47 #endif
38 ); 48 );
49 LOG(INFO) << "Locale changed: accept_language=" << accept_language_;
39 } 50 }
40 return accept_language_; 51 return accept_language_;
41 } 52 }
42 53
43 std::string CastHttpUserAgentSettings::GetUserAgent() const { 54 std::string CastHttpUserAgentSettings::GetUserAgent() const {
44 return chromecast::shell::GetUserAgent(); 55 return chromecast::shell::GetUserAgent();
45 } 56 }
46 57
47 } // namespace shell 58 } // namespace shell
48 } // namespace chromecast 59 } // namespace chromecast
OLDNEW
« no previous file with comments | « chromecast/browser/cast_http_user_agent_settings.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698