OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 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_UI_ANDROID_INFOBAR_INFOBAR_ANDROID_H_ |
| 6 #define CHROME_BROWSER_UI_ANDROID_INFOBAR_INFOBAR_ANDROID_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/android/jni_helper.h" |
| 11 #include "base/android/scoped_java_ref.h" |
| 12 #include "base/basictypes.h" |
| 13 #include "base/compiler_specific.h" |
| 14 #include "chrome/browser/infobars/infobar.h" |
| 15 |
| 16 class InfoBarDelegate; |
| 17 class InfoBarService; |
| 18 |
| 19 namespace gfx { |
| 20 class Image; |
| 21 } |
| 22 |
| 23 class InfoBarAndroid : public InfoBar { |
| 24 public: |
| 25 |
| 26 // Make sure this set of values is aligned with the java constants defined in |
| 27 // InfoBar.java |
| 28 enum ActionType { |
| 29 ACTION_NONE = 0, |
| 30 // Confirm infobar |
| 31 ACTION_OK = 1, |
| 32 ACTION_CANCEL = 2, |
| 33 // Translate infobar |
| 34 ACTION_TRANSLATE = 3, |
| 35 ACTION_TRANSLATE_SHOW_ORIGINAL = 4, |
| 36 }; |
| 37 |
| 38 InfoBarAndroid(InfoBarService* owner, InfoBarDelegate* delegate); |
| 39 virtual ~InfoBarAndroid(); |
| 40 |
| 41 // InfoBar |
| 42 virtual base::android::ScopedJavaLocalRef<jobject> CreateRenderInfoBar( |
| 43 JNIEnv* env) = 0; |
| 44 |
| 45 void set_java_infobar(const base::android::JavaRef<jobject>& java_info_bar); |
| 46 |
| 47 bool HasSetJavaInfoBar() const; |
| 48 |
| 49 // Tells the Java-side counterpart of this InfoBar to point to the replacement |
| 50 // InfoBar instead of this one. |
| 51 void ReassignJavaInfoBar(InfoBarAndroid* replacement); |
| 52 |
| 53 void OnButtonClicked(JNIEnv* env, jobject obj, |
| 54 jint action, jstring action_value); |
| 55 void OnCloseButtonClicked(JNIEnv* env, jobject obj); |
| 56 |
| 57 void OnInfoBarClosed(JNIEnv* env, jobject obj); |
| 58 |
| 59 void CloseJavaInfoBar(); |
| 60 |
| 61 // Maps from a Chromium ID (IDR_TRANSLATE) to a enum value that Java code can |
| 62 // translate into a Drawable ID using the ResourceId class. |
| 63 int GetEnumeratedIconId(); |
| 64 |
| 65 // Acquire the java infobar from a different one. |
| 66 // This is used to do in place replacements. |
| 67 virtual void PassJavaInfoBar(InfoBarAndroid* source) {} |
| 68 |
| 69 protected: |
| 70 // Derived classes must implement this method to process the |
| 71 // corresponding action. |
| 72 virtual void ProcessButton( |
| 73 int action, const std::string& action_value) = 0; |
| 74 void CloseInfoBar(); |
| 75 |
| 76 private: |
| 77 // The InfoBar's delegate. |
| 78 InfoBarDelegate* delegate_; |
| 79 base::android::ScopedJavaGlobalRef<jobject> java_info_bar_; |
| 80 |
| 81 DISALLOW_COPY_AND_ASSIGN(InfoBarAndroid); |
| 82 }; |
| 83 |
| 84 // Register the NativeInfoBar's native methods through jni |
| 85 bool RegisterNativeInfoBar(JNIEnv* env); |
| 86 |
| 87 #endif // CHROME_BROWSER_UI_ANDROID_INFOBAR_INFOBAR_ANDROID_H_ |
OLD | NEW |