Roll src/third_party/WebKit eac3800:0237a66 (svn 202606:202607)
[chromium-blink-merge.git] / components / translate / core / browser / translate_accept_languages.h
blob33b88847cade8129b760b2ad14fa148c19fa8e04
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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_ACCEPT_LANGUAGES_H_
6 #define COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_ACCEPT_LANGUAGES_H_
8 #include <set>
9 #include <string>
11 #include "base/basictypes.h"
12 #include "base/prefs/pref_change_registrar.h"
14 class PrefService;
16 namespace translate {
18 // TranslateAcceptLanguages tracks the value of the "Accept-Language" HTTP
19 // header.
20 class TranslateAcceptLanguages {
21 public:
22 // |accept_languages_pref| is the path to the preference storing the accept
23 // languages.
24 TranslateAcceptLanguages(PrefService* prefs,
25 const char* accept_languages_pref);
26 virtual ~TranslateAcceptLanguages();
28 // Returns true if |language| is available as Accept-Languages. |language|
29 // will be converted if it has the synonym of accept language.
30 static bool CanBeAcceptLanguage(const std::string& language);
32 // Returns true if the passed language has been configured by the user as an
33 // accept language. |language| will be converted if it has the synonym of
34 // accept languages.
35 bool IsAcceptLanguage(const std::string& language);
37 private:
38 // Initializes the |accept_languages_| language table based on the associated
39 // preference in |prefs|.
40 void InitAcceptLanguages(PrefService* prefs);
42 // Set of accept languages.
43 std::set<std::string> accept_languages_;
45 // Listens to accept languages changes.
46 PrefChangeRegistrar pref_change_registrar_;
48 // Path of accept languages preference.
49 const std::string accept_languages_pref_;
51 DISALLOW_COPY_AND_ASSIGN(TranslateAcceptLanguages);
54 } // namespace translate
56 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_ACCEPT_LANGUAGES_H_