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

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

Issue 1150193004: Straighten up life cycle of native InfoBar pointers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed unrelated file Created 5 years, 6 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
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_weak_ref.h" 10 #include "base/android/jni_weak_ref.h"
(...skipping 26 matching lines...) Expand all
37 ACTION_CREATE_NEW_FILE = 6, 37 ACTION_CREATE_NEW_FILE = 6,
38 }; 38 };
39 39
40 explicit InfoBarAndroid(scoped_ptr<infobars::InfoBarDelegate> delegate); 40 explicit InfoBarAndroid(scoped_ptr<infobars::InfoBarDelegate> delegate);
41 ~InfoBarAndroid() override; 41 ~InfoBarAndroid() override;
42 42
43 // InfoBar: 43 // InfoBar:
44 virtual base::android::ScopedJavaLocalRef<jobject> CreateRenderInfoBar( 44 virtual base::android::ScopedJavaLocalRef<jobject> CreateRenderInfoBar(
45 JNIEnv* env) = 0; 45 JNIEnv* env) = 0;
46 46
47 void set_java_infobar(const base::android::JavaRef<jobject>& java_info_bar); 47 virtual void SetJavaInfoBar(
48 const base::android::JavaRef<jobject>& java_info_bar);
49 jobject GetJavaInfoBar();
48 bool HasSetJavaInfoBar() const; 50 bool HasSetJavaInfoBar() const;
49 51
50 // Tells the Java-side counterpart of this InfoBar to point to the replacement 52 // Tells the Java-side counterpart of this InfoBar to point to the replacement
51 // InfoBar instead of this one. 53 // InfoBar instead of this one.
52 void ReassignJavaInfoBar(InfoBarAndroid* replacement); 54 void ReassignJavaInfoBar(InfoBarAndroid* replacement);
53 55
54 virtual void OnLinkClicked(JNIEnv* env, jobject obj) {} 56 virtual void OnLinkClicked(JNIEnv* env, jobject obj) {}
55 void OnButtonClicked(JNIEnv* env, 57 void OnButtonClicked(JNIEnv* env,
56 jobject obj, 58 jobject obj,
57 jint action, 59 jint action,
58 jstring action_value); 60 jstring action_value);
59 void OnCloseButtonClicked(JNIEnv* env, jobject obj); 61 void OnCloseButtonClicked(JNIEnv* env, jobject obj);
60 62
61 void CloseJavaInfoBar(); 63 void CloseJavaInfoBar();
62 64
63 // Maps from a Chromium ID (IDR_TRANSLATE) to a enum value that Java code can 65 // Maps from a Chromium ID (IDR_TRANSLATE) to a enum value that Java code can
64 // translate into a Drawable ID using the ResourceId class. 66 // translate into a Drawable ID using the ResourceId class.
65 int GetEnumeratedIconId(); 67 int GetEnumeratedIconId();
66 68
67 // Acquire the java infobar from a different one. This is used to do in-place 69 // Acquire the java infobar from a different one. This is used to do in-place
68 // replacements. 70 // replacements.
69 virtual void PassJavaInfoBar(InfoBarAndroid* source) {} 71 virtual void PassJavaInfoBar(InfoBarAndroid* source) {}
70 72
71 protected: 73 protected:
72 // Derived classes must implement this method to process the corresponding 74 // Derived classes must implement this method to process the corresponding
73 // action. 75 // action.
74 virtual void ProcessButton(int action, 76 virtual void ProcessButton(int action,
75 const std::string& action_value) = 0; 77 const std::string& action_value) = 0;
76 void CloseInfoBar(); 78 void CloseInfoBar();
79 InfoBarAndroid* infobar_android() { return this; }
77 80
78 private: 81 private:
79 base::android::ScopedJavaGlobalRef<jobject> java_info_bar_; 82 base::android::ScopedJavaGlobalRef<jobject> java_info_bar_;
80 83
81 DISALLOW_COPY_AND_ASSIGN(InfoBarAndroid); 84 DISALLOW_COPY_AND_ASSIGN(InfoBarAndroid);
82 }; 85 };
83 86
84 // Registers the NativeInfoBar's native methods through JNI. 87 // Registers the NativeInfoBar's native methods through JNI.
85 bool RegisterNativeInfoBar(JNIEnv* env); 88 bool RegisterNativeInfoBar(JNIEnv* env);
86 89
87 #endif // CHROME_BROWSER_UI_ANDROID_INFOBARS_INFOBAR_ANDROID_H_ 90 #endif // CHROME_BROWSER_UI_ANDROID_INFOBARS_INFOBAR_ANDROID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698