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 CHROME_BROWSER_TRANSLATE_TRANSLATE_ACCEPT_LANGUAGES_H_
6 #define CHROME_BROWSER_TRANSLATE_TRANSLATE_ACCEPT_LANGUAGES_H_
11 #include "base/basictypes.h"
12 #include "base/prefs/pref_change_registrar.h"
16 // TranslateAcceptLanguages tracks the value of the "Accept-Language" HTTP
18 class TranslateAcceptLanguages {
21 // |accept_languages_pref| is the path to the preference storing the accept
23 TranslateAcceptLanguages(PrefService* prefs,
24 const char* accept_languages_pref);
25 virtual ~TranslateAcceptLanguages();
27 // Returns true if |language| is available as Accept-Languages. |language|
28 // will be converted if it has the synonym of accept language.
29 static bool CanBeAcceptLanguage(const std::string& language);
31 // Returns true if the passed language has been configured by the user as an
32 // accept language. |language| will be converted if it has the synonym of
34 bool IsAcceptLanguage(const std::string& language);
37 // Initializes the |accept_languages_| language table based on the associated
38 // preference in |prefs|.
39 void InitAcceptLanguages(PrefService* prefs);
41 // Set of accept languages.
42 std::set<std::string> accept_languages_;
44 // Listens to accept languages changes.
45 PrefChangeRegistrar pref_change_registrar_;
47 // Path of accept languages preference.
48 const std::string accept_languages_pref_;
50 DISALLOW_COPY_AND_ASSIGN(TranslateAcceptLanguages);
53 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_ACCEPT_LANGUAGES_H_