| 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 COMPONENTS_TRANSLATE_CONTENT_RENDERER_TRANSLATE_HELPER_H_ | 5 #ifndef COMPONENTS_TRANSLATE_CONTENT_RENDERER_TRANSLATE_HELPER_H_ |
| 6 #define COMPONENTS_TRANSLATE_CONTENT_RENDERER_TRANSLATE_HELPER_H_ | 6 #define COMPONENTS_TRANSLATE_CONTENT_RENDERER_TRANSLATE_HELPER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/gtest_prod_util.h" | |
| 11 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 13 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 14 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 15 #include "components/translate/content/renderer/renderer_cld_data_provider.h" | 14 #include "components/translate/content/renderer/renderer_cld_data_provider.h" |
| 16 #include "components/translate/core/common/translate_errors.h" | 15 #include "components/translate/core/common/translate_errors.h" |
| 17 #include "content/public/renderer/render_view_observer.h" | 16 #include "content/public/renderer/render_view_observer.h" |
| 18 #include "url/gurl.h" | 17 #include "url/gurl.h" |
| 19 | 18 |
| 20 namespace blink { | 19 namespace blink { |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 // run successfully. Otherwise, returns empty string. | 143 // run successfully. Otherwise, returns empty string. |
| 145 virtual std::string ExecuteScriptAndGetStringResult( | 144 virtual std::string ExecuteScriptAndGetStringResult( |
| 146 const std::string& script); | 145 const std::string& script); |
| 147 | 146 |
| 148 // Executes the JavaScript code in |script| in the main frame of RenderView. | 147 // Executes the JavaScript code in |script| in the main frame of RenderView. |
| 149 // and returns the number returned by the script evaluation if the script was | 148 // and returns the number returned by the script evaluation if the script was |
| 150 // run successfully. Otherwise, returns 0.0. | 149 // run successfully. Otherwise, returns 0.0. |
| 151 virtual double ExecuteScriptAndGetDoubleResult(const std::string& script); | 150 virtual double ExecuteScriptAndGetDoubleResult(const std::string& script); |
| 152 | 151 |
| 153 private: | 152 private: |
| 154 FRIEND_TEST_ALL_PREFIXES(TranslateHelperTest, AdoptHtmlLang); | |
| 155 FRIEND_TEST_ALL_PREFIXES(TranslateHelperTest, | |
| 156 CLDAgreeWithLanguageCodeHavingCountryCode); | |
| 157 FRIEND_TEST_ALL_PREFIXES(TranslateHelperTest, | |
| 158 CLDDisagreeWithWrongLanguageCode); | |
| 159 FRIEND_TEST_ALL_PREFIXES(TranslateHelperTest, | |
| 160 InvalidLanguageMetaTagProviding); | |
| 161 FRIEND_TEST_ALL_PREFIXES(TranslateHelperTest, LanguageCodeTypoCorrection); | |
| 162 FRIEND_TEST_ALL_PREFIXES(TranslateHelperTest, LanguageCodeSynonyms); | |
| 163 FRIEND_TEST_ALL_PREFIXES(TranslateHelperTest, ResetInvalidLanguageCode); | |
| 164 FRIEND_TEST_ALL_PREFIXES(TranslateHelperTest, SimilarLanguageCode); | |
| 165 FRIEND_TEST_ALL_PREFIXES(TranslateHelperTest, WellKnownWrongConfiguration); | |
| 166 | |
| 167 enum LanguageDetectionTiming { | 153 enum LanguageDetectionTiming { |
| 168 ON_TIME, // Language detection was performed as soon as it was requested | 154 ON_TIME, // Language detection was performed as soon as it was requested |
| 169 DEFERRED, // Language detection couldn't be performed when it was requested | 155 DEFERRED, // Language detection couldn't be performed when it was requested |
| 170 RESUMED, // A deferred language detection attempt was completed later | 156 RESUMED, // A deferred language detection attempt was completed later |
| 171 LANGUAGE_DETECTION_TIMING_MAX_VALUE // The bounding value for this enum | 157 LANGUAGE_DETECTION_TIMING_MAX_VALUE // The bounding value for this enum |
| 172 }; | 158 }; |
| 173 | 159 |
| 174 // Converts language code to the one used in server supporting list. | 160 // Converts language code to the one used in server supporting list. |
| 175 static void ConvertLanguageCodeSynonym(std::string* code); | 161 static void ConvertLanguageCodeSynonym(std::string* code); |
| 176 | 162 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 | 248 |
| 263 // Method factory used to make calls to TranslatePageImpl. | 249 // Method factory used to make calls to TranslatePageImpl. |
| 264 base::WeakPtrFactory<TranslateHelper> weak_method_factory_; | 250 base::WeakPtrFactory<TranslateHelper> weak_method_factory_; |
| 265 | 251 |
| 266 DISALLOW_COPY_AND_ASSIGN(TranslateHelper); | 252 DISALLOW_COPY_AND_ASSIGN(TranslateHelper); |
| 267 }; | 253 }; |
| 268 | 254 |
| 269 } // namespace translate | 255 } // namespace translate |
| 270 | 256 |
| 271 #endif // COMPONENTS_TRANSLATE_CONTENT_RENDERER_TRANSLATE_HELPER_H_ | 257 #endif // COMPONENTS_TRANSLATE_CONTENT_RENDERER_TRANSLATE_HELPER_H_ |
| OLD | NEW |