| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 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_BROWSER_TRANSLATE_TRANSLATE_TAB_HELPER_H_ | 5 #ifndef CHROME_BROWSER_TRANSLATE_TRANSLATE_TAB_HELPER_H_ |
| 6 #define CHROME_BROWSER_TRANSLATE_TRANSLATE_TAB_HELPER_H_ | 6 #define CHROME_BROWSER_TRANSLATE_TRANSLATE_TAB_HELPER_H_ |
| 7 | 7 |
| 8 #include "chrome/browser/tab_contents/language_state.h" | 8 #include "components/translate/content/browser/content_translate_driver.h" |
| 9 #include "components/translate/core/common/translate_errors.h" | 9 #include "components/translate/core/common/translate_errors.h" |
| 10 #include "content/public/browser/web_contents_observer.h" | 10 #include "content/public/browser/web_contents_observer.h" |
| 11 #include "content/public/browser/web_contents_user_data.h" | 11 #include "content/public/browser/web_contents_user_data.h" |
| 12 | 12 |
| 13 struct LanguageDetectionDetails; | 13 struct LanguageDetectionDetails; |
| 14 | 14 |
| 15 class TranslateTabHelper | 15 class TranslateTabHelper |
| 16 : public content::WebContentsObserver, | 16 : public content::WebContentsObserver, |
| 17 public content::WebContentsUserData<TranslateTabHelper> { | 17 public content::WebContentsUserData<TranslateTabHelper> { |
| 18 public: | 18 public: |
| 19 virtual ~TranslateTabHelper(); | 19 virtual ~TranslateTabHelper(); |
| 20 | 20 |
| 21 LanguageState& language_state() { return language_state_; } | 21 // Gets the LanguageState associated with the page. |
| 22 LanguageState& GetLanguageState(); |
| 23 |
| 24 // Returns the ContentTranslateDriver instance associated with this |
| 25 // WebContents. |
| 26 ContentTranslateDriver& translate_driver() { return translate_driver_; } |
| 22 | 27 |
| 23 private: | 28 private: |
| 24 explicit TranslateTabHelper(content::WebContents* web_contents); | 29 explicit TranslateTabHelper(content::WebContents* web_contents); |
| 25 friend class content::WebContentsUserData<TranslateTabHelper>; | 30 friend class content::WebContentsUserData<TranslateTabHelper>; |
| 26 | 31 |
| 27 // content::WebContentsObserver implementation. | 32 // content::WebContentsObserver implementation. |
| 28 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 33 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 29 virtual void DidNavigateAnyFrame( | 34 virtual void DidNavigateAnyFrame( |
| 30 const content::LoadCommittedDetails& details, | 35 const content::LoadCommittedDetails& details, |
| 31 const content::FrameNavigateParams& params) OVERRIDE; | 36 const content::FrameNavigateParams& params) OVERRIDE; |
| 32 | 37 |
| 33 void OnLanguageDetermined(const LanguageDetectionDetails& details, | 38 void OnLanguageDetermined(const LanguageDetectionDetails& details, |
| 34 bool page_needs_translation); | 39 bool page_needs_translation); |
| 35 void OnPageTranslated(int32 page_id, | 40 void OnPageTranslated(int32 page_id, |
| 36 const std::string& original_lang, | 41 const std::string& original_lang, |
| 37 const std::string& translated_lang, | 42 const std::string& translated_lang, |
| 38 TranslateErrors::Type error_type); | 43 TranslateErrors::Type error_type); |
| 39 | 44 |
| 40 // Information about the language the page is in and has been translated to. | 45 ContentTranslateDriver translate_driver_; |
| 41 LanguageState language_state_; | |
| 42 | 46 |
| 43 DISALLOW_COPY_AND_ASSIGN(TranslateTabHelper); | 47 DISALLOW_COPY_AND_ASSIGN(TranslateTabHelper); |
| 44 }; | 48 }; |
| 45 | 49 |
| 46 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_TAB_HELPER_H_ | 50 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_TAB_HELPER_H_ |
| OLD | NEW |