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/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 // Used in unit-tests. Makes the various tasks be posted immediately so that | 63 // Used in unit-tests. Makes the various tasks be posted immediately so that |
64 // the tests don't have to wait before checking states. | 64 // the tests don't have to wait before checking states. |
65 virtual bool DontDelayTasks(); | 65 virtual bool DontDelayTasks(); |
66 | 66 |
67 private: | 67 private: |
68 // Returns whether the page associated with |document| is a candidate for | 68 // Returns whether the page associated with |document| is a candidate for |
69 // translation. Some pages can explictly specify (via a meta-tag) that they | 69 // translation. Some pages can explictly specify (via a meta-tag) that they |
70 // should not be translated. | 70 // should not be translated. |
71 static bool IsPageTranslatable(WebKit::WebDocument* document); | 71 static bool IsPageTranslatable(WebKit::WebDocument* document); |
72 | 72 |
73 // Returns the language specified in the language meta tag of |document|, or | |
74 // an empty string if no such tag was found. | |
75 // The tag may specify several languages, the first one is returned. | |
76 // Example of such meta-tag: | |
77 // <meta http-equiv="content-language" content="en, fr"> | |
78 static std::string GetPageLanguageFromMetaTag(WebKit::WebDocument* document); | |
79 | |
80 // Returns the ISO 639_1 language code of the specified |text|, or 'unknown' | 73 // Returns the ISO 639_1 language code of the specified |text|, or 'unknown' |
81 // if it failed. | 74 // if it failed. |
82 static std::string DetermineTextLanguage(const string16& text); | 75 static std::string DetermineTextLanguage(const string16& text); |
83 | 76 |
84 // RenderViewObserver implementation. | 77 // RenderViewObserver implementation. |
85 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 78 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
86 | 79 |
87 // Cancels any translation that is currently being performed. This does not | 80 // Cancels any translation that is currently being performed. This does not |
88 // revert existing translations. | 81 // revert existing translations. |
89 void CancelPendingTranslation(); | 82 void CancelPendingTranslation(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 std::string source_lang_; | 122 std::string source_lang_; |
130 std::string target_lang_; | 123 std::string target_lang_; |
131 | 124 |
132 // Method factory used to make calls to TranslatePageImpl. | 125 // Method factory used to make calls to TranslatePageImpl. |
133 base::WeakPtrFactory<TranslateHelper> weak_method_factory_; | 126 base::WeakPtrFactory<TranslateHelper> weak_method_factory_; |
134 | 127 |
135 DISALLOW_COPY_AND_ASSIGN(TranslateHelper); | 128 DISALLOW_COPY_AND_ASSIGN(TranslateHelper); |
136 }; | 129 }; |
137 | 130 |
138 #endif // CHROME_RENDERER_TRANSLATE_HELPER_H_ | 131 #endif // CHROME_RENDERER_TRANSLATE_HELPER_H_ |
OLD | NEW |