OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "chrome/browser/ui/android/infobars/grouped_permission_infobar.h" | 5 #include "chrome/browser/ui/android/infobars/grouped_permission_infobar.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
10 #include "chrome/browser/android/resource_mapper.h" | 10 #include "chrome/browser/android/resource_mapper.h" |
11 #include "chrome/browser/permissions/grouped_permission_infobar_delegate.h" | 11 #include "chrome/browser/permissions/grouped_permission_infobar_delegate.h" |
12 #include "jni/GroupedPermissionInfoBar_jni.h" | 12 #include "jni/GroupedPermissionInfoBar_jni.h" |
13 | 13 |
14 GroupedPermissionInfoBar::GroupedPermissionInfoBar( | 14 GroupedPermissionInfoBar::GroupedPermissionInfoBar( |
15 std::unique_ptr<GroupedPermissionInfoBarDelegate> delegate) | 15 std::unique_ptr<GroupedPermissionInfoBarDelegate> delegate) |
16 : ConfirmInfoBar(std::move(delegate)) {} | 16 : ConfirmInfoBar(std::move(delegate)) {} |
17 | 17 |
18 GroupedPermissionInfoBar::~GroupedPermissionInfoBar() { | 18 GroupedPermissionInfoBar::~GroupedPermissionInfoBar() { |
19 } | 19 } |
20 | 20 |
21 bool GroupedPermissionInfoBar::Register(JNIEnv* env) { | 21 bool GroupedPermissionInfoBar::Register(JNIEnv* env) { |
22 return RegisterNativesImpl(env); | 22 return RegisterNativesImpl(env); |
23 } | 23 } |
24 | 24 |
| 25 void GroupedPermissionInfoBar::ToggleAccept( |
| 26 JNIEnv* env, |
| 27 const base::android::JavaParamRef<jobject>& obj, |
| 28 jint position, |
| 29 jboolean value) { |
| 30 GetDelegate()->ToggleAccept(position, value); |
| 31 } |
| 32 |
25 base::android::ScopedJavaLocalRef<jobject> | 33 base::android::ScopedJavaLocalRef<jobject> |
26 GroupedPermissionInfoBar::CreateRenderInfoBar(JNIEnv* env) { | 34 GroupedPermissionInfoBar::CreateRenderInfoBar(JNIEnv* env) { |
27 GroupedPermissionInfoBarDelegate* delegate = GetDelegate(); | 35 GroupedPermissionInfoBarDelegate* delegate = GetDelegate(); |
28 | 36 |
29 base::android::ScopedJavaLocalRef<jstring> message_text = | 37 base::android::ScopedJavaLocalRef<jstring> message_text = |
30 base::android::ConvertUTF16ToJavaString( | 38 base::android::ConvertUTF16ToJavaString( |
31 env, delegate->GetMessageText()); | 39 env, delegate->GetMessageText()); |
32 base::android::ScopedJavaLocalRef<jstring> ok_button_text = | 40 base::android::ScopedJavaLocalRef<jstring> ok_button_text = |
33 base::android::ConvertUTF16ToJavaString( | 41 base::android::ConvertUTF16ToJavaString( |
34 env, GetTextFor(ConfirmInfoBarDelegate::BUTTON_OK)); | 42 env, GetTextFor(ConfirmInfoBarDelegate::BUTTON_OK)); |
(...skipping 13 matching lines...) Expand all Loading... |
48 } | 56 } |
49 | 57 |
50 return Java_GroupedPermissionInfoBar_create( | 58 return Java_GroupedPermissionInfoBar_create( |
51 env, message_text.obj(), ok_button_text.obj(), cancel_button_text.obj(), | 59 env, message_text.obj(), ok_button_text.obj(), cancel_button_text.obj(), |
52 base::android::ToJavaIntArray(env, permission_icons).obj(), | 60 base::android::ToJavaIntArray(env, permission_icons).obj(), |
53 base::android::ToJavaArrayOfStrings(env, permission_strings).obj(), | 61 base::android::ToJavaArrayOfStrings(env, permission_strings).obj(), |
54 GetWindowAndroid().obj(), | 62 GetWindowAndroid().obj(), |
55 base::android::ToJavaIntArray(env, content_settings_types).obj()); | 63 base::android::ToJavaIntArray(env, content_settings_types).obj()); |
56 } | 64 } |
57 | 65 |
| 66 void GroupedPermissionInfoBar::SetJavaInfoBar( |
| 67 const base::android::JavaRef<jobject>& java_info_bar) { |
| 68 InfoBarAndroid::SetJavaInfoBar(java_info_bar); |
| 69 JNIEnv* env = base::android::AttachCurrentThread(); |
| 70 Java_GroupedPermissionInfoBar_setNativePtr(env, java_info_bar.obj(), |
| 71 reinterpret_cast<intptr_t>(this)); |
| 72 } |
| 73 |
58 GroupedPermissionInfoBarDelegate* GroupedPermissionInfoBar::GetDelegate() { | 74 GroupedPermissionInfoBarDelegate* GroupedPermissionInfoBar::GetDelegate() { |
59 return static_cast<GroupedPermissionInfoBarDelegate*>(delegate()); | 75 return static_cast<GroupedPermissionInfoBarDelegate*>(delegate()); |
60 } | 76 } |
61 | 77 |
62 std::unique_ptr<infobars::InfoBar> | 78 std::unique_ptr<infobars::InfoBar> |
63 GroupedPermissionInfoBarDelegate::CreateInfoBar( | 79 GroupedPermissionInfoBarDelegate::CreateInfoBar( |
64 infobars::InfoBarManager* infobar_manager, | 80 infobars::InfoBarManager* infobar_manager, |
65 std::unique_ptr<GroupedPermissionInfoBarDelegate> delegate) { | 81 std::unique_ptr<GroupedPermissionInfoBarDelegate> delegate) { |
66 return std::unique_ptr<infobars::InfoBar>( | 82 return std::unique_ptr<infobars::InfoBar>( |
67 new GroupedPermissionInfoBar(std::move(delegate))); | 83 new GroupedPermissionInfoBar(std::move(delegate))); |
68 } | 84 } |
OLD | NEW |