| 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 #if defined(ENABLE_LANGUAGE_DETECTION) |
| 73 // Returns the ISO 639_1 language code of the specified |text|, or 'unknown' | 74 // Returns the ISO 639_1 language code of the specified |text|, or 'unknown' |
| 74 // if it failed. | 75 // if it failed. |
| 75 static std::string DetermineTextLanguage(const string16& text); | 76 static std::string DetermineTextLanguage(const string16& text); |
| 77 #endif |
| 76 | 78 |
| 77 // RenderViewObserver implementation. | 79 // RenderViewObserver implementation. |
| 78 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 80 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 79 | 81 |
| 80 // Cancels any translation that is currently being performed. This does not | 82 // Cancels any translation that is currently being performed. This does not |
| 81 // revert existing translations. | 83 // revert existing translations. |
| 82 void CancelPendingTranslation(); | 84 void CancelPendingTranslation(); |
| 83 | 85 |
| 84 // Checks if the current running page translation is finished or errored and | 86 // Checks if the current running page translation is finished or errored and |
| 85 // notifies the browser accordingly. If the translation has not terminated, | 87 // notifies the browser accordingly. If the translation has not terminated, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 std::string source_lang_; | 124 std::string source_lang_; |
| 123 std::string target_lang_; | 125 std::string target_lang_; |
| 124 | 126 |
| 125 // Method factory used to make calls to TranslatePageImpl. | 127 // Method factory used to make calls to TranslatePageImpl. |
| 126 base::WeakPtrFactory<TranslateHelper> weak_method_factory_; | 128 base::WeakPtrFactory<TranslateHelper> weak_method_factory_; |
| 127 | 129 |
| 128 DISALLOW_COPY_AND_ASSIGN(TranslateHelper); | 130 DISALLOW_COPY_AND_ASSIGN(TranslateHelper); |
| 129 }; | 131 }; |
| 130 | 132 |
| 131 #endif // CHROME_RENDERER_TRANSLATE_HELPER_H_ | 133 #endif // CHROME_RENDERER_TRANSLATE_HELPER_H_ |
| OLD | NEW |