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 <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/callback_list.h" | 12 #include "base/callback_list.h" |
13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "components/translate/core/browser/language_state.h" | |
16 #include "components/translate/core/common/translate_errors.h" | 17 #include "components/translate/core/common/translate_errors.h" |
17 | 18 |
18 class GURL; | 19 class GURL; |
19 class PrefService; | 20 class PrefService; |
20 class TranslateClient; | 21 class TranslateClient; |
21 class TranslateDriver; | 22 class TranslateDriver; |
22 class TranslatePrefs; | 23 class TranslatePrefs; |
23 struct TranslateErrorDetails; | 24 struct TranslateErrorDetails; |
24 | 25 |
25 // The TranslateManager class is responsible for showing an info-bar when a page | 26 // The TranslateManager class is responsible for showing an info-bar when a page |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 // Callback types for translate errors. | 82 // Callback types for translate errors. |
82 typedef base::Callback<void(const TranslateErrorDetails&)> | 83 typedef base::Callback<void(const TranslateErrorDetails&)> |
83 TranslateErrorCallback; | 84 TranslateErrorCallback; |
84 typedef base::CallbackList<void(const TranslateErrorDetails&)> | 85 typedef base::CallbackList<void(const TranslateErrorDetails&)> |
85 TranslateErrorCallbackList; | 86 TranslateErrorCallbackList; |
86 | 87 |
87 // Registers a callback for translate errors. | 88 // Registers a callback for translate errors. |
88 static scoped_ptr<TranslateErrorCallbackList::Subscription> | 89 static scoped_ptr<TranslateErrorCallbackList::Subscription> |
89 RegisterTranslateErrorCallback(const TranslateErrorCallback& callback); | 90 RegisterTranslateErrorCallback(const TranslateErrorCallback& callback); |
90 | 91 |
92 LanguageState& GetLanguageState(); | |
droger
2014/05/21 09:13:25
Can you add a comment for this method?
nshaik
2014/05/21 15:26:15
Done.
| |
93 | |
91 private: | 94 private: |
92 // Sends a translation request to the TranslateDriver. | 95 // Sends a translation request to the TranslateDriver. |
93 void DoTranslatePage(const std::string& translate_script, | 96 void DoTranslatePage(const std::string& translate_script, |
94 const std::string& source_lang, | 97 const std::string& source_lang, |
95 const std::string& target_lang); | 98 const std::string& target_lang); |
96 | 99 |
97 // Called when the Translate script has been fetched. | 100 // Called when the Translate script has been fetched. |
98 // Initiates the translation. | 101 // Initiates the translation. |
99 void OnTranslateScriptFetchComplete(int page_id, | 102 void OnTranslateScriptFetchComplete(int page_id, |
100 const std::string& source_lang, | 103 const std::string& source_lang, |
101 const std::string& target_lang, | 104 const std::string& target_lang, |
102 bool success, | 105 bool success, |
103 const std::string& data); | 106 const std::string& data); |
104 | 107 |
105 // Preference name for the Accept-Languages HTTP header. | 108 // Preference name for the Accept-Languages HTTP header. |
106 std::string accept_languages_pref_name_; | 109 std::string accept_languages_pref_name_; |
107 | 110 |
108 TranslateClient* translate_client_; // Weak. | 111 TranslateClient* translate_client_; // Weak. |
109 TranslateDriver* translate_driver_; // Weak. | 112 TranslateDriver* translate_driver_; // Weak. |
110 | 113 |
114 LanguageState language_state_; | |
115 | |
111 base::WeakPtrFactory<TranslateManager> weak_method_factory_; | 116 base::WeakPtrFactory<TranslateManager> weak_method_factory_; |
112 | 117 |
113 DISALLOW_COPY_AND_ASSIGN(TranslateManager); | 118 DISALLOW_COPY_AND_ASSIGN(TranslateManager); |
114 }; | 119 }; |
115 | 120 |
116 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_MANAGER_H_ | 121 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_MANAGER_H_ |
OLD | NEW |