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_
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
{
22 // |accept_languages_pref| is the path to the preference storing the accept
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
35 bool IsAcceptLanguage(const std::string
& language
);
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_