| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_TRANSLATE_TRANSLATE_MANAGER_H_ |
| 6 #define CHROME_BROWSER_TRANSLATE_TRANSLATE_MANAGER_H_ | 6 #define CHROME_BROWSER_TRANSLATE_TRANSLATE_MANAGER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 | 68 |
| 69 // Clears the translate script, so it will be fetched next time we translate. | 69 // Clears the translate script, so it will be fetched next time we translate. |
| 70 void ClearTranslateScript() { translate_script_.clear(); } | 70 void ClearTranslateScript() { translate_script_.clear(); } |
| 71 | 71 |
| 72 // content::NotificationObserver implementation: | 72 // content::NotificationObserver implementation: |
| 73 virtual void Observe(int type, | 73 virtual void Observe(int type, |
| 74 const content::NotificationSource& source, | 74 const content::NotificationSource& source, |
| 75 const content::NotificationDetails& details); | 75 const content::NotificationDetails& details); |
| 76 | 76 |
| 77 // content::URLFetcherDelegate implementation: | 77 // content::URLFetcherDelegate implementation: |
| 78 virtual void OnURLFetchComplete(const URLFetcher* source); | 78 virtual void OnURLFetchComplete(const content::URLFetcher* source); |
| 79 | 79 |
| 80 // Used by unit-tests to override the default delay after which the translate | 80 // Used by unit-tests to override the default delay after which the translate |
| 81 // script is fetched again from the translation server. | 81 // script is fetched again from the translation server. |
| 82 void set_translate_script_expiration_delay(int delay_ms) { | 82 void set_translate_script_expiration_delay(int delay_ms) { |
| 83 translate_script_expiration_delay_ = delay_ms; | 83 translate_script_expiration_delay_ = delay_ms; |
| 84 } | 84 } |
| 85 | 85 |
| 86 // Convenience method to know if a tab is showing a translate infobar. | 86 // Convenience method to know if a tab is showing a translate infobar. |
| 87 static bool IsShowingTranslateInfobar(TabContents* tab); | 87 static bool IsShowingTranslateInfobar(TabContents* tab); |
| 88 | 88 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 base::WeakPtrFactory<TranslateManager> weak_method_factory_; | 190 base::WeakPtrFactory<TranslateManager> weak_method_factory_; |
| 191 | 191 |
| 192 // The JS injected in the page to do the translation. | 192 // The JS injected in the page to do the translation. |
| 193 std::string translate_script_; | 193 std::string translate_script_; |
| 194 | 194 |
| 195 // Delay in milli-seconds after which the translate script is fetched again | 195 // Delay in milli-seconds after which the translate script is fetched again |
| 196 // from the translate server. | 196 // from the translate server. |
| 197 int translate_script_expiration_delay_; | 197 int translate_script_expiration_delay_; |
| 198 | 198 |
| 199 // Set when the translate JS is currently being retrieved. NULL otherwise. | 199 // Set when the translate JS is currently being retrieved. NULL otherwise. |
| 200 scoped_ptr<URLFetcher> translate_script_request_pending_; | 200 scoped_ptr<content::URLFetcher> translate_script_request_pending_; |
| 201 | 201 |
| 202 // Set when the list of languages is currently being retrieved. | 202 // Set when the list of languages is currently being retrieved. |
| 203 // NULL otherwise. | 203 // NULL otherwise. |
| 204 scoped_ptr<URLFetcher> language_list_request_pending_; | 204 scoped_ptr<content::URLFetcher> language_list_request_pending_; |
| 205 | 205 |
| 206 // The list of pending translate requests. Translate requests are queued when | 206 // The list of pending translate requests. Translate requests are queued when |
| 207 // the translate script is not ready and has to be fetched from the translate | 207 // the translate script is not ready and has to be fetched from the translate |
| 208 // server. | 208 // server. |
| 209 std::vector<PendingRequest> pending_requests_; | 209 std::vector<PendingRequest> pending_requests_; |
| 210 | 210 |
| 211 // The languages supported by the translation server. | 211 // The languages supported by the translation server. |
| 212 static base::LazyInstance<std::set<std::string> > supported_languages_; | 212 static base::LazyInstance<std::set<std::string> > supported_languages_; |
| 213 | 213 |
| 214 DISALLOW_COPY_AND_ASSIGN(TranslateManager); | 214 DISALLOW_COPY_AND_ASSIGN(TranslateManager); |
| 215 }; | 215 }; |
| 216 | 216 |
| 217 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_MANAGER_H_ | 217 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_MANAGER_H_ |
| OLD | NEW |