| 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_HELPER_H_ | 5 #ifndef CHROME_RENDERER_TRANSLATE_HELPER_H_ |
| 6 #define CHROME_RENDERER_TRANSLATE_HELPER_H_ | 6 #define CHROME_RENDERER_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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 // Asks the Translate element in the page what the language of the page is. | 59 // Asks the Translate element in the page what the language of the page is. |
| 60 // Can only be called if a translation has happened and was successful. | 60 // Can only be called if a translation has happened and was successful. |
| 61 // Returns the language code on success, an empty string on failure. | 61 // Returns the language code on success, an empty string on failure. |
| 62 virtual std::string GetOriginalPageLanguage(); | 62 virtual std::string GetOriginalPageLanguage(); |
| 63 | 63 |
| 64 // Used in unit-tests. Makes the various tasks be posted immediately so that | 64 // Used in unit-tests. Makes the various tasks be posted immediately so that |
| 65 // the tests don't have to wait before checking states. | 65 // the tests don't have to wait before checking states. |
| 66 virtual bool DontDelayTasks(); | 66 virtual bool DontDelayTasks(); |
| 67 | 67 |
| 68 private: | 68 private: |
| 69 FRIEND_TEST_ALL_PREFIXES(TranslateHelperTest, LanguageCodeTypoCorrection); |
| 69 FRIEND_TEST_ALL_PREFIXES(TranslateHelperTest, LanguageCodeSynonyms); | 70 FRIEND_TEST_ALL_PREFIXES(TranslateHelperTest, LanguageCodeSynonyms); |
| 70 | 71 |
| 72 // Correct language code if it contains well-known mistakes. |
| 73 static void CorrectLanguageCodeTypo(std::string* code); |
| 74 |
| 71 // Convert language code to the one used in server supporting list. | 75 // Convert language code to the one used in server supporting list. |
| 72 static void ConvertLanguageCodeSynonym(std::string* code); | 76 static void ConvertLanguageCodeSynonym(std::string* code); |
| 73 | 77 |
| 74 // Returns whether the page associated with |document| is a candidate for | 78 // Returns whether the page associated with |document| is a candidate for |
| 75 // translation. Some pages can explictly specify (via a meta-tag) that they | 79 // translation. Some pages can explictly specify (via a meta-tag) that they |
| 76 // should not be translated. | 80 // should not be translated. |
| 77 static bool IsPageTranslatable(WebKit::WebDocument* document); | 81 static bool IsPageTranslatable(WebKit::WebDocument* document); |
| 78 | 82 |
| 79 #if defined(ENABLE_LANGUAGE_DETECTION) | 83 #if defined(ENABLE_LANGUAGE_DETECTION) |
| 80 // Returns the ISO 639_1 language code of the specified |text|, or 'unknown' | 84 // Returns the ISO 639_1 language code of the specified |text|, or 'unknown' |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 std::string source_lang_; | 134 std::string source_lang_; |
| 131 std::string target_lang_; | 135 std::string target_lang_; |
| 132 | 136 |
| 133 // Method factory used to make calls to TranslatePageImpl. | 137 // Method factory used to make calls to TranslatePageImpl. |
| 134 base::WeakPtrFactory<TranslateHelper> weak_method_factory_; | 138 base::WeakPtrFactory<TranslateHelper> weak_method_factory_; |
| 135 | 139 |
| 136 DISALLOW_COPY_AND_ASSIGN(TranslateHelper); | 140 DISALLOW_COPY_AND_ASSIGN(TranslateHelper); |
| 137 }; | 141 }; |
| 138 | 142 |
| 139 #endif // CHROME_RENDERER_TRANSLATE_HELPER_H_ | 143 #endif // CHROME_RENDERER_TRANSLATE_HELPER_H_ |
| OLD | NEW |