Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_CHROME_TRANSLATE_CLIENT_H_ | 5 #ifndef CHROME_BROWSER_TRANSLATE_CHROME_TRANSLATE_CLIENT_H_ |
| 6 #define CHROME_BROWSER_TRANSLATE_CHROME_TRANSLATE_CLIENT_H_ | 6 #define CHROME_BROWSER_TRANSLATE_CHROME_TRANSLATE_CLIENT_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "chrome/browser/ui/translate/translate_bubble_model.h" | 11 #include "chrome/browser/ui/translate/translate_bubble_model.h" |
| 12 #include "components/translate/content/browser/browser_cld_data_provider.h" | 12 #include "components/translate/content/browser/browser_cld_data_provider.h" |
| 13 #include "components/translate/content/browser/content_translate_driver.h" | 13 #include "components/translate/content/browser/content_translate_driver.h" |
| 14 #include "components/translate/core/browser/translate_client.h" | 14 #include "components/translate/core/browser/translate_client.h" |
| 15 #include "components/translate/core/browser/translate_step.h" | 15 #include "components/translate/core/browser/translate_step.h" |
| 16 #include "components/translate/core/common/translate_errors.h" | 16 #include "components/translate/core/common/translate_errors.h" |
| 17 #include "content/public/browser/web_contents_observer.h" | 17 #include "content/public/browser/web_contents_observer.h" |
| 18 #include "content/public/browser/web_contents_user_data.h" | 18 #include "content/public/browser/web_contents_user_data.h" |
| 19 | 19 |
| 20 namespace base { | |
| 21 class File; | |
| 22 } // namespace base | |
| 23 | |
| 24 namespace content { | 20 namespace content { |
| 25 class BrowserContext; | 21 class BrowserContext; |
| 26 class WebContents; | 22 class WebContents; |
| 27 } // namespace content | 23 } // namespace content |
| 28 | 24 |
| 29 namespace test { | 25 namespace test { |
| 30 class ScopedCLDDynamicDataHarness; | 26 class ScopedCLDDynamicDataHarness; |
| 31 } // namespace test | 27 } // namespace test |
| 32 | 28 |
| 33 class PrefService; | 29 class PrefService; |
| 34 | 30 |
| 35 namespace translate { | 31 namespace translate { |
| 36 struct LanguageDetectionDetails; | |
| 37 class LanguageState; | 32 class LanguageState; |
| 38 class TranslateAcceptLanguages; | 33 class TranslateAcceptLanguages; |
| 39 class TranslatePrefs; | 34 class TranslatePrefs; |
| 40 class TranslateManager; | 35 class TranslateManager; |
| 41 } // namespace translate | 36 } // namespace translate |
| 42 | 37 |
| 43 class ChromeTranslateClient | 38 class ChromeTranslateClient |
| 44 : public translate::TranslateClient, | 39 : public translate::TranslateClient, |
| 40 public translate::ContentTranslateDriver::Observer, | |
| 45 public content::WebContentsObserver, | 41 public content::WebContentsObserver, |
| 46 public content::WebContentsUserData<ChromeTranslateClient> { | 42 public content::WebContentsUserData<ChromeTranslateClient> { |
| 47 public: | 43 public: |
| 48 virtual ~ChromeTranslateClient(); | 44 virtual ~ChromeTranslateClient(); |
| 49 | 45 |
| 50 // Gets the LanguageState associated with the page. | 46 // Gets the LanguageState associated with the page. |
| 51 translate::LanguageState& GetLanguageState(); | 47 translate::LanguageState& GetLanguageState(); |
| 52 | 48 |
| 53 // Returns the ContentTranslateDriver instance associated with this | 49 // Returns the ContentTranslateDriver instance associated with this |
| 54 // WebContents. | 50 // WebContents. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 scoped_ptr<translate::TranslateInfoBarDelegate> delegate) const OVERRIDE; | 89 scoped_ptr<translate::TranslateInfoBarDelegate> delegate) const OVERRIDE; |
| 94 virtual void ShowTranslateUI(translate::TranslateStep step, | 90 virtual void ShowTranslateUI(translate::TranslateStep step, |
| 95 const std::string source_language, | 91 const std::string source_language, |
| 96 const std::string target_language, | 92 const std::string target_language, |
| 97 translate::TranslateErrors::Type error_type, | 93 translate::TranslateErrors::Type error_type, |
| 98 bool triggered_from_menu) OVERRIDE; | 94 bool triggered_from_menu) OVERRIDE; |
| 99 virtual bool IsTranslatableURL(const GURL& url) OVERRIDE; | 95 virtual bool IsTranslatableURL(const GURL& url) OVERRIDE; |
| 100 virtual void ShowReportLanguageDetectionErrorUI( | 96 virtual void ShowReportLanguageDetectionErrorUI( |
| 101 const GURL& report_url) OVERRIDE; | 97 const GURL& report_url) OVERRIDE; |
| 102 | 98 |
| 99 // TranslateDriver::Observer implementation. | |
|
Takashi Toyoshima
2014/09/16 06:32:47
ContentTranslateDriver::Observer?
| |
| 100 virtual void OnLanguageDetermined( | |
| 101 const translate::LanguageDetectionDetails& details) OVERRIDE; | |
| 102 virtual void OnPageTranslated( | |
| 103 const std::string& original_lang, | |
| 104 const std::string& translated_lang, | |
| 105 translate::TranslateErrors::Type error_type) OVERRIDE; | |
| 106 | |
| 103 private: | 107 private: |
| 104 explicit ChromeTranslateClient(content::WebContents* web_contents); | 108 explicit ChromeTranslateClient(content::WebContents* web_contents); |
| 105 friend class content::WebContentsUserData<ChromeTranslateClient>; | 109 friend class content::WebContentsUserData<ChromeTranslateClient>; |
| 106 | 110 |
| 107 // content::WebContentsObserver implementation. | 111 // content::WebContentsObserver implementation. |
| 108 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 112 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 109 virtual void WebContentsDestroyed() OVERRIDE; | 113 virtual void WebContentsDestroyed() OVERRIDE; |
| 110 | 114 |
| 111 // IPC handlers. | |
| 112 void OnTranslateAssignedSequenceNumber(int page_seq_no); | |
| 113 void OnLanguageDetermined(const translate::LanguageDetectionDetails& details, | |
| 114 bool page_needs_translation); | |
| 115 void OnPageTranslated(const std::string& original_lang, | |
| 116 const std::string& translated_lang, | |
| 117 translate::TranslateErrors::Type error_type); | |
| 118 | |
| 119 // Shows the translate bubble. | 115 // Shows the translate bubble. |
| 120 void ShowBubble(translate::TranslateStep step, | 116 void ShowBubble(translate::TranslateStep step, |
| 121 translate::TranslateErrors::Type error_type); | 117 translate::TranslateErrors::Type error_type); |
| 122 | 118 |
| 123 translate::ContentTranslateDriver translate_driver_; | 119 translate::ContentTranslateDriver translate_driver_; |
| 124 scoped_ptr<translate::TranslateManager> translate_manager_; | 120 scoped_ptr<translate::TranslateManager> translate_manager_; |
| 125 | 121 |
| 126 // Provides CLD data for this process. | 122 // Provides CLD data for this process. |
| 127 scoped_ptr<translate::BrowserCldDataProvider> cld_data_provider_; | 123 scoped_ptr<translate::BrowserCldDataProvider> cld_data_provider_; |
| 128 | 124 |
| 129 DISALLOW_COPY_AND_ASSIGN(ChromeTranslateClient); | 125 DISALLOW_COPY_AND_ASSIGN(ChromeTranslateClient); |
| 130 }; | 126 }; |
| 131 | 127 |
| 132 #endif // CHROME_BROWSER_TRANSLATE_CHROME_TRANSLATE_CLIENT_H_ | 128 #endif // CHROME_BROWSER_TRANSLATE_CHROME_TRANSLATE_CLIENT_H_ |
| OLD | NEW |