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"
18 // TranslateAcceptLanguages tracks the value of the "Accept-Language" HTTP
20 class TranslateAcceptLanguages
{
23 // |accept_languages_pref| is the path to the preference storing the accept
25 TranslateAcceptLanguages(PrefService
* prefs
,
26 const char* accept_languages_pref
);
27 virtual ~TranslateAcceptLanguages();
29 // Returns true if |language| is available as Accept-Languages. |language|
30 // will be converted if it has the synonym of accept language.
31 static bool CanBeAcceptLanguage(const std::string
& language
);
33 // Returns true if the passed language has been configured by the user as an
34 // accept language. |language| will be converted if it has the synonym of
36 bool IsAcceptLanguage(const std::string
& language
);
39 // Initializes the |accept_languages_| language table based on the associated
40 // preference in |prefs|.
41 void InitAcceptLanguages(PrefService
* prefs
);
43 // Set of accept languages.
44 std::set
<std::string
> accept_languages_
;
46 // Listens to accept languages changes.
47 PrefChangeRegistrar pref_change_registrar_
;
49 // Path of accept languages preference.
50 const std::string accept_languages_pref_
;
52 DISALLOW_COPY_AND_ASSIGN(TranslateAcceptLanguages
);
55 } // namespace translate
57 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_ACCEPT_LANGUAGES_H_