• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #ifndef CHROME_BROWSER_TRANSLATE_TRANSLATE_TAB_HELPER_H_
6 #define CHROME_BROWSER_TRANSLATE_TRANSLATE_TAB_HELPER_H_
7 
8 #include "chrome/browser/tab_contents/language_state.h"
9 #include "chrome/common/translate/translate_errors.h"
10 #include "content/public/browser/web_contents_observer.h"
11 #include "content/public/browser/web_contents_user_data.h"
12 
13 struct LanguageDetectionDetails;
14 
15 class TranslateTabHelper
16     : public content::WebContentsObserver,
17       public content::WebContentsUserData<TranslateTabHelper> {
18  public:
19   virtual ~TranslateTabHelper();
20 
language_state()21   LanguageState& language_state() { return language_state_; }
22 
23  private:
24   explicit TranslateTabHelper(content::WebContents* web_contents);
25   friend class content::WebContentsUserData<TranslateTabHelper>;
26 
27   // content::WebContentsObserver implementation.
28   virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
29   virtual void DidNavigateAnyFrame(
30       const content::LoadCommittedDetails& details,
31       const content::FrameNavigateParams& params) OVERRIDE;
32 
33   void OnLanguageDetermined(const LanguageDetectionDetails& details,
34                             bool page_needs_translation);
35   void OnPageTranslated(int32 page_id,
36                         const std::string& original_lang,
37                         const std::string& translated_lang,
38                         TranslateErrors::Type error_type);
39 
40   // Information about the language the page is in and has been translated to.
41   LanguageState language_state_;
42 
43   DISALLOW_COPY_AND_ASSIGN(TranslateTabHelper);
44 };
45 
46 #endif  // CHROME_BROWSER_TRANSLATE_TRANSLATE_TAB_HELPER_H_
47