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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_UI_ANDROID_INFOBARS_INFOBAR_CONTAINER_ANDROID_H_ 6 #define CHROME_BROWSER_UI_ANDROID_INFOBARS_INFOBAR_CONTAINER_ANDROID_H_ 7 8 #include <map> 9 #include <string> 10 11 #include "base/android/jni_weak_ref.h" 12 #include "base/android/scoped_java_ref.h" 13 #include "base/basictypes.h" 14 #include "base/compiler_specific.h" 15 #include "components/infobars/core/infobar_container.h" 16 17 class InfoBarAndroid; 18 19 namespace content { 20 class WebContents; 21 } 22 23 class InfoBarContainerAndroid : public infobars::InfoBarContainer { 24 public: 25 InfoBarContainerAndroid(JNIEnv* env, 26 jobject infobar_container, 27 jobject auto_login_delegate); 28 void Destroy(JNIEnv* env, jobject obj); 29 30 JavaObjectWeakGlobalRef auto_login_delegate() const { 31 return weak_java_auto_login_delegate_; 32 } 33 34 JavaObjectWeakGlobalRef java_container() const { 35 return weak_java_infobar_container_; 36 } 37 38 private: 39 virtual ~InfoBarContainerAndroid() OVERRIDE; 40 41 // InfobarContainer: 42 virtual void PlatformSpecificAddInfoBar(infobars::InfoBar* infobar, 43 size_t position) OVERRIDE; 44 virtual void PlatformSpecificRemoveInfoBar(infobars::InfoBar* infobar) 45 OVERRIDE; 46 virtual void PlatformSpecificReplaceInfoBar( 47 infobars::InfoBar* old_infobar, 48 infobars::InfoBar* new_infobar) OVERRIDE; 49 50 // Create the Java equivalent of |android_bar| and add it to the java 51 // container. 52 void AttachJavaInfoBar(InfoBarAndroid* android_bar); 53 54 // We're owned by the java infobar, need to use a weak ref so it can destroy 55 // us. 56 JavaObjectWeakGlobalRef weak_java_infobar_container_; 57 JavaObjectWeakGlobalRef weak_java_auto_login_delegate_; 58 59 DISALLOW_COPY_AND_ASSIGN(InfoBarContainerAndroid); 60 }; 61 62 // Registers the InfoBarContainer's native methods through JNI. 63 bool RegisterInfoBarContainer(JNIEnv* env); 64 65 #endif // CHROME_BROWSER_UI_ANDROID_INFOBARS_INFOBAR_CONTAINER_ANDROID_H_ 66