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.
5 #ifndef CHROME_BROWSER_UI_ANDROID_INFOBARS_INFOBAR_ANDROID_H_
6 #define CHROME_BROWSER_UI_ANDROID_INFOBARS_INFOBAR_ANDROID_H_
10 #include "base/android/jni_weak_ref.h"
11 #include "base/android/scoped_java_ref.h"
12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h"
14 #include "components/infobars/core/infobar.h"
19 class InfoBarDelegate
;
22 class InfoBarAndroid
: public infobars::InfoBar
{
25 // A Java counterpart will be generated for this enum.
26 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.infobar
27 // GENERATED_JAVA_PREFIX_TO_STRIP: ACTION_
35 ACTION_TRANSLATE_SHOW_ORIGINAL
= 4,
36 // Download overwrite infobar
38 ACTION_CREATE_NEW_FILE
= 6,
41 explicit InfoBarAndroid(scoped_ptr
<infobars::InfoBarDelegate
> delegate
);
42 ~InfoBarAndroid() override
;
45 virtual base::android::ScopedJavaLocalRef
<jobject
> CreateRenderInfoBar(
48 virtual void SetJavaInfoBar(
49 const base::android::JavaRef
<jobject
>& java_info_bar
);
50 jobject
GetJavaInfoBar();
51 bool HasSetJavaInfoBar() const;
53 // Tells the Java-side counterpart of this InfoBar to point to the replacement
54 // InfoBar instead of this one.
55 void ReassignJavaInfoBar(InfoBarAndroid
* replacement
);
57 virtual void OnLinkClicked(JNIEnv
* env
, jobject obj
) {}
58 void OnButtonClicked(JNIEnv
* env
,
61 jstring action_value
);
62 void OnCloseButtonClicked(JNIEnv
* env
, jobject obj
);
64 void CloseJavaInfoBar();
66 // Maps from a Chromium ID (IDR_TRANSLATE) to a enum value that Java code can
67 // translate into a Drawable ID using the ResourceId class.
68 int GetEnumeratedIconId();
70 // Acquire the java infobar from a different one. This is used to do in-place
72 virtual void PassJavaInfoBar(InfoBarAndroid
* source
) {}
75 // Derived classes must implement this method to process the corresponding
77 virtual void ProcessButton(int action
,
78 const std::string
& action_value
) = 0;
80 InfoBarAndroid
* infobar_android() { return this; }
83 base::android::ScopedJavaGlobalRef
<jobject
> java_info_bar_
;
85 DISALLOW_COPY_AND_ASSIGN(InfoBarAndroid
);
88 // Registers the NativeInfoBar's native methods through JNI.
89 bool RegisterNativeInfoBar(JNIEnv
* env
);
91 #endif // CHROME_BROWSER_UI_ANDROID_INFOBARS_INFOBAR_ANDROID_H_