Chromium Code Reviews| 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. | 31 // translate to and from. If alpha language support is enabled, it fills |
| 32 // |languages| with the list of all supporting languages including alpha | |
| 33 // languages. | |
| 32 void GetSupportedLanguages(std::vector<std::string>* languages); | 34 void GetSupportedLanguages(std::vector<std::string>* languages); |
| 33 | 35 |
| 34 // Returns the language code that can be used with the Translate method for a | 36 // Returns the language code that can be used with the Translate method for a |
| 35 // specified |chrome_locale|. | 37 // specified |chrome_locale|. |
| 36 std::string GetLanguageCode(const std::string& chrome_locale); | 38 std::string GetLanguageCode(const std::string& chrome_locale); |
| 37 | 39 |
| 38 // Returns true if |language| is supported by the translation server. | 40 // Returns true if |language| is supported by the translation server. If alpha |
| 41 // language support is enabled, returns true if |language| is in alpha | |
|
MAD
2013/05/31 15:14:52
This comment seems to say that when alpha is enabl
Takashi Toyoshima
2013/05/31 16:37:06
thanks!
| |
| 42 // language list. | |
| 39 bool IsSupportedLanguage(const std::string& language); | 43 bool IsSupportedLanguage(const std::string& language); |
| 40 | 44 |
| 41 // TODO(toyoshim): Add IsSupportedAlphaLanguage() here. | 45 // Returns true if |language| is supported by the translation server as a |
| 46 // alpha language. | |
| 47 bool IsAlphaLanguage(const std::string& language); | |
| 42 | 48 |
| 43 // Fetches the language list from the translate server. It will not retry | 49 // Fetches the language list from the translate server. It will not retry |
| 44 // more than kMaxRetryLanguageListFetch times. | 50 // more than kMaxRetryLanguageListFetch times. |
| 45 void RequestLanguageList(); | 51 void RequestLanguageList(); |
| 46 | 52 |
| 47 // static const values shared with our browser tests. | 53 // static const values shared with our browser tests. |
| 48 static const char kLanguageListCallbackName[]; | 54 static const char kLanguageListCallbackName[]; |
| 49 static const char kTargetLanguagesKey[]; | 55 static const char kTargetLanguagesKey[]; |
| 50 | 56 |
| 51 private: | 57 private: |
| 52 // Parses |language_list| and fills |supported_languages_| with the list of | 58 // Updates |supported_all_languages_| contains union of |supported_languages_| |
|
MAD
2013/05/31 15:14:52
contains union -> to contain the union
Takashi Toyoshima
2013/05/31 16:37:06
Done.
| |
| 53 // languages that the translate server can translate to and from. | 59 // and |supported-alpha_languages_|. |
|
MAD
2013/05/31 15:14:52
Nit: supported-alpha_languages_ -> supported_alpha
Takashi Toyoshima
2013/05/31 16:37:06
Done.
| |
| 54 void SetSupportedLanguages(const std::string& language_list); | 60 void UpdateSupportedLanguages(); |
| 55 | 61 |
| 56 // The languages supported by the translation server. | 62 // The languages supported by the translation server. |
| 57 std::set<std::string> supported_languages_; | 63 std::set<std::string> supported_languages_; |
| 58 | 64 |
| 65 // The alpha languages supported by the translation server. | |
| 66 std::set<std::string> supported_alpha_languages_; | |
| 67 | |
| 68 // The languages supported by the translation server. It contains union of | |
|
MAD
2013/05/31 15:14:52
I would say "All the languages supported..." and a
Takashi Toyoshima
2013/05/31 16:37:06
Done.
| |
| 69 // |supported_languages_| and |supported_alpha_languages_|. | |
| 70 std::set<std::string> supported_all_languages_; | |
|
MAD
2013/05/31 15:14:52
I would rename it to all_supported_languages_.
Takashi Toyoshima
2013/05/31 16:37:06
Done.
| |
| 71 | |
| 59 // An URLFetcher instance to fetch a server providing supported language list. | 72 // An URLFetcher instance to fetch a server providing supported language list. |
| 60 scoped_ptr<net::URLFetcher> url_fetcher_; | 73 scoped_ptr<net::URLFetcher> language_list_fetcher_; |
| 74 | |
| 75 // An URLFetcher instance to fetch a server providing supported alpha language | |
| 76 // list. | |
| 77 scoped_ptr<net::URLFetcher> alpha_language_list_fetcher_; | |
| 78 | |
| 79 // A flag to representing if alpha language support is enabled. | |
| 80 bool alpha_language_support_is_enabled_; | |
|
MAD
2013/05/31 15:14:52
You don't seem to be using that...
Takashi Toyoshima
2013/05/31 16:37:06
Thanks.
I stop using it at the last clean up.
Sorr
| |
| 61 | 81 |
| 62 DISALLOW_COPY_AND_ASSIGN(TranslateLanguageList); | 82 DISALLOW_COPY_AND_ASSIGN(TranslateLanguageList); |
| 63 }; | 83 }; |
| 64 | 84 |
| 65 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_LANGUAGE_LIST_H_ | 85 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_LANGUAGE_LIST_H_ |
| OLD | NEW |