| 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/permissions/permission_dialog_delegate.h" | 5 #include "chrome/browser/permissions/permission_dialog_delegate.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_array.h" |
| 10 #include "base/android/jni_string.h" | 11 #include "base/android/jni_string.h" |
| 11 #include "base/feature_list.h" | 12 #include "base/feature_list.h" |
| 12 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 13 #include "chrome/browser/android/resource_mapper.h" | 14 #include "chrome/browser/android/resource_mapper.h" |
| 15 #include "chrome/browser/android/tab_android.h" |
| 14 #include "chrome/browser/geolocation/geolocation_infobar_delegate_android.h" | 16 #include "chrome/browser/geolocation/geolocation_infobar_delegate_android.h" |
| 15 #include "chrome/browser/media/midi_permission_infobar_delegate_android.h" | 17 #include "chrome/browser/media/midi_permission_infobar_delegate_android.h" |
| 16 #include "chrome/browser/media/protected_media_identifier_infobar_delegate_andro
id.h" | 18 #include "chrome/browser/media/protected_media_identifier_infobar_delegate_andro
id.h" |
| 17 #include "chrome/browser/media/webrtc/media_stream_devices_controller.h" | 19 #include "chrome/browser/media/webrtc/media_stream_devices_controller.h" |
| 18 #include "chrome/browser/media/webrtc/media_stream_infobar_delegate_android.h" | 20 #include "chrome/browser/media/webrtc/media_stream_infobar_delegate_android.h" |
| 19 #include "chrome/browser/notifications/notification_permission_infobar_delegate.
h" | 21 #include "chrome/browser/notifications/notification_permission_infobar_delegate.
h" |
| 20 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/common/chrome_features.h" | 23 #include "chrome/common/chrome_features.h" |
| 22 #include "components/variations/variations_associated_data.h" | 24 #include "components/variations/variations_associated_data.h" |
| 23 #include "content/public/browser/android/content_view_core.h" | |
| 24 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
| 25 #include "jni/PermissionDialogController_jni.h" | 26 #include "jni/PermissionDialogController_jni.h" |
| 26 #include "jni/PermissionDialogDelegate_jni.h" | 27 #include "jni/PermissionDialogDelegate_jni.h" |
| 27 #include "ui/android/window_android.h" | 28 #include "ui/android/window_android.h" |
| 28 #include "ui/base/window_open_disposition.h" | 29 #include "ui/base/window_open_disposition.h" |
| 29 | 30 |
| 30 using base::android::ConvertUTF16ToJavaString; | 31 using base::android::ConvertUTF16ToJavaString; |
| 31 | 32 |
| 32 namespace { | 33 namespace { |
| 33 | 34 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 return has_user_gesture; | 82 return has_user_gesture; |
| 82 } | 83 } |
| 83 | 84 |
| 84 // static | 85 // static |
| 85 bool PermissionDialogDelegate::RegisterPermissionDialogDelegate(JNIEnv* env) { | 86 bool PermissionDialogDelegate::RegisterPermissionDialogDelegate(JNIEnv* env) { |
| 86 return RegisterNativesImpl(env); | 87 return RegisterNativesImpl(env); |
| 87 } | 88 } |
| 88 | 89 |
| 89 ScopedJavaLocalRef<jobject> PermissionDialogDelegate::CreateJavaDelegate( | 90 ScopedJavaLocalRef<jobject> PermissionDialogDelegate::CreateJavaDelegate( |
| 90 JNIEnv* env) { | 91 JNIEnv* env) { |
| 91 content::ContentViewCore* cvc = | 92 TabAndroid* tab = TabAndroid::FromWebContents(web_contents()); |
| 92 content::ContentViewCore::FromWebContents(web_contents()); | 93 DCHECK(tab); |
| 93 DCHECK(cvc); | 94 |
| 95 std::vector<int> content_settings{infobar_delegate_->content_settings()}; |
| 94 | 96 |
| 95 return Java_PermissionDialogDelegate_create( | 97 return Java_PermissionDialogDelegate_create( |
| 96 env, reinterpret_cast<uintptr_t>(this), | 98 env, reinterpret_cast<uintptr_t>(this), |
| 97 cvc->GetWindowAndroid()->GetJavaObject(), | 99 tab->GetJavaObject(), |
| 100 base::android::ToJavaIntArray(env, content_settings).obj(), |
| 98 ResourceMapper::MapFromChromiumId(infobar_delegate_->GetIconId()), | 101 ResourceMapper::MapFromChromiumId(infobar_delegate_->GetIconId()), |
| 99 ConvertUTF16ToJavaString(env, infobar_delegate_->GetMessageText()), | 102 ConvertUTF16ToJavaString(env, infobar_delegate_->GetMessageText()), |
| 100 ConvertUTF16ToJavaString(env, infobar_delegate_->GetLinkText()), | 103 ConvertUTF16ToJavaString(env, infobar_delegate_->GetLinkText()), |
| 101 ConvertUTF16ToJavaString(env, infobar_delegate_->GetButtonLabel( | 104 ConvertUTF16ToJavaString(env, infobar_delegate_->GetButtonLabel( |
| 102 PermissionInfoBarDelegate::BUTTON_OK)), | 105 PermissionInfoBarDelegate::BUTTON_OK)), |
| 103 ConvertUTF16ToJavaString(env, | 106 ConvertUTF16ToJavaString(env, |
| 104 infobar_delegate_->GetButtonLabel( | 107 infobar_delegate_->GetButtonLabel( |
| 105 PermissionInfoBarDelegate::BUTTON_CANCEL)), | 108 PermissionInfoBarDelegate::BUTTON_CANCEL)), |
| 106 infobar_delegate_->ShouldShowPersistenceToggle()); | 109 infobar_delegate_->ShouldShowPersistenceToggle()); |
| 107 } | 110 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 base::android::ScopedJavaLocalRef<jobject> j_delegate = | 160 base::android::ScopedJavaLocalRef<jobject> j_delegate = |
| 158 CreateJavaDelegate(env); | 161 CreateJavaDelegate(env); |
| 159 | 162 |
| 160 // Send the Java delegate to the Java PermissionDialogController for display. | 163 // Send the Java delegate to the Java PermissionDialogController for display. |
| 161 // The controller takes over lifetime management; when the Java delegate is no | 164 // The controller takes over lifetime management; when the Java delegate is no |
| 162 // longer needed it will in turn free the native delegate. | 165 // longer needed it will in turn free the native delegate. |
| 163 Java_PermissionDialogController_createDialog(env, j_delegate.obj()); | 166 Java_PermissionDialogController_createDialog(env, j_delegate.obj()); |
| 164 } | 167 } |
| 165 | 168 |
| 166 PermissionDialogDelegate::~PermissionDialogDelegate() {} | 169 PermissionDialogDelegate::~PermissionDialogDelegate() {} |
| OLD | NEW |