Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / chrome / browser / ui / android / infobars / infobar_android.h
blob8070753b00fcd500340077bae76925c0a761326f
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_
8 #include <string>
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"
16 class InfoBarService;
18 namespace infobars {
19 class InfoBarDelegate;
22 class InfoBarAndroid : public infobars::InfoBar {
23 public:
25 // Make sure this set of values is aligned with the java constants defined in
26 // InfoBar.java!
27 enum ActionType {
28 ACTION_NONE = 0,
29 // Confirm infobar
30 ACTION_OK = 1,
31 ACTION_CANCEL = 2,
32 // Translate infobar
33 ACTION_TRANSLATE = 3,
34 ACTION_TRANSLATE_SHOW_ORIGINAL = 4,
35 // Download overwrite infobar
36 ACTION_OVERWRITE = 5,
37 ACTION_CREATE_NEW_FILE = 6,
40 explicit InfoBarAndroid(scoped_ptr<infobars::InfoBarDelegate> delegate);
41 ~InfoBarAndroid() override;
43 // InfoBar:
44 virtual base::android::ScopedJavaLocalRef<jobject> CreateRenderInfoBar(
45 JNIEnv* env) = 0;
47 void set_java_infobar(const base::android::JavaRef<jobject>& java_info_bar);
48 bool HasSetJavaInfoBar() const;
50 // Tells the Java-side counterpart of this InfoBar to point to the replacement
51 // InfoBar instead of this one.
52 void ReassignJavaInfoBar(InfoBarAndroid* replacement);
54 virtual void OnLinkClicked(JNIEnv* env, jobject obj) {}
55 void OnButtonClicked(JNIEnv* env,
56 jobject obj,
57 jint action,
58 jstring action_value);
59 void OnCloseButtonClicked(JNIEnv* env, jobject obj);
61 void CloseJavaInfoBar();
63 // 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.
65 int GetEnumeratedIconId();
67 // Acquire the java infobar from a different one. This is used to do in-place
68 // replacements.
69 virtual void PassJavaInfoBar(InfoBarAndroid* source) {}
71 protected:
72 // Derived classes must implement this method to process the corresponding
73 // action.
74 virtual void ProcessButton(int action,
75 const std::string& action_value) = 0;
76 void CloseInfoBar();
78 private:
79 base::android::ScopedJavaGlobalRef<jobject> java_info_bar_;
81 DISALLOW_COPY_AND_ASSIGN(InfoBarAndroid);
84 // Registers the NativeInfoBar's native methods through JNI.
85 bool RegisterNativeInfoBar(JNIEnv* env);
87 #endif // CHROME_BROWSER_UI_ANDROID_INFOBARS_INFOBAR_ANDROID_H_