OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_INFOBAR_ANDROID_H_ | 5 #ifndef CHROME_BROWSER_UI_ANDROID_INFOBARS_INFOBAR_ANDROID_H_ |
6 #define CHROME_BROWSER_UI_ANDROID_INFOBARS_INFOBAR_ANDROID_H_ | 6 #define CHROME_BROWSER_UI_ANDROID_INFOBARS_INFOBAR_ANDROID_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/android/jni_helper.h" | 10 #include "base/android/jni_helper.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 enum ActionType { | 24 enum ActionType { |
25 ACTION_NONE = 0, | 25 ACTION_NONE = 0, |
26 // Confirm infobar | 26 // Confirm infobar |
27 ACTION_OK = 1, | 27 ACTION_OK = 1, |
28 ACTION_CANCEL = 2, | 28 ACTION_CANCEL = 2, |
29 // Translate infobar | 29 // Translate infobar |
30 ACTION_TRANSLATE = 3, | 30 ACTION_TRANSLATE = 3, |
31 ACTION_TRANSLATE_SHOW_ORIGINAL = 4, | 31 ACTION_TRANSLATE_SHOW_ORIGINAL = 4, |
32 }; | 32 }; |
33 | 33 |
34 InfoBarAndroid(InfoBarService* owner, InfoBarDelegate* delegate); | 34 explicit InfoBarAndroid(scoped_ptr<InfoBarDelegate> delegate); |
35 virtual ~InfoBarAndroid(); | 35 virtual ~InfoBarAndroid(); |
36 | 36 |
37 // InfoBar: | 37 // InfoBar: |
38 virtual base::android::ScopedJavaLocalRef<jobject> CreateRenderInfoBar( | 38 virtual base::android::ScopedJavaLocalRef<jobject> CreateRenderInfoBar( |
39 JNIEnv* env) = 0; | 39 JNIEnv* env) = 0; |
40 | 40 |
41 void set_java_infobar(const base::android::JavaRef<jobject>& java_info_bar); | 41 void set_java_infobar(const base::android::JavaRef<jobject>& java_info_bar); |
42 bool HasSetJavaInfoBar() const; | 42 bool HasSetJavaInfoBar() const; |
43 | 43 |
44 // Tells the Java-side counterpart of this InfoBar to point to the replacement | 44 // Tells the Java-side counterpart of this InfoBar to point to the replacement |
45 // InfoBar instead of this one. | 45 // InfoBar instead of this one. |
46 void ReassignJavaInfoBar(InfoBarAndroid* replacement); | 46 void ReassignJavaInfoBar(InfoBarAndroid* replacement); |
47 | 47 |
48 void OnButtonClicked(JNIEnv* env, | 48 void OnButtonClicked(JNIEnv* env, |
49 jobject obj, | 49 jobject obj, |
50 jint action, | 50 jint action, |
51 jstring action_value); | 51 jstring action_value); |
52 void OnCloseButtonClicked(JNIEnv* env, jobject obj); | 52 void OnCloseButtonClicked(JNIEnv* env, jobject obj); |
53 | 53 |
| 54 // TODO(pkasting): Who calls this and why? Seems like it should go away |
54 void OnInfoBarClosed(JNIEnv* env, jobject obj); | 55 void OnInfoBarClosed(JNIEnv* env, jobject obj); |
55 | 56 |
56 void CloseJavaInfoBar(); | 57 void CloseJavaInfoBar(); |
57 | 58 |
58 // Maps from a Chromium ID (IDR_TRANSLATE) to a enum value that Java code can | 59 // Maps from a Chromium ID (IDR_TRANSLATE) to a enum value that Java code can |
59 // translate into a Drawable ID using the ResourceId class. | 60 // translate into a Drawable ID using the ResourceId class. |
60 int GetEnumeratedIconId(); | 61 int GetEnumeratedIconId(); |
61 | 62 |
62 // Acquire the java infobar from a different one. This is used to do in-place | 63 // Acquire the java infobar from a different one. This is used to do in-place |
63 // replacements. | 64 // replacements. |
64 virtual void PassJavaInfoBar(InfoBarAndroid* source) {} | 65 virtual void PassJavaInfoBar(InfoBarAndroid* source) {} |
65 | 66 |
66 protected: | 67 protected: |
67 // Derived classes must implement this method to process the corresponding | 68 // Derived classes must implement this method to process the corresponding |
68 // action. | 69 // action. |
69 virtual void ProcessButton(int action, | 70 virtual void ProcessButton(int action, |
70 const std::string& action_value) = 0; | 71 const std::string& action_value) = 0; |
71 void CloseInfoBar(); | 72 void CloseInfoBar(); |
72 | 73 |
73 private: | 74 private: |
74 // The InfoBar's delegate. | |
75 InfoBarDelegate* delegate_; | |
76 base::android::ScopedJavaGlobalRef<jobject> java_info_bar_; | 75 base::android::ScopedJavaGlobalRef<jobject> java_info_bar_; |
77 | 76 |
78 DISALLOW_COPY_AND_ASSIGN(InfoBarAndroid); | 77 DISALLOW_COPY_AND_ASSIGN(InfoBarAndroid); |
79 }; | 78 }; |
80 | 79 |
81 // Registers the NativeInfoBar's native methods through JNI. | 80 // Registers the NativeInfoBar's native methods through JNI. |
82 bool RegisterNativeInfoBar(JNIEnv* env); | 81 bool RegisterNativeInfoBar(JNIEnv* env); |
83 | 82 |
84 #endif // CHROME_BROWSER_UI_ANDROID_INFOBARS_INFOBAR_ANDROID_H_ | 83 #endif // CHROME_BROWSER_UI_ANDROID_INFOBARS_INFOBAR_ANDROID_H_ |
OLD | NEW |