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 10 matching lines...) Expand all Loading... |
21 // This class is defined to be owned only by TranslateManager. | 21 // This class is defined to be owned only by TranslateManager. |
22 class TranslateLanguageList : public net::URLFetcherDelegate { | 22 class TranslateLanguageList : public net::URLFetcherDelegate { |
23 public: | 23 public: |
24 TranslateLanguageList(); | 24 TranslateLanguageList(); |
25 virtual ~TranslateLanguageList(); | 25 virtual ~TranslateLanguageList(); |
26 | 26 |
27 // net::URLFetcherDelegate implementation: | 27 // net::URLFetcherDelegate implementation: |
28 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 28 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
29 | 29 |
30 // Fills |languages| with the list of languages that the translate server can | 30 // Fills |languages| with the list of languages that the translate server can |
31 // translate to and from. If alpha language support is enabled, it fills | 31 // translate to and from. |languages| will include alpha languages. |
32 // |languages| with the list of all supporting languages including alpha | |
33 // languages. | |
34 void GetSupportedLanguages(std::vector<std::string>* languages); | 32 void GetSupportedLanguages(std::vector<std::string>* languages); |
35 | 33 |
36 // 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 |
37 // specified |chrome_locale|. | 35 // specified |chrome_locale|. |
38 std::string GetLanguageCode(const std::string& chrome_locale); | 36 std::string GetLanguageCode(const std::string& chrome_locale); |
39 | 37 |
40 // Returns true if |language| is supported by the translation server. If alpha | 38 // Returns true if |language| is supported by the translation server. It also |
41 // language support is enabled, also returns true if |language| is in alpha | 39 // returns true against alpha languages. |
42 // language list. | |
43 bool IsSupportedLanguage(const std::string& language); | 40 bool IsSupportedLanguage(const std::string& language); |
44 | 41 |
45 // Returns true if |language| is supported by the translation server as a | 42 // Returns true if |language| is supported by the translation server as a |
46 // alpha language. | 43 // alpha language. |
47 bool IsAlphaLanguage(const std::string& language); | 44 bool IsAlphaLanguage(const std::string& language); |
48 | 45 |
49 // Fetches the language list from the translate server. It will not retry | 46 // Fetches the language list from the translate server. It will not retry |
50 // more than kMaxRetryLanguageListFetch times. | 47 // more than kMaxRetryLanguageListFetch times. |
51 void RequestLanguageList(); | 48 void RequestLanguageList(); |
52 | 49 |
(...skipping 20 matching lines...) Expand all Loading... |
73 scoped_ptr<net::URLFetcher> language_list_fetcher_; | 70 scoped_ptr<net::URLFetcher> language_list_fetcher_; |
74 | 71 |
75 // An URLFetcher instance to fetch a server providing supported alpha language | 72 // An URLFetcher instance to fetch a server providing supported alpha language |
76 // list. | 73 // list. |
77 scoped_ptr<net::URLFetcher> alpha_language_list_fetcher_; | 74 scoped_ptr<net::URLFetcher> alpha_language_list_fetcher_; |
78 | 75 |
79 DISALLOW_COPY_AND_ASSIGN(TranslateLanguageList); | 76 DISALLOW_COPY_AND_ASSIGN(TranslateLanguageList); |
80 }; | 77 }; |
81 | 78 |
82 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_LANGUAGE_LIST_H_ | 79 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_LANGUAGE_LIST_H_ |
OLD | NEW |