Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: chrome/browser/ui/android/infobars/permission_group_infobar_android.cc

Issue 1332063003: permissions: implement coalesced permissions on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@request-multiple
Patch Set: Bring CL up to scratch with mocks Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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"
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_destroy(env, java_infobar_.obj());
34 java_infobar_.Reset();
35 }
36
37 PermissionGroupInfoBarDelegateAndroid*
38 PermissionGroupInfoBarAndroid::GetDelegate() {
39 return static_cast<PermissionGroupInfoBarDelegateAndroid*>(delegate());
40 }
41
42 void PermissionGroupInfoBarAndroid::OnCheckedStateUpdate(
43 JNIEnv* env,
44 jobject obj,
45 jbooleanArray raw_checked_states) {
46 jint array_size = env->GetArrayLength(raw_checked_states);
47 jboolean* states_ptr = env->GetBooleanArrayElements(
48 raw_checked_states, NULL);
49
50 GetDelegate()->OnCheckedStateUpdate(states_ptr, array_size);
51 }
52
53 base::android::ScopedJavaLocalRef<jobject>
54 PermissionGroupInfoBarAndroid::CreateRenderInfoBar(JNIEnv* env) {
55 content::WebContents* web_contents =
56 InfoBarService::WebContentsFromInfoBar(this);
57 DCHECK(web_contents);
58 content::ContentViewCore* cvc =
59 content::ContentViewCore::FromWebContents(web_contents);
60 DCHECK(cvc);
61
62 base::android::ScopedJavaLocalRef<jobject> jwindow_android =
63 cvc->GetWindowAndroid()->GetJavaObject();
64 base::android::ScopedJavaLocalRef<jstring> title_message =
65 base::android::ConvertUTF16ToJavaString(
66 env, GetDelegate()->GetMessageText());
67 base::android::ScopedJavaLocalRef<jintArray> jtypes =
68 base::android::ToJavaIntArray(env, permission_types_);
69
70 base::android::ScopedJavaLocalRef<jobject> infobar;
71 infobar.Reset(Java_PermissionGroupInfoBarAndroid_createInfoBar(env,
72 reinterpret_cast<intptr_t>(this),
73 jwindow_android.obj(),
74 title_message.obj(),
75 jtypes.obj()));
76 java_infobar_.Reset(env, infobar.obj());
77 return infobar;
78 }
79
80 // Native JNI methods ---------------------------------------------------------
81
82 bool RegisterPermissionGroupInfoBarAndroid(JNIEnv* env) {
83 return RegisterNativesImpl(env);
84 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698