diff options
author | mad@chromium.org <mad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-21 21:07:35 +0000 |
---|---|---|
committer | mad@chromium.org <mad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-21 21:07:35 +0000 |
commit | 79f6324897972c76a900d1ebe28218642fab5eba (patch) | |
tree | 1a638697fd2ea0718669c7d4f7abd280e68bbfd3 /chrome/browser/translate/translate_manager.h | |
parent | 803e4c8a8db64fa1a404c2b347ba459f6535f914 (diff) | |
download | chromium_src-79f6324897972c76a900d1ebe28218642fab5eba.zip chromium_src-79f6324897972c76a900d1ebe28218642fab5eba.tar.gz chromium_src-79f6324897972c76a900d1ebe28218642fab5eba.tar.bz2 |
Get the list of supported languages from the translate server.
BUG=35475
TEST=Make sure that we can translate to and from all languages supported by the translate server.
Review URL: http://codereview.chromium.org/7171002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89892 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/translate/translate_manager.h')
-rw-r--r-- | chrome/browser/translate/translate_manager.h | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/chrome/browser/translate/translate_manager.h b/chrome/browser/translate/translate_manager.h index 1e2d54a..1c5caa0 100644 --- a/chrome/browser/translate/translate_manager.h +++ b/chrome/browser/translate/translate_manager.h @@ -39,6 +39,12 @@ class TranslateManager : public NotificationObserver, virtual ~TranslateManager(); + // Let the caller decide if and when we should fetch the language list from + // the translate server. This is a NOOP if switches::kDisableTranslate is + // set or if prefs::kEnableTranslate is set to false. + // It will not retry more than kMaxRetryLanguageListFetch times. + void FetchLanguageListFromTranslateServer(PrefService* prefs); + // Translates the page contents from |source_lang| to |target_lang|. // The actual translation might be performed asynchronously if the translate // script is not yet available. @@ -94,6 +100,9 @@ class TranslateManager : public NotificationObserver, // Returns true if |language| is supported by the translation server. static bool IsSupportedLanguage(const std::string& language); + // static const values shared with our browser tests. + static const char* const kLanguageListCallbackName; + static const char* const kTargetLanguagesKey; protected: TranslateManager(); @@ -111,6 +120,14 @@ class TranslateManager : public NotificationObserver, std::string target_lang; }; + // Fills supported_languages_ with the list of languages that the translate + // server can translate to and from. + static void SetSupportedLanguages(const std::string& language_list); + + // Initializes the list of supported languages if it wasn't initialized before + // in case we failed to get them from the server, or didn't get them just yet. + static void InitSupportedLanguages(); + // Starts the translation process on |tab| containing the page in the // |page_lang| language. void InitiateTranslation(TabContents* tab, const std::string& page_lang); @@ -127,8 +144,8 @@ class TranslateManager : public NotificationObserver, const std::string& source_lang, const std::string& target_lang); - // Shows the after translate or error infobar depending on the details. - void PageTranslated(TabContents* tab, PageTranslatedDetails* details); + // Shows the after translate or error infobar depending on the details. + void PageTranslated(TabContents* tab, PageTranslatedDetails* details); // Returns true if the passed language has been configured by the user as an // accept language. @@ -175,6 +192,9 @@ class TranslateManager : public NotificationObserver, // Whether the translate JS is currently being retrieved. bool translate_script_request_pending_; + // Whether the list of languages is currently being retrieved. + bool language_list_request_pending_; + // The list of pending translate requests. Translate requests are queued when // the translate script is not ready and has to be fetched from the translate // server. |