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