OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CHROME_BROWSER_TRANSLATE_TRANSLATE_LANGUAGE_LIST_H_ | 5 #ifndef CHROME_BROWSER_TRANSLATE_TRANSLATE_LANGUAGE_LIST_H_ |
6 #define CHROME_BROWSER_TRANSLATE_TRANSLATE_LANGUAGE_LIST_H_ | 6 #define CHROME_BROWSER_TRANSLATE_TRANSLATE_LANGUAGE_LIST_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 20 matching lines...) Expand all Loading... |
31 // translate to and from. | 31 // translate to and from. |
32 void GetSupportedLanguages(std::vector<std::string>* languages); | 32 void GetSupportedLanguages(std::vector<std::string>* languages); |
33 | 33 |
34 // Returns the language code that can be used with the Translate method for a | 34 // Returns the language code that can be used with the Translate method for a |
35 // specified |chrome_locale|. | 35 // specified |chrome_locale|. |
36 std::string GetLanguageCode(const std::string& chrome_locale); | 36 std::string GetLanguageCode(const std::string& chrome_locale); |
37 | 37 |
38 // Returns true if |language| is supported by the translation server. | 38 // Returns true if |language| is supported by the translation server. |
39 bool IsSupportedLanguage(const std::string& language); | 39 bool IsSupportedLanguage(const std::string& language); |
40 | 40 |
41 // TODO(toyoshim): Add IsSupportedAlphaLanguage() here. | 41 // Returns true if |language| is supported by the translation server as a |
| 42 // alpha language. |
| 43 bool IsAlphaLanguage(const std::string& language); |
42 | 44 |
43 // Fetches the language list from the translate server. It will not retry | 45 // Fetches the language list from the translate server. It will not retry |
44 // more than kMaxRetryLanguageListFetch times. | 46 // more than kMaxRetryLanguageListFetch times. |
45 void RequestLanguageList(); | 47 void RequestLanguageList(); |
46 | 48 |
47 // static const values shared with our browser tests. | 49 // static const values shared with our browser tests. |
48 static const char kLanguageListCallbackName[]; | 50 static const char kLanguageListCallbackName[]; |
49 static const char kTargetLanguagesKey[]; | 51 static const char kTargetLanguagesKey[]; |
50 | 52 |
51 private: | 53 private: |
52 // Parses |language_list| and fills |supported_languages_| with the list of | |
53 // languages that the translate server can translate to and from. | |
54 void SetSupportedLanguages(const std::string& language_list); | |
55 | |
56 // The languages supported by the translation server. | 54 // The languages supported by the translation server. |
57 std::set<std::string> supported_languages_; | 55 std::set<std::string> supported_languages_; |
58 | 56 |
| 57 // The alpha languages supported by the translation server. |
| 58 std::set<std::string> supported_alpha_languages_; |
| 59 |
59 // An URLFetcher instance to fetch a server providing supported language list. | 60 // An URLFetcher instance to fetch a server providing supported language list. |
60 scoped_ptr<net::URLFetcher> url_fetcher_; | 61 scoped_ptr<net::URLFetcher> language_list_fetcher_; |
| 62 |
| 63 // An URLFetcher instance to fetch a server providing supported alpha language |
| 64 // list. |
| 65 scoped_ptr<net::URLFetcher> alpha_language_list_fetcher_; |
61 | 66 |
62 DISALLOW_COPY_AND_ASSIGN(TranslateLanguageList); | 67 DISALLOW_COPY_AND_ASSIGN(TranslateLanguageList); |
63 }; | 68 }; |
64 | 69 |
65 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_LANGUAGE_LIST_H_ | 70 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_LANGUAGE_LIST_H_ |
OLD | NEW |