Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2015 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. | |
| 4 | |
| 5 #include "android_webview/browser/net/aw_http_user_agent_settings.h" | |
| 6 | |
| 7 #include "android_webview/browser/aw_content_browser_client.h" | |
| 8 #include "android_webview/common/aw_content_client.h" | |
| 9 #include "content/public/browser/browser_thread.h" | |
| 10 #include "net/http/http_util.h" | |
| 11 | |
| 12 namespace android_webview { | |
| 13 | |
| 14 AwHttpUserAgentSettings::AwHttpUserAgentSettings() { | |
| 15 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
| 16 last_aw_accept_language_ = | |
|
Torne
2015/07/17 13:33:18
Maybe just do this lazily to avoid duplicating the
ctserng
2015/07/17 16:51:15
Will do.
| |
| 17 AwContentBrowserClient::GetAcceptLangsImpl(); | |
| 18 last_http_accept_language_ = | |
| 19 net::HttpUtil::GenerateAcceptLanguageHeader(last_aw_accept_language_); | |
| 20 } | |
| 21 | |
| 22 AwHttpUserAgentSettings::~AwHttpUserAgentSettings() { | |
| 23 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | |
| 24 } | |
| 25 | |
| 26 std::string AwHttpUserAgentSettings::GetAcceptLanguage() const { | |
| 27 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | |
| 28 std::string new_aw_accept_language = | |
| 29 AwContentBrowserClient::GetAcceptLangsImpl(); | |
| 30 if (new_aw_accept_language != last_aw_accept_language_) { | |
| 31 last_http_accept_language_ = | |
| 32 net::HttpUtil::GenerateAcceptLanguageHeader(new_aw_accept_language); | |
| 33 last_aw_accept_language_ = new_aw_accept_language; | |
| 34 } | |
| 35 return last_http_accept_language_; | |
| 36 } | |
| 37 | |
| 38 std::string AwHttpUserAgentSettings::GetUserAgent() const { | |
| 39 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | |
| 40 return android_webview::GetUserAgent(); | |
| 41 } | |
| 42 | |
| 43 } // namespace android_webview | |
| OLD | NEW |