Chromium Code Reviews| 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 content driver for translate. | |
|
blundell
2014/01/20 14:22:53
// Returns the ContentTranslateDriver instance ass
| |
| 25 ContentTranslateDriver* GetTranslateDriver(); | |
| 22 | 26 |
| 23 private: | 27 private: |
| 24 explicit TranslateTabHelper(content::WebContents* web_contents); | 28 explicit TranslateTabHelper(content::WebContents* web_contents); |
| 25 friend class content::WebContentsUserData<TranslateTabHelper>; | 29 friend class content::WebContentsUserData<TranslateTabHelper>; |
| 26 | 30 |
| 27 // content::WebContentsObserver implementation. | 31 // content::WebContentsObserver implementation. |
| 28 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 32 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 29 virtual void DidNavigateAnyFrame( | 33 virtual void DidNavigateAnyFrame( |
| 30 const content::LoadCommittedDetails& details, | 34 const content::LoadCommittedDetails& details, |
| 31 const content::FrameNavigateParams& params) OVERRIDE; | 35 const content::FrameNavigateParams& params) OVERRIDE; |
| 32 | 36 |
| 33 void OnLanguageDetermined(const LanguageDetectionDetails& details, | 37 void OnLanguageDetermined(const LanguageDetectionDetails& details, |
| 34 bool page_needs_translation); | 38 bool page_needs_translation); |
| 35 void OnPageTranslated(int32 page_id, | 39 void OnPageTranslated(int32 page_id, |
| 36 const std::string& original_lang, | 40 const std::string& original_lang, |
| 37 const std::string& translated_lang, | 41 const std::string& translated_lang, |
| 38 TranslateErrors::Type error_type); | 42 TranslateErrors::Type error_type); |
| 39 | 43 |
| 40 // Information about the language the page is in and has been translated to. | 44 ContentTranslateDriver translate_driver_; |
| 41 LanguageState language_state_; | |
| 42 | 45 |
| 43 DISALLOW_COPY_AND_ASSIGN(TranslateTabHelper); | 46 DISALLOW_COPY_AND_ASSIGN(TranslateTabHelper); |
| 44 }; | 47 }; |
| 45 | 48 |
| 46 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_TAB_HELPER_H_ | 49 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_TAB_HELPER_H_ |
| OLD | NEW |