Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 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 #include "chrome/browser/ui/android/infobars/permission_group_infobar_android.h" | |
| 6 | |
| 7 #include "base/android/jni_android.h" | |
| 8 #include "base/android/jni_array.h" | |
| 9 #include "base/android/jni_string.h" | |
| 10 #include "base/android/scoped_java_ref.h" | |
| 11 #include "chrome/browser/android/permissions/permission_group_infobar_delegate_a ndroid.h" | |
| 12 #include "chrome/browser/infobars/infobar_service.h" | |
| 13 #include "content/public/browser/android/content_view_core.h" | |
| 14 #include "content/public/browser/web_contents.h" | |
| 15 #include "jni/PermissionGroupInfoBarAndroid_jni.h" | |
| 16 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | |
|
gone
2015/09/25 10:34:43
get rid of the ones you don't use
Lalit Maganti
2015/09/25 13:09:24
Done.
| |
| 17 #include "ui/android/window_android.h" | |
| 18 #include "ui/gfx/android/java_bitmap.h" | |
| 19 #include "ui/gfx/image/image.h" | |
| 20 | |
| 21 PermissionGroupInfoBarAndroid::PermissionGroupInfoBarAndroid( | |
| 22 scoped_ptr<PermissionGroupInfoBarDelegateAndroid> delegate, | |
| 23 std::vector<int> permission_types) | |
| 24 : ConfirmInfoBar(delegate.Pass()), | |
| 25 permission_types_(permission_types) { | |
| 26 } | |
| 27 | |
| 28 PermissionGroupInfoBarAndroid::~PermissionGroupInfoBarAndroid() { | |
| 29 if (java_infobar_.is_null()) | |
| 30 return; | |
| 31 | |
| 32 JNIEnv* env = base::android::AttachCurrentThread(); | |
| 33 Java_PermissionGroupInfoBarAndroid_onNativeDestroyed( | |
| 34 env, java_infobar_.obj()); | |
| 35 java_infobar_.Reset(); | |
| 36 } | |
| 37 | |
| 38 PermissionGroupInfoBarDelegateAndroid* | |
| 39 PermissionGroupInfoBarAndroid::GetDelegate() { | |
| 40 return static_cast<PermissionGroupInfoBarDelegateAndroid*>(delegate()); | |
| 41 } | |
| 42 | |
| 43 void PermissionGroupInfoBarAndroid::OnCheckedStateUpdate( | |
| 44 JNIEnv* env, | |
| 45 jobject obj, | |
| 46 jbooleanArray raw_checked_states) { | |
| 47 jint array_size = env->GetArrayLength(raw_checked_states); | |
| 48 jboolean* states_ptr = env->GetBooleanArrayElements( | |
| 49 raw_checked_states, NULL); | |
| 50 | |
| 51 GetDelegate()->OnCheckedStateUpdate(states_ptr, array_size); | |
| 52 } | |
| 53 | |
| 54 base::android::ScopedJavaLocalRef<jobject> | |
| 55 PermissionGroupInfoBarAndroid::CreateRenderInfoBar(JNIEnv* env) { | |
| 56 content::WebContents* web_contents = | |
| 57 InfoBarService::WebContentsFromInfoBar(this); | |
| 58 DCHECK(web_contents); | |
| 59 content::ContentViewCore* cvc = | |
| 60 content::ContentViewCore::FromWebContents(web_contents); | |
| 61 DCHECK(cvc); | |
| 62 | |
| 63 base::android::ScopedJavaLocalRef<jobject> jwindow_android = | |
| 64 cvc->GetWindowAndroid()->GetJavaObject(); | |
| 65 base::android::ScopedJavaLocalRef<jstring> title_message = | |
| 66 base::android::ConvertUTF16ToJavaString( | |
| 67 env, GetDelegate()->GetMessageText()); | |
| 68 base::android::ScopedJavaLocalRef<jintArray> jtypes = | |
| 69 base::android::ToJavaIntArray(env, permission_types_); | |
| 70 | |
| 71 base::android::ScopedJavaLocalRef<jobject> infobar; | |
| 72 infobar.Reset(Java_PermissionGroupInfoBarAndroid_createInfoBar(env, | |
| 73 reinterpret_cast<intptr_t>(this), | |
| 74 jwindow_android.obj(), | |
| 75 title_message.obj(), | |
| 76 jtypes.obj())); | |
| 77 java_infobar_.Reset(env, infobar.obj()); | |
| 78 return infobar; | |
| 79 } | |
| 80 | |
| 81 // Native JNI methods --------------------------------------------------------- | |
| 82 | |
| 83 bool RegisterPermissionGroupInfoBarAndroid(JNIEnv* env) { | |
| 84 return RegisterNativesImpl(env); | |
| 85 } | |
| OLD | NEW |