Popular sites on the NTP: re-download popular suggestions once per Chrome run
[chromium-blink-merge.git] / chrome / browser / net / chrome_http_user_agent_settings.h
blob8612b3c1858e3bc26a9ded552a1be1b44438a282
1 // Copyright (c) 2012 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 CHROME_BROWSER_NET_CHROME_HTTP_USER_AGENT_SETTINGS_H_
6 #define CHROME_BROWSER_NET_CHROME_HTTP_USER_AGENT_SETTINGS_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/prefs/pref_member.h"
13 #include "net/url_request/http_user_agent_settings.h"
15 class PrefService;
17 // An implementation of |HttpUserAgentSettings| that provides HTTP header
18 // Accept-Language value that tracks Pref settings.
19 class ChromeHttpUserAgentSettings : public net::HttpUserAgentSettings {
20 public:
21 // Must be called on the UI thread.
22 explicit ChromeHttpUserAgentSettings(PrefService* prefs);
23 // Must be called on the IO thread.
24 ~ChromeHttpUserAgentSettings() override;
26 void CleanupOnUIThread();
28 // net::HttpUserAgentSettings implementation
29 std::string GetAcceptLanguage() const override;
30 std::string GetUserAgent() const override;
32 private:
33 StringPrefMember pref_accept_language_;
35 // Avoid re-processing by caching the last value from the preferences and the
36 // last result of processing via net::HttpUtil::GenerateAccept*Header().
37 mutable std::string last_pref_accept_language_;
38 mutable std::string last_http_accept_language_;
40 DISALLOW_COPY_AND_ASSIGN(ChromeHttpUserAgentSettings);
43 #endif // CHROME_BROWSER_NET_CHROME_HTTP_USER_AGENT_SETTINGS_H_