Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_RENDERER_TRANSLATE_TRANSLATE_HELPER_H_ | 5 #ifndef CHROME_RENDERER_TRANSLATE_TRANSLATE_HELPER_H_ |
| 6 #define CHROME_RENDERER_TRANSLATE_TRANSLATE_HELPER_H_ | 6 #define CHROME_RENDERER_TRANSLATE_TRANSLATE_HELPER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 106 FRIEND_TEST_ALL_PREFIXES(TranslateHelperTest, | 106 FRIEND_TEST_ALL_PREFIXES(TranslateHelperTest, |
| 107 CLDDisagreeWithWrongLanguageCode); | 107 CLDDisagreeWithWrongLanguageCode); |
| 108 FRIEND_TEST_ALL_PREFIXES(TranslateHelperTest, | 108 FRIEND_TEST_ALL_PREFIXES(TranslateHelperTest, |
| 109 InvalidLanguageMetaTagProviding); | 109 InvalidLanguageMetaTagProviding); |
| 110 FRIEND_TEST_ALL_PREFIXES(TranslateHelperTest, LanguageCodeTypoCorrection); | 110 FRIEND_TEST_ALL_PREFIXES(TranslateHelperTest, LanguageCodeTypoCorrection); |
| 111 FRIEND_TEST_ALL_PREFIXES(TranslateHelperTest, LanguageCodeSynonyms); | 111 FRIEND_TEST_ALL_PREFIXES(TranslateHelperTest, LanguageCodeSynonyms); |
| 112 FRIEND_TEST_ALL_PREFIXES(TranslateHelperTest, ResetInvalidLanguageCode); | 112 FRIEND_TEST_ALL_PREFIXES(TranslateHelperTest, ResetInvalidLanguageCode); |
| 113 FRIEND_TEST_ALL_PREFIXES(TranslateHelperTest, SimilarLanguageCode); | 113 FRIEND_TEST_ALL_PREFIXES(TranslateHelperTest, SimilarLanguageCode); |
| 114 FRIEND_TEST_ALL_PREFIXES(TranslateHelperTest, WellKnownWrongConfiguration); | 114 FRIEND_TEST_ALL_PREFIXES(TranslateHelperTest, WellKnownWrongConfiguration); |
| 115 | 115 |
| 116 enum LanguageDetectionTiming { | |
| 117 ON_TIME, // Language detection was performed as soon as it was requested | |
| 118 DEFERRED, // Language detection couldn't be performed when it was requested | |
| 119 RESUMED, // A deferred language detection attempt was completed later | |
| 120 kLanguageDetectionTimingMax // bounding value for this enum | |
|
Alexei Svitkine (slow)
2014/07/16 14:50:40
Nit: Use same naming convention as for the other e
andrewhayden
2014/07/17 08:36:19
This is copied from the same place the rest of thi
| |
| 121 }; | |
| 122 | |
| 116 // Converts language code to the one used in server supporting list. | 123 // Converts language code to the one used in server supporting list. |
| 117 static void ConvertLanguageCodeSynonym(std::string* code); | 124 static void ConvertLanguageCodeSynonym(std::string* code); |
| 118 | 125 |
| 119 // Returns whether the page associated with |document| is a candidate for | 126 // Returns whether the page associated with |document| is a candidate for |
| 120 // translation. Some pages can explictly specify (via a meta-tag) that they | 127 // translation. Some pages can explictly specify (via a meta-tag) that they |
| 121 // should not be translated. | 128 // should not be translated. |
| 122 static bool IsTranslationAllowed(blink::WebDocument* document); | 129 static bool IsTranslationAllowed(blink::WebDocument* document); |
| 123 | 130 |
| 124 // RenderViewObserver implementation. | 131 // RenderViewObserver implementation. |
| 125 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 132 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 160 void DeferPageCaptured(const int page_id, const base::string16& contents); | 167 void DeferPageCaptured(const int page_id, const base::string16& contents); |
| 161 | 168 |
| 162 // Start polling for CLD data. | 169 // Start polling for CLD data. |
| 163 // Polling will automatically halt as soon as the renderer obtains a | 170 // Polling will automatically halt as soon as the renderer obtains a |
| 164 // reference to the data file. | 171 // reference to the data file. |
| 165 void SendCldDataRequest(const int delay_millis, const int next_delay_millis); | 172 void SendCldDataRequest(const int delay_millis, const int next_delay_millis); |
| 166 | 173 |
| 167 // Callback triggered when CLD data becomes available. | 174 // Callback triggered when CLD data becomes available. |
| 168 void OnCldDataAvailable(); | 175 void OnCldDataAvailable(); |
| 169 | 176 |
| 177 // Record the timing of language detection, immediately sending an IPC-based | |
|
jar (doing other things)
2014/07/16 16:44:44
nit: perhaps better would be to aggregate these re
andrewhayden
2014/07/17 08:36:19
Totally agree, but again very far out of scope for
| |
| 178 // histogram delta update to the browser process in case the hosting renderer | |
| 179 // process terminates before the metrics would otherwise be transferred. | |
| 180 void RecordLanguageDetectionTiming(LanguageDetectionTiming); | |
| 181 | |
| 170 // An ever-increasing sequence number of the current page, used to match up | 182 // An ever-increasing sequence number of the current page, used to match up |
| 171 // translation requests with responses. | 183 // translation requests with responses. |
| 172 int page_seq_no_; | 184 int page_seq_no_; |
| 173 | 185 |
| 174 // The states associated with the current translation. | 186 // The states associated with the current translation. |
| 175 bool translation_pending_; | 187 bool translation_pending_; |
| 176 std::string source_lang_; | 188 std::string source_lang_; |
| 177 std::string target_lang_; | 189 std::string target_lang_; |
| 178 | 190 |
| 179 // Time when a page langauge is determined. This is used to know a duration | 191 // Time when a page langauge is determined. This is used to know a duration |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 201 int deferred_page_seq_no_; | 213 int deferred_page_seq_no_; |
| 202 | 214 |
| 203 // The contents of the page most recently reported to PageCaptured if | 215 // The contents of the page most recently reported to PageCaptured if |
| 204 // deferred_page_capture_ is true. | 216 // deferred_page_capture_ is true. |
| 205 base::string16 deferred_contents_; | 217 base::string16 deferred_contents_; |
| 206 | 218 |
| 207 DISALLOW_COPY_AND_ASSIGN(TranslateHelper); | 219 DISALLOW_COPY_AND_ASSIGN(TranslateHelper); |
| 208 }; | 220 }; |
| 209 | 221 |
| 210 #endif // CHROME_RENDERER_TRANSLATE_TRANSLATE_HELPER_H_ | 222 #endif // CHROME_RENDERER_TRANSLATE_TRANSLATE_HELPER_H_ |
| OLD | NEW |