| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 private: | 89 private: |
| 90 FRIEND_TEST_ALL_PREFIXES(TranslateHelperTest, LanguageCodeTypoCorrection); | 90 FRIEND_TEST_ALL_PREFIXES(TranslateHelperTest, LanguageCodeTypoCorrection); |
| 91 FRIEND_TEST_ALL_PREFIXES(TranslateHelperTest, LanguageCodeSynonyms); | 91 FRIEND_TEST_ALL_PREFIXES(TranslateHelperTest, LanguageCodeSynonyms); |
| 92 FRIEND_TEST_ALL_PREFIXES(TranslateHelperTest, ResetInvalidLanguageCode); | 92 FRIEND_TEST_ALL_PREFIXES(TranslateHelperTest, ResetInvalidLanguageCode); |
| 93 FRIEND_TEST_ALL_PREFIXES(TranslateHelperTest, | 93 FRIEND_TEST_ALL_PREFIXES(TranslateHelperTest, |
| 94 CLDDisagreeWithWrongLanguageCode); | 94 CLDDisagreeWithWrongLanguageCode); |
| 95 FRIEND_TEST_ALL_PREFIXES(TranslateHelperTest, | 95 FRIEND_TEST_ALL_PREFIXES(TranslateHelperTest, |
| 96 CLDAgreeWithLanguageCodeHavingCountryCode); | 96 CLDAgreeWithLanguageCodeHavingCountryCode); |
| 97 FRIEND_TEST_ALL_PREFIXES(TranslateHelperTest, | 97 FRIEND_TEST_ALL_PREFIXES(TranslateHelperTest, |
| 98 InvalidLanguageMetaTagProviding); | 98 InvalidLanguageMetaTagProviding); |
| 99 FRIEND_TEST_ALL_PREFIXES(TranslateHelperTest, AdoptHtmlLang); |
| 99 | 100 |
| 100 // Correct language code if it contains well-known mistakes. | 101 // Corrects language code if it contains well-known mistakes. |
| 101 static void CorrectLanguageCodeTypo(std::string* code); | 102 static void CorrectLanguageCodeTypo(std::string* code); |
| 102 | 103 |
| 103 // Convert language code to the one used in server supporting list. | 104 // Converts language code to the one used in server supporting list. |
| 104 static void ConvertLanguageCodeSynonym(std::string* code); | 105 static void ConvertLanguageCodeSynonym(std::string* code); |
| 105 | 106 |
| 106 // Reset language code if the specified string is apparently invalid. | 107 // Resets language code if the specified string is apparently invalid. |
| 107 static void ResetInvalidLanguageCode(std::string* code); | 108 static void ResetInvalidLanguageCode(std::string* code); |
| 108 | 109 |
| 109 // Determine content page language from Content-Language code and contents. | 110 // Applies a series of language code modification in proper order. |
| 111 static void ApplyLanguageCodeCorrection(std::string* code); |
| 112 |
| 113 // Determines content page language from Content-Language code and contents. |
| 110 static std::string DeterminePageLanguage(const std::string& code, | 114 static std::string DeterminePageLanguage(const std::string& code, |
| 115 const std::string& html_lang, |
| 111 const string16& contents, | 116 const string16& contents, |
| 112 std::string* cld_language, | 117 std::string* cld_language, |
| 113 bool* is_cld_reliable); | 118 bool* is_cld_reliable); |
| 114 | 119 |
| 115 // Returns whether the page associated with |document| is a candidate for | 120 // Returns whether the page associated with |document| is a candidate for |
| 116 // translation. Some pages can explictly specify (via a meta-tag) that they | 121 // translation. Some pages can explictly specify (via a meta-tag) that they |
| 117 // should not be translated. | 122 // should not be translated. |
| 118 static bool IsTranslationAllowed(WebKit::WebDocument* document); | 123 static bool IsTranslationAllowed(WebKit::WebDocument* document); |
| 119 | 124 |
| 120 #if defined(ENABLE_LANGUAGE_DETECTION) | 125 #if defined(ENABLE_LANGUAGE_DETECTION) |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 // time from showing infobar to requesting translation. | 165 // time from showing infobar to requesting translation. |
| 161 base::TimeTicks language_determined_time_; | 166 base::TimeTicks language_determined_time_; |
| 162 | 167 |
| 163 // Method factory used to make calls to TranslatePageImpl. | 168 // Method factory used to make calls to TranslatePageImpl. |
| 164 base::WeakPtrFactory<TranslateHelper> weak_method_factory_; | 169 base::WeakPtrFactory<TranslateHelper> weak_method_factory_; |
| 165 | 170 |
| 166 DISALLOW_COPY_AND_ASSIGN(TranslateHelper); | 171 DISALLOW_COPY_AND_ASSIGN(TranslateHelper); |
| 167 }; | 172 }; |
| 168 | 173 |
| 169 #endif // CHROME_RENDERER_TRANSLATE_TRANSLATE_HELPER_H_ | 174 #endif // CHROME_RENDERER_TRANSLATE_TRANSLATE_HELPER_H_ |
| OLD | NEW |