Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: chrome/browser/ui/android/infobars/infobar_android.h

Issue 24562006: Cleanup upstreamed Android infobar code. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "base/android/scoped_java_ref.h" 11 #include "base/android/scoped_java_ref.h"
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "chrome/browser/infobars/infobar.h" 14 #include "chrome/browser/infobars/infobar.h"
15 15
16 class InfoBarDelegate; 16 class InfoBarDelegate;
17 class InfoBarService; 17 class InfoBarService;
18 18
19 namespace gfx {
20 class Image;
21 }
22
23 class InfoBarAndroid : public InfoBar { 19 class InfoBarAndroid : public InfoBar {
24 public: 20 public:
25 21
26 // Make sure this set of values is aligned with the java constants defined in 22 // Make sure this set of values is aligned with the java constants defined in
27 // InfoBar.java 23 // InfoBar.java!
28 enum ActionType { 24 enum ActionType {
29 ACTION_NONE = 0, 25 ACTION_NONE = 0,
30 // Confirm infobar 26 // Confirm infobar
31 ACTION_OK = 1, 27 ACTION_OK = 1,
32 ACTION_CANCEL = 2, 28 ACTION_CANCEL = 2,
33 // Translate infobar 29 // Translate infobar
34 ACTION_TRANSLATE = 3, 30 ACTION_TRANSLATE = 3,
35 ACTION_TRANSLATE_SHOW_ORIGINAL = 4, 31 ACTION_TRANSLATE_SHOW_ORIGINAL = 4,
36 }; 32 };
37 33
38 InfoBarAndroid(InfoBarService* owner, InfoBarDelegate* delegate); 34 InfoBarAndroid(InfoBarService* owner, InfoBarDelegate* delegate);
39 virtual ~InfoBarAndroid(); 35 virtual ~InfoBarAndroid();
40 36
41 // InfoBar 37 // InfoBar:
42 virtual base::android::ScopedJavaLocalRef<jobject> CreateRenderInfoBar( 38 virtual base::android::ScopedJavaLocalRef<jobject> CreateRenderInfoBar(
43 JNIEnv* env) = 0; 39 JNIEnv* env) = 0;
44 40
45 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);
46
47 bool HasSetJavaInfoBar() const; 42 bool HasSetJavaInfoBar() const;
48 43
49 // 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
50 // InfoBar instead of this one. 45 // InfoBar instead of this one.
51 void ReassignJavaInfoBar(InfoBarAndroid* replacement); 46 void ReassignJavaInfoBar(InfoBarAndroid* replacement);
52 47
53 void OnButtonClicked(JNIEnv* env, jobject obj, 48 void OnButtonClicked(JNIEnv* env,
54 jint action, jstring action_value); 49 jobject obj,
50 jint action,
51 jstring action_value);
55 void OnCloseButtonClicked(JNIEnv* env, jobject obj); 52 void OnCloseButtonClicked(JNIEnv* env, jobject obj);
56 53
57 void OnInfoBarClosed(JNIEnv* env, jobject obj); 54 void OnInfoBarClosed(JNIEnv* env, jobject obj);
58 55
59 void CloseJavaInfoBar(); 56 void CloseJavaInfoBar();
60 57
61 // Maps from a Chromium ID (IDR_TRANSLATE) to a enum value that Java code can 58 // 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. 59 // translate into a Drawable ID using the ResourceId class.
63 int GetEnumeratedIconId(); 60 int GetEnumeratedIconId();
64 61
65 // Acquire the java infobar from a different one. 62 // Acquire the java infobar from a different one. This is used to do in-place
66 // This is used to do in place replacements. 63 // replacements.
67 virtual void PassJavaInfoBar(InfoBarAndroid* source) {} 64 virtual void PassJavaInfoBar(InfoBarAndroid* source) {}
68 65
69 protected: 66 protected:
70 // Derived classes must implement this method to process the 67 // Derived classes must implement this method to process the corresponding
71 // corresponding action. 68 // action.
72 virtual void ProcessButton( 69 virtual void ProcessButton(int action,
73 int action, const std::string& action_value) = 0; 70 const std::string& action_value) = 0;
74 void CloseInfoBar(); 71 void CloseInfoBar();
75 72
76 private: 73 private:
77 // The InfoBar's delegate. 74 // The InfoBar's delegate.
78 InfoBarDelegate* delegate_; 75 InfoBarDelegate* delegate_;
79 base::android::ScopedJavaGlobalRef<jobject> java_info_bar_; 76 base::android::ScopedJavaGlobalRef<jobject> java_info_bar_;
80 77
81 DISALLOW_COPY_AND_ASSIGN(InfoBarAndroid); 78 DISALLOW_COPY_AND_ASSIGN(InfoBarAndroid);
82 }; 79 };
83 80
84 // Register the NativeInfoBar's native methods through jni 81 // Registers the NativeInfoBar's native methods through JNI.
85 bool RegisterNativeInfoBar(JNIEnv* env); 82 bool RegisterNativeInfoBar(JNIEnv* env);
86 83
87 #endif // CHROME_BROWSER_UI_ANDROID_INFOBARS_INFOBAR_ANDROID_H_ 84 #endif // CHROME_BROWSER_UI_ANDROID_INFOBARS_INFOBAR_ANDROID_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/android/infobars/confirm_infobar.cc ('k') | chrome/browser/ui/android/infobars/infobar_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698