Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ios / chrome / browser / net / ios_chrome_http_user_agent_settings.h
blob5be34bcf4f1f77437b279e3fac483d4d90147c8f
1 // Copyright 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.
5 #ifndef IOS_CHROME_BROWSER_NET_IOS_CHROME_HTTP_USER_AGENT_SETTINGS_H_
6 #define IOS_CHROME_BROWSER_NET_IOS_CHROME_HTTP_USER_AGENT_SETTINGS_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/macros.h"
13 #include "base/prefs/pref_member.h"
14 #include "net/url_request/http_user_agent_settings.h"
16 class PrefService;
18 // An implementation of |HttpUserAgentSettings| that provides HTTP header
19 // Accept-Language value that tracks Pref settings.
20 class IOSChromeHttpUserAgentSettings : public net::HttpUserAgentSettings {
21 public:
22 // Must be called on the UI thread.
23 explicit IOSChromeHttpUserAgentSettings(PrefService* prefs);
24 // Must be called on the IO thread.
25 ~IOSChromeHttpUserAgentSettings() override;
27 void CleanupOnUIThread();
29 // net::HttpUserAgentSettings implementation
30 std::string GetAcceptLanguage() const override;
31 std::string GetUserAgent() const override;
33 private:
34 StringPrefMember pref_accept_language_;
36 // Avoid re-processing by caching the last value from the preferences and the
37 // last result of processing via net::HttpUtil::GenerateAccept*Header().
38 mutable std::string last_pref_accept_language_;
39 mutable std::string last_http_accept_language_;
41 DISALLOW_COPY_AND_ASSIGN(IOSChromeHttpUserAgentSettings);
44 #endif // IOS_CHROME_BROWSER_NET_IOS_CHROME_HTTP_USER_AGENT_SETTINGS_H_