diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-13 00:44:31 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-13 00:44:31 +0000 |
commit | 93b9d6948d212b630a115dc4b77bbe6bf2b3b671 (patch) | |
tree | 92e02d514f2b44cdd2b7f82063ed3e91af3773bf /chrome/renderer/translate_helper.h | |
parent | 71504b42e176b37b9324897a53908df5ba6c723e (diff) | |
download | chromium_src-93b9d6948d212b630a115dc4b77bbe6bf2b3b671.zip chromium_src-93b9d6948d212b630a115dc4b77bbe6bf2b3b671.tar.gz chromium_src-93b9d6948d212b630a115dc4b77bbe6bf2b3b671.tar.bz2 |
Move code that talks to spelling and translate out of content. I create ChromeRenderObserver, which is a RenderViewObserver for the Chrome layer. Also, I added a TranslateTabHelper to hold the per-tab language data and moved LanguageState back to chrome since it's not used by content.
Review URL: http://codereview.chromium.org/6824068
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81341 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/translate_helper.h')
-rw-r--r-- | chrome/renderer/translate_helper.h | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/chrome/renderer/translate_helper.h b/chrome/renderer/translate_helper.h index 54a4706..902f0bc 100644 --- a/chrome/renderer/translate_helper.h +++ b/chrome/renderer/translate_helper.h @@ -17,25 +17,21 @@ class WebDocument; class WebFrame; } +namespace autofill { +class AutofillAgent; +} + // This class deals with page translation. // There is one TranslateHelper per RenderView. class TranslateHelper : public RenderViewObserver { public: - explicit TranslateHelper(RenderView* render_view); + // autofill can be NULL. + TranslateHelper(RenderView* render_view, autofill::AutofillAgent* autofill); virtual ~TranslateHelper(); - // Returns whether the page associated with |document| is a candidate for - // translation. Some pages can explictly specify (via a meta-tag) that they - // should not be translated. - static bool IsPageTranslatable(WebKit::WebDocument* document); - - // Returns the language specified in the language meta tag of |document|, or - // an empty string if no such tag was found. - // The tag may specify several languages, the first one is returned. - // Example of such meta-tag: - // <meta http-equiv="content-language" content="en, fr"> - static std::string GetPageLanguageFromMetaTag(WebKit::WebDocument* document); + // Informs us that the page's text has been extracted. + void PageCaptured(const string16& contents); protected: // The following methods are protected so they can be overridden in @@ -75,6 +71,22 @@ class TranslateHelper : public RenderViewObserver { virtual bool DontDelayTasks(); private: + // Returns whether the page associated with |document| is a candidate for + // translation. Some pages can explictly specify (via a meta-tag) that they + // should not be translated. + static bool IsPageTranslatable(WebKit::WebDocument* document); + + // Returns the language specified in the language meta tag of |document|, or + // an empty string if no such tag was found. + // The tag may specify several languages, the first one is returned. + // Example of such meta-tag: + // <meta http-equiv="content-language" content="en, fr"> + static std::string GetPageLanguageFromMetaTag(WebKit::WebDocument* document); + + // Returns the ISO 639_1 language code of the specified |text|, or 'unknown' + // if it failed. + static std::string DetermineTextLanguage(const string16& text); + // RenderViewObserver implementation. virtual bool OnMessageReceived(const IPC::Message& message); @@ -123,6 +135,8 @@ class TranslateHelper : public RenderViewObserver { std::string source_lang_; std::string target_lang_; + autofill::AutofillAgent* autofill_; + // Method factory used to make calls to TranslatePageImpl. ScopedRunnableMethodFactory<TranslateHelper> method_factory_; |