Chromium Code Reviews| 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 static void SetIgnoreMissingKeyForTesting(bool ignore); | |
|
hajimehoshi
2015/07/08 04:41:35
Add a comment
| |
| 103 | |
| 102 private: | 104 private: |
| 103 // Sends a translation request to the TranslateDriver. | 105 // Sends a translation request to the TranslateDriver. |
| 104 void DoTranslatePage(const std::string& translate_script, | 106 void DoTranslatePage(const std::string& translate_script, |
| 105 const std::string& source_lang, | 107 const std::string& source_lang, |
| 106 const std::string& target_lang); | 108 const std::string& target_lang); |
| 107 | 109 |
| 108 // Called when the Translate script has been fetched. | 110 // Called when the Translate script has been fetched. |
| 109 // Initiates the translation. | 111 // Initiates the translation. |
| 110 void OnTranslateScriptFetchComplete(const std::string& source_lang, | 112 void OnTranslateScriptFetchComplete(const std::string& source_lang, |
| 111 const std::string& target_lang, | 113 const std::string& target_lang, |
| 112 bool success, | 114 bool success, |
| 113 const std::string& data); | 115 const std::string& data); |
| 114 | 116 |
| 115 // Sequence number of the current page. | 117 // Sequence number of the current page. |
| 116 int page_seq_no_; | 118 int page_seq_no_; |
| 117 | 119 |
| 118 // Preference name for the Accept-Languages HTTP header. | 120 // Preference name for the Accept-Languages HTTP header. |
| 119 std::string accept_languages_pref_name_; | 121 std::string accept_languages_pref_name_; |
| 120 | 122 |
| 121 TranslateClient* translate_client_; // Weak. | 123 TranslateClient* translate_client_; // Weak. |
| 122 TranslateDriver* translate_driver_; // Weak. | 124 TranslateDriver* translate_driver_; // Weak. |
| 123 | 125 |
| 124 LanguageState language_state_; | 126 LanguageState language_state_; |
| 125 | 127 |
| 126 base::WeakPtrFactory<TranslateManager> weak_method_factory_; | 128 base::WeakPtrFactory<TranslateManager> weak_method_factory_; |
| 127 | 129 |
| 130 // By default, don't offer to translate in builds lacking an API key. For | |
| 131 // testing, set to true to offer anyway. | |
| 132 static bool ignore_missing_key_for_testing_; | |
| 133 | |
| 128 DISALLOW_COPY_AND_ASSIGN(TranslateManager); | 134 DISALLOW_COPY_AND_ASSIGN(TranslateManager); |
| 129 }; | 135 }; |
| 130 | 136 |
| 131 } // namespace translate | 137 } // namespace translate |
| 132 | 138 |
| 133 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_MANAGER_H_ | 139 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_MANAGER_H_ |
| OLD | NEW |