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_helper.h" 12#include "base/android/scoped_java_ref.h" 13#include "base/basictypes.h" 14#include "base/compiler_specific.h" 15#include "chrome/browser/infobars/infobar_container.h" 16 17class InfoBarAndroid; 18 19namespace content { 20class WebContents; 21} 22 23class InfoBarContainerAndroid : public 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(InfoBar* infobar, 43 size_t position) OVERRIDE; 44 virtual void PlatformSpecificRemoveInfoBar(InfoBar* infobar) OVERRIDE; 45 virtual void PlatformSpecificReplaceInfoBar(InfoBar* old_infobar, 46 InfoBar* new_infobar) OVERRIDE; 47 48 // Create the Java equivalent of |android_bar| and add it to the java 49 // container. 50 void AttachJavaInfoBar(InfoBarAndroid* android_bar); 51 52 // We're owned by the java infobar, need to use a weak ref so it can destroy 53 // us. 54 JavaObjectWeakGlobalRef weak_java_infobar_container_; 55 JavaObjectWeakGlobalRef weak_java_auto_login_delegate_; 56 57 DISALLOW_COPY_AND_ASSIGN(InfoBarContainerAndroid); 58}; 59 60// Registers the InfoBarContainer's native methods through JNI. 61bool RegisterInfoBarContainer(JNIEnv* env); 62 63#endif // CHROME_BROWSER_UI_ANDROID_INFOBARS_INFOBAR_CONTAINER_ANDROID_H_ 64