| OLD | NEW |
| 1 // Copyright 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" |
| 10 #include "chrome/browser/ui/translate/translate_bubble_model.h" | 11 #include "chrome/browser/ui/translate/translate_bubble_model.h" |
| 11 #include "components/translate/content/browser/content_translate_driver.h" | 12 #include "components/translate/content/browser/content_translate_driver.h" |
| 12 #include "components/translate/core/common/translate_errors.h" | 13 #include "components/translate/core/common/translate_errors.h" |
| 13 #include "content/public/browser/web_contents_observer.h" | 14 #include "content/public/browser/web_contents_observer.h" |
| 14 #include "content/public/browser/web_contents_user_data.h" | 15 #include "content/public/browser/web_contents_user_data.h" |
| 15 | 16 |
| 16 namespace content { | 17 namespace content { |
| 18 class BrowserContext; |
| 17 class WebContents; | 19 class WebContents; |
| 18 } | 20 } |
| 19 | 21 |
| 20 struct LanguageDetectionDetails; | 22 struct LanguageDetectionDetails; |
| 23 class PrefService; |
| 24 class TranslateAcceptLanguages; |
| 25 class TranslatePrefs; |
| 21 | 26 |
| 22 class TranslateTabHelper | 27 class TranslateTabHelper |
| 23 : public content::WebContentsObserver, | 28 : public content::WebContentsObserver, |
| 24 public content::WebContentsUserData<TranslateTabHelper> { | 29 public content::WebContentsUserData<TranslateTabHelper> { |
| 25 public: | 30 public: |
| 26 virtual ~TranslateTabHelper(); | 31 virtual ~TranslateTabHelper(); |
| 27 | 32 |
| 28 // Gets the LanguageState associated with the page. | 33 // Gets the LanguageState associated with the page. |
| 29 LanguageState& GetLanguageState(); | 34 LanguageState& GetLanguageState(); |
| 30 | 35 |
| 31 // Returns the ContentTranslateDriver instance associated with this | 36 // Returns the ContentTranslateDriver instance associated with this |
| 32 // WebContents. | 37 // WebContents. |
| 33 ContentTranslateDriver& translate_driver() { return translate_driver_; } | 38 ContentTranslateDriver& translate_driver() { return translate_driver_; } |
| 34 | 39 |
| 40 // Helper method to return a new TranslatePrefs instance. |
| 41 static scoped_ptr<TranslatePrefs> CreateTranslatePrefs(PrefService* prefs); |
| 42 |
| 43 // Helper method to return the TranslateAcceptLanguages instance associated |
| 44 // with |browser_context|. |
| 45 static TranslateAcceptLanguages* GetTranslateAcceptLanguages( |
| 46 content::BrowserContext* browser_context); |
| 47 |
| 35 // Denotes which state the user is in with respect to translate. | 48 // Denotes which state the user is in with respect to translate. |
| 36 enum TranslateStep { | 49 enum TranslateStep { |
| 37 BEFORE_TRANSLATE, | 50 BEFORE_TRANSLATE, |
| 38 TRANSLATING, | 51 TRANSLATING, |
| 39 AFTER_TRANSLATE, | 52 AFTER_TRANSLATE, |
| 40 TRANSLATE_ERROR | 53 TRANSLATE_ERROR |
| 41 }; | 54 }; |
| 42 | 55 |
| 43 // Called when the embedder should present UI to the user corresponding to the | 56 // Called when the embedder should present UI to the user corresponding to the |
| 44 // user's current |step|. | 57 // user's current |step|. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 69 void ShowBubble(content::WebContents* web_contents, | 82 void ShowBubble(content::WebContents* web_contents, |
| 70 TranslateBubbleModel::ViewState view_state, | 83 TranslateBubbleModel::ViewState view_state, |
| 71 TranslateErrors::Type error_type); | 84 TranslateErrors::Type error_type); |
| 72 | 85 |
| 73 ContentTranslateDriver translate_driver_; | 86 ContentTranslateDriver translate_driver_; |
| 74 | 87 |
| 75 DISALLOW_COPY_AND_ASSIGN(TranslateTabHelper); | 88 DISALLOW_COPY_AND_ASSIGN(TranslateTabHelper); |
| 76 }; | 89 }; |
| 77 | 90 |
| 78 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_TAB_HELPER_H_ | 91 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_TAB_HELPER_H_ |
| OLD | NEW |