OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_ACCEPT_LANGUAGES_H_ | 5 #ifndef COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_ACCEPT_LANGUAGES_H_ |
6 #define COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_ACCEPT_LANGUAGES_H_ | 6 #define COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_ACCEPT_LANGUAGES_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... | |
27 | 27 |
28 // Returns true if |language| is available as Accept-Languages. |language| | 28 // Returns true if |language| is available as Accept-Languages. |language| |
29 // will be converted if it has the synonym of accept language. | 29 // will be converted if it has the synonym of accept language. |
30 static bool CanBeAcceptLanguage(const std::string& language); | 30 static bool CanBeAcceptLanguage(const std::string& language); |
31 | 31 |
32 // Returns true if the passed language has been configured by the user as an | 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 | 33 // accept language. |language| will be converted if it has the synonym of |
34 // accept languages. | 34 // accept languages. |
35 bool IsAcceptLanguage(const std::string& language); | 35 bool IsAcceptLanguage(const std::string& language); |
36 | 36 |
37 protected: | |
38 // Default constructor. Used for creating mocks in tests. | |
39 TranslateAcceptLanguages(); | |
groby-ooo-7-16
2017/04/10 20:52:47
I don't think that's necessary - see e.g MockTrans
hamelphi
2017/04/11 22:46:07
Since TranslateAcceptLanguages has a non-default c
hamelphi
2017/04/12 21:10:53
This is not necessary anymore, since I do not call
groby-ooo-7-16
2017/04/20 19:45:57
Just FYI: It crashes on GetString because the prop
| |
40 | |
37 private: | 41 private: |
38 // Initializes the |accept_languages_| language table based on the associated | 42 // Initializes the |accept_languages_| language table based on the associated |
39 // preference in |prefs|. | 43 // preference in |prefs|. |
40 void InitAcceptLanguages(PrefService* prefs); | 44 void InitAcceptLanguages(PrefService* prefs); |
41 | 45 |
42 // Set of accept languages. | 46 // Set of accept languages. |
43 std::set<std::string> accept_languages_; | 47 std::set<std::string> accept_languages_; |
44 | 48 |
45 // Listens to accept languages changes. | 49 // Listens to accept languages changes. |
46 PrefChangeRegistrar pref_change_registrar_; | 50 PrefChangeRegistrar pref_change_registrar_; |
47 | 51 |
48 // Path of accept languages preference. | 52 // Path of accept languages preference. |
49 const std::string accept_languages_pref_; | 53 const std::string accept_languages_pref_; |
50 | 54 |
51 DISALLOW_COPY_AND_ASSIGN(TranslateAcceptLanguages); | 55 DISALLOW_COPY_AND_ASSIGN(TranslateAcceptLanguages); |
52 }; | 56 }; |
53 | 57 |
54 } // namespace translate | 58 } // namespace translate |
55 | 59 |
56 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_ACCEPT_LANGUAGES_H_ | 60 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_ACCEPT_LANGUAGES_H_ |
OLD | NEW |