OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_MANAGER_H_ | 5 #ifndef COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_MANAGER_H_ |
6 #define COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_MANAGER_H_ | 6 #define COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 11 matching lines...) Expand all Loading... |
22 class TranslateEventProto; | 22 class TranslateEventProto; |
23 } | 23 } |
24 | 24 |
25 namespace translate { | 25 namespace translate { |
26 | 26 |
27 extern const base::Feature kTranslateLanguageByULP; | 27 extern const base::Feature kTranslateLanguageByULP; |
28 | 28 |
29 class TranslateClient; | 29 class TranslateClient; |
30 class TranslateDriver; | 30 class TranslateDriver; |
31 class TranslatePrefs; | 31 class TranslatePrefs; |
| 32 class TranslateRanker; |
32 | 33 |
33 namespace testing { | 34 namespace testing { |
34 class TranslateManagerTest; | 35 class TranslateManagerTest; |
35 } // namespace testing | 36 } // namespace testing |
36 | 37 |
37 struct TranslateErrorDetails; | 38 struct TranslateErrorDetails; |
38 | 39 |
39 // The TranslateManager class is responsible for showing an info-bar when a page | 40 // The TranslateManager class is responsible for showing an info-bar when a page |
40 // in a language different than the user language is loaded. It triggers the | 41 // in a language different than the user language is loaded. It triggers the |
41 // page translation the user requests. | 42 // page translation the user requests. |
42 | 43 |
43 class TranslateManager { | 44 class TranslateManager { |
44 public: | 45 public: |
45 // |translate_client| is expected to outlive the TranslateManager. | 46 // |translate_client| is expected to outlive the TranslateManager. |
46 // |accept_language_pref_name| is the path for the preference for the | 47 // |accept_language_pref_name| is the path for the preference for the |
47 // accept-languages. | 48 // accept-languages. |
48 TranslateManager(TranslateClient* translate_client, | 49 TranslateManager(TranslateClient* translate_client, |
| 50 TranslateRanker* translate_ranker, |
49 const std::string& accept_language_pref_name); | 51 const std::string& accept_language_pref_name); |
50 virtual ~TranslateManager(); | 52 virtual ~TranslateManager(); |
51 | 53 |
52 // Returns a weak pointer to this instance. | 54 // Returns a weak pointer to this instance. |
53 base::WeakPtr<TranslateManager> GetWeakPtr(); | 55 base::WeakPtr<TranslateManager> GetWeakPtr(); |
54 | 56 |
55 // Cannot return NULL. | 57 // Cannot return NULL. |
56 TranslateClient* translate_client() { return translate_client_; } | 58 TranslateClient* translate_client() { return translate_client_; } |
57 | 59 |
58 // Sets the sequence number of the current page, for use while sending | 60 // Sets the sequence number of the current page, for use while sending |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 const TranslatePrefs& translate_prefs); | 156 const TranslatePrefs& translate_prefs); |
155 | 157 |
156 // Sequence number of the current page. | 158 // Sequence number of the current page. |
157 int page_seq_no_; | 159 int page_seq_no_; |
158 | 160 |
159 // Preference name for the Accept-Languages HTTP header. | 161 // Preference name for the Accept-Languages HTTP header. |
160 std::string accept_languages_pref_name_; | 162 std::string accept_languages_pref_name_; |
161 | 163 |
162 TranslateClient* translate_client_; // Weak. | 164 TranslateClient* translate_client_; // Weak. |
163 TranslateDriver* translate_driver_; // Weak. | 165 TranslateDriver* translate_driver_; // Weak. |
| 166 TranslateRanker* translate_ranker_; // Weak. |
164 | 167 |
165 LanguageState language_state_; | 168 LanguageState language_state_; |
166 | 169 |
167 std::unique_ptr<metrics::TranslateEventProto> translate_event_; | 170 std::unique_ptr<metrics::TranslateEventProto> translate_event_; |
168 | 171 |
169 base::WeakPtrFactory<TranslateManager> weak_method_factory_; | 172 base::WeakPtrFactory<TranslateManager> weak_method_factory_; |
170 | 173 |
171 // By default, don't offer to translate in builds lacking an API key. For | 174 // By default, don't offer to translate in builds lacking an API key. For |
172 // testing, set to true to offer anyway. | 175 // testing, set to true to offer anyway. |
173 static bool ignore_missing_key_for_testing_; | 176 static bool ignore_missing_key_for_testing_; |
174 | 177 |
175 DISALLOW_COPY_AND_ASSIGN(TranslateManager); | 178 DISALLOW_COPY_AND_ASSIGN(TranslateManager); |
176 }; | 179 }; |
177 | 180 |
178 } // namespace translate | 181 } // namespace translate |
179 | 182 |
180 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_MANAGER_H_ | 183 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_MANAGER_H_ |
OLD | NEW |