| 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 #include "components/translate/content/browser/content_translate_driver.h" |
| 13 | 13 |
| 14 namespace translate { | 14 namespace translate { |
| 15 class TranslateInfoBarDelegate; | 15 class TranslateInfoBarDelegate; |
| 16 } | 16 } |
| 17 | 17 |
| 18 class TranslateCompactInfoBar | 18 class TranslateCompactInfoBar |
| 19 : public InfoBarAndroid, | 19 : public InfoBarAndroid, |
| 20 public translate::ContentTranslateDriver::Observer { | 20 public translate::ContentTranslateDriver::Observer { |
| 21 public: | 21 public: |
| 22 explicit TranslateCompactInfoBar( | 22 explicit TranslateCompactInfoBar( |
| 23 std::unique_ptr<translate::TranslateInfoBarDelegate> delegate); | 23 std::unique_ptr<translate::TranslateInfoBarDelegate> delegate); |
| 24 ~TranslateCompactInfoBar() override; | 24 ~TranslateCompactInfoBar() override; |
| 25 | 25 |
| 26 // JNI methods specific to translate. | 26 // JNI method specific to string settings in translate. |
| 27 void ApplyTranslateOptions(JNIEnv* env, | 27 void ApplyStringTranslateOption( |
| 28 const base::android::JavaParamRef<jobject>& obj); | 28 JNIEnv* env, |
| 29 const base::android::JavaParamRef<jobject>& obj, |
| 30 int option, |
| 31 const base::android::JavaParamRef<jstring>& value); |
| 32 |
| 33 // JNI method specific to boolean settings in translate. |
| 34 void ApplyBoolTranslateOption(JNIEnv* env, |
| 35 const base::android::JavaParamRef<jobject>& obj, |
| 36 int option, |
| 37 jboolean value); |
| 29 | 38 |
| 30 // ContentTranslateDriver::Observer implementation. | 39 // ContentTranslateDriver::Observer implementation. |
| 31 void OnPageTranslated(const std::string& original_lang, | 40 void OnPageTranslated(const std::string& original_lang, |
| 32 const std::string& translated_lang, | 41 const std::string& translated_lang, |
| 33 translate::TranslateErrors::Type error_type) override; | 42 translate::TranslateErrors::Type error_type) override; |
| 34 | 43 |
| 35 private: | 44 private: |
| 36 // InfoBarAndroid: | 45 // InfoBarAndroid: |
| 37 base::android::ScopedJavaLocalRef<jobject> CreateRenderInfoBar( | 46 base::android::ScopedJavaLocalRef<jobject> CreateRenderInfoBar( |
| 38 JNIEnv* env) override; | 47 JNIEnv* env) override; |
| 39 void ProcessButton(int action) override; | 48 void ProcessButton(int action) override; |
| 40 void SetJavaInfoBar( | 49 void SetJavaInfoBar( |
| 41 const base::android::JavaRef<jobject>& java_info_bar) override; | 50 const base::android::JavaRef<jobject>& java_info_bar) override; |
| 42 | 51 |
| 43 translate::TranslateInfoBarDelegate* GetDelegate(); | 52 translate::TranslateInfoBarDelegate* GetDelegate(); |
| 44 translate::ContentTranslateDriver* translate_driver_; | 53 translate::ContentTranslateDriver* translate_driver_; |
| 45 | 54 |
| 46 DISALLOW_COPY_AND_ASSIGN(TranslateCompactInfoBar); | 55 DISALLOW_COPY_AND_ASSIGN(TranslateCompactInfoBar); |
| 47 }; | 56 }; |
| 48 | 57 |
| 49 // Registers the native methods through JNI. | 58 // Registers the native methods through JNI. |
| 50 bool RegisterTranslateCompactInfoBar(JNIEnv* env); | 59 bool RegisterTranslateCompactInfoBar(JNIEnv* env); |
| 51 | 60 |
| 52 #endif // CHROME_BROWSER_UI_ANDROID_INFOBARS_TRANSLATE_COMPACT_INFOBAR_H_ | 61 #endif // CHROME_BROWSER_UI_ANDROID_INFOBARS_TRANSLATE_COMPACT_INFOBAR_H_ |
| OLD | NEW |