| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_UI_ANDROID_INFOBARS_TRANSLATE_COMPACT_INFOBAR_H_ | 5 #ifndef CHROME_BROWSER_UI_ANDROID_INFOBARS_TRANSLATE_COMPACT_INFOBAR_H_ |
| 6 #define CHROME_BROWSER_UI_ANDROID_INFOBARS_TRANSLATE_COMPACT_INFOBAR_H_ | 6 #define CHROME_BROWSER_UI_ANDROID_INFOBARS_TRANSLATE_COMPACT_INFOBAR_H_ |
| 7 | 7 |
| 8 #include "base/android/scoped_java_ref.h" | 8 #include "base/android/scoped_java_ref.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "chrome/browser/translate/chrome_translate_client.h" | 10 #include "chrome/browser/translate/chrome_translate_client.h" |
| 11 #include "chrome/browser/ui/android/infobars/infobar_android.h" | 11 #include "chrome/browser/ui/android/infobars/infobar_android.h" |
| 12 #include "components/translate/content/browser/content_translate_driver.h" |
| 12 | 13 |
| 13 namespace translate { | 14 namespace translate { |
| 14 class TranslateInfoBarDelegate; | 15 class TranslateInfoBarDelegate; |
| 15 } | 16 } |
| 16 | 17 |
| 17 class TranslateCompactInfoBar : public InfoBarAndroid { | 18 class TranslateCompactInfoBar |
| 19 : public InfoBarAndroid, |
| 20 public translate::ContentTranslateDriver::Observer { |
| 18 public: | 21 public: |
| 19 explicit TranslateCompactInfoBar( | 22 explicit TranslateCompactInfoBar( |
| 20 std::unique_ptr<translate::TranslateInfoBarDelegate> delegate); | 23 std::unique_ptr<translate::TranslateInfoBarDelegate> delegate); |
| 21 ~TranslateCompactInfoBar() override; | 24 ~TranslateCompactInfoBar() override; |
| 22 | 25 |
| 23 // JNI methods specific to translate. | 26 // JNI methods specific to translate. |
| 24 void ApplyTranslateOptions(JNIEnv* env, | 27 void ApplyTranslateOptions(JNIEnv* env, |
| 25 const base::android::JavaParamRef<jobject>& obj); | 28 const base::android::JavaParamRef<jobject>& obj); |
| 26 | 29 |
| 30 // ContentTranslateDriver::Observer implementation. |
| 31 void OnPageTranslated(const std::string& original_lang, |
| 32 const std::string& translated_lang, |
| 33 translate::TranslateErrors::Type error_type) override; |
| 34 |
| 27 private: | 35 private: |
| 28 // InfoBarAndroid: | 36 // InfoBarAndroid: |
| 29 base::android::ScopedJavaLocalRef<jobject> CreateRenderInfoBar( | 37 base::android::ScopedJavaLocalRef<jobject> CreateRenderInfoBar( |
| 30 JNIEnv* env) override; | 38 JNIEnv* env) override; |
| 31 void ProcessButton(int action) override; | 39 void ProcessButton(int action) override; |
| 32 void SetJavaInfoBar( | 40 void SetJavaInfoBar( |
| 33 const base::android::JavaRef<jobject>& java_info_bar) override; | 41 const base::android::JavaRef<jobject>& java_info_bar) override; |
| 34 | 42 |
| 35 translate::TranslateInfoBarDelegate* GetDelegate(); | 43 translate::TranslateInfoBarDelegate* GetDelegate(); |
| 44 translate::ContentTranslateDriver* translate_driver_; |
| 36 | 45 |
| 37 DISALLOW_COPY_AND_ASSIGN(TranslateCompactInfoBar); | 46 DISALLOW_COPY_AND_ASSIGN(TranslateCompactInfoBar); |
| 38 }; | 47 }; |
| 39 | 48 |
| 40 // Registers the native methods through JNI. | 49 // Registers the native methods through JNI. |
| 41 bool RegisterTranslateCompactInfoBar(JNIEnv* env); | 50 bool RegisterTranslateCompactInfoBar(JNIEnv* env); |
| 42 | 51 |
| 43 #endif | 52 #endif |
| OLD | NEW |