| 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> |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 typedef base::CallbackList<void(const TranslateErrorDetails&)> | 92 typedef base::CallbackList<void(const TranslateErrorDetails&)> |
| 93 TranslateErrorCallbackList; | 93 TranslateErrorCallbackList; |
| 94 | 94 |
| 95 // Registers a callback for translate errors. | 95 // Registers a callback for translate errors. |
| 96 static scoped_ptr<TranslateErrorCallbackList::Subscription> | 96 static scoped_ptr<TranslateErrorCallbackList::Subscription> |
| 97 RegisterTranslateErrorCallback(const TranslateErrorCallback& callback); | 97 RegisterTranslateErrorCallback(const TranslateErrorCallback& callback); |
| 98 | 98 |
| 99 // Gets the LanguageState associated with the TranslateManager | 99 // Gets the LanguageState associated with the TranslateManager |
| 100 LanguageState& GetLanguageState(); | 100 LanguageState& GetLanguageState(); |
| 101 | 101 |
| 102 // By default, don't offer to translate in builds lacking an API key. For |
| 103 // testing, set to true to offer anyway. |
| 104 static void SetIgnoreMissingKeyForTesting(bool ignore); |
| 105 |
| 102 private: | 106 private: |
| 103 // Sends a translation request to the TranslateDriver. | 107 // Sends a translation request to the TranslateDriver. |
| 104 void DoTranslatePage(const std::string& translate_script, | 108 void DoTranslatePage(const std::string& translate_script, |
| 105 const std::string& source_lang, | 109 const std::string& source_lang, |
| 106 const std::string& target_lang); | 110 const std::string& target_lang); |
| 107 | 111 |
| 108 // Called when the Translate script has been fetched. | 112 // Called when the Translate script has been fetched. |
| 109 // Initiates the translation. | 113 // Initiates the translation. |
| 110 void OnTranslateScriptFetchComplete(const std::string& source_lang, | 114 void OnTranslateScriptFetchComplete(const std::string& source_lang, |
| 111 const std::string& target_lang, | 115 const std::string& target_lang, |
| 112 bool success, | 116 bool success, |
| 113 const std::string& data); | 117 const std::string& data); |
| 114 | 118 |
| 115 // Sequence number of the current page. | 119 // Sequence number of the current page. |
| 116 int page_seq_no_; | 120 int page_seq_no_; |
| 117 | 121 |
| 118 // Preference name for the Accept-Languages HTTP header. | 122 // Preference name for the Accept-Languages HTTP header. |
| 119 std::string accept_languages_pref_name_; | 123 std::string accept_languages_pref_name_; |
| 120 | 124 |
| 121 TranslateClient* translate_client_; // Weak. | 125 TranslateClient* translate_client_; // Weak. |
| 122 TranslateDriver* translate_driver_; // Weak. | 126 TranslateDriver* translate_driver_; // Weak. |
| 123 | 127 |
| 124 LanguageState language_state_; | 128 LanguageState language_state_; |
| 125 | 129 |
| 126 base::WeakPtrFactory<TranslateManager> weak_method_factory_; | 130 base::WeakPtrFactory<TranslateManager> weak_method_factory_; |
| 127 | 131 |
| 132 // By default, don't offer to translate in builds lacking an API key. For |
| 133 // testing, set to true to offer anyway. |
| 134 static bool ignore_missing_key_for_testing_; |
| 135 |
| 128 DISALLOW_COPY_AND_ASSIGN(TranslateManager); | 136 DISALLOW_COPY_AND_ASSIGN(TranslateManager); |
| 129 }; | 137 }; |
| 130 | 138 |
| 131 } // namespace translate | 139 } // namespace translate |
| 132 | 140 |
| 133 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_MANAGER_H_ | 141 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_MANAGER_H_ |
| OLD | NEW |