OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
15 #include "base/lazy_instance.h" | 15 #include "base/lazy_instance.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
18 #include "base/time.h" | 18 #include "base/time.h" |
19 #include "chrome/browser/prefs/pref_change_registrar.h" | 19 #include "chrome/browser/prefs/pref_change_registrar.h" |
20 #include "chrome/common/translate_errors.h" | 20 #include "chrome/common/translate_errors.h" |
21 #include "content/public/common/url_fetcher_delegate.h" | |
22 #include "content/public/browser/notification_observer.h" | 21 #include "content/public/browser/notification_observer.h" |
23 #include "content/public/browser/notification_registrar.h" | 22 #include "content/public/browser/notification_registrar.h" |
| 23 #include "content/public/common/url_fetcher_delegate.h" |
24 | 24 |
25 template <typename T> struct DefaultSingletonTraits; | 25 template <typename T> struct DefaultSingletonTraits; |
26 class GURL; | 26 class GURL; |
27 struct PageTranslatedDetails; | 27 struct PageTranslatedDetails; |
28 class PrefService; | 28 class PrefService; |
29 class TranslateInfoBarDelegate; | 29 class TranslateInfoBarDelegate; |
30 | 30 |
31 namespace content { | 31 namespace content { |
32 class WebContents; | 32 class WebContents; |
33 } | 33 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 | 73 |
74 // Clears the translate script, so it will be fetched next time we translate. | 74 // Clears the translate script, so it will be fetched next time we translate. |
75 void ClearTranslateScript() { translate_script_.clear(); } | 75 void ClearTranslateScript() { translate_script_.clear(); } |
76 | 76 |
77 // content::NotificationObserver implementation: | 77 // content::NotificationObserver implementation: |
78 virtual void Observe(int type, | 78 virtual void Observe(int type, |
79 const content::NotificationSource& source, | 79 const content::NotificationSource& source, |
80 const content::NotificationDetails& details) OVERRIDE; | 80 const content::NotificationDetails& details) OVERRIDE; |
81 | 81 |
82 // content::URLFetcherDelegate implementation: | 82 // content::URLFetcherDelegate implementation: |
83 virtual void OnURLFetchComplete(const content::URLFetcher* source) OVERRIDE; | 83 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
84 | 84 |
85 // Used by unit-tests to override the default delay after which the translate | 85 // Used by unit-tests to override the default delay after which the translate |
86 // script is fetched again from the translation server. | 86 // script is fetched again from the translation server. |
87 void set_translate_script_expiration_delay(int delay_ms) { | 87 void set_translate_script_expiration_delay(int delay_ms) { |
88 translate_script_expiration_delay_ = | 88 translate_script_expiration_delay_ = |
89 base::TimeDelta::FromMilliseconds(delay_ms); | 89 base::TimeDelta::FromMilliseconds(delay_ms); |
90 } | 90 } |
91 | 91 |
92 // Convenience method to know if a tab is showing a translate infobar. | 92 // Convenience method to know if a tab is showing a translate infobar. |
93 static bool IsShowingTranslateInfobar(content::WebContents* tab); | 93 static bool IsShowingTranslateInfobar(content::WebContents* tab); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 // server. | 219 // server. |
220 std::vector<PendingRequest> pending_requests_; | 220 std::vector<PendingRequest> pending_requests_; |
221 | 221 |
222 // The languages supported by the translation server. | 222 // The languages supported by the translation server. |
223 static base::LazyInstance<std::set<std::string> > supported_languages_; | 223 static base::LazyInstance<std::set<std::string> > supported_languages_; |
224 | 224 |
225 DISALLOW_COPY_AND_ASSIGN(TranslateManager); | 225 DISALLOW_COPY_AND_ASSIGN(TranslateManager); |
226 }; | 226 }; |
227 | 227 |
228 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_MANAGER_H_ | 228 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_MANAGER_H_ |
OLD | NEW |