| 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_array.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 permission_prompt_->GetContentSettingType(0)}; | 155 permission_prompt_->GetContentSettingType(0)}; |
| 156 | 156 |
| 157 j_delegate_.Reset(Java_PermissionDialogDelegate_create( | 157 j_delegate_.Reset(Java_PermissionDialogDelegate_create( |
| 158 env, reinterpret_cast<uintptr_t>(this), tab_->GetJavaObject(), | 158 env, reinterpret_cast<uintptr_t>(this), tab_->GetJavaObject(), |
| 159 base::android::ToJavaIntArray(env, content_settings_types).obj(), | 159 base::android::ToJavaIntArray(env, content_settings_types).obj(), |
| 160 ResourceMapper::MapFromChromiumId( | 160 ResourceMapper::MapFromChromiumId( |
| 161 permission_prompt_->GetIconIdForPermission(0)), | 161 permission_prompt_->GetIconIdForPermission(0)), |
| 162 ConvertUTF16ToJavaString(env, permission_prompt_->GetMessageText(0)), | 162 ConvertUTF16ToJavaString(env, permission_prompt_->GetMessageText(0)), |
| 163 // TODO(timloh): Pass the actual link text for EME. | 163 // TODO(timloh): Pass the actual link text for EME. |
| 164 ConvertUTF16ToJavaString(env, base::string16()), primaryButtonText, | 164 ConvertUTF16ToJavaString(env, base::string16()), primaryButtonText, |
| 165 secondaryButtonText, | 165 secondaryButtonText, permission_prompt_->ShouldShowPersistenceToggle())); |
| 166 // TODO(timloh): Hook up the persistence toggle. | |
| 167 false)); | |
| 168 } | 166 } |
| 169 | 167 |
| 170 void PermissionDialogDelegate::Accept(JNIEnv* env, | 168 void PermissionDialogDelegate::Accept(JNIEnv* env, |
| 171 const JavaParamRef<jobject>& obj, | 169 const JavaParamRef<jobject>& obj, |
| 172 jboolean persist) { | 170 jboolean persist) { |
| 173 if (infobar_delegate_) { | 171 if (infobar_delegate_) { |
| 174 if (infobar_delegate_->ShouldShowPersistenceToggle()) | 172 if (infobar_delegate_->ShouldShowPersistenceToggle()) |
| 175 infobar_delegate_->set_persist(persist); | 173 infobar_delegate_->set_persist(persist); |
| 176 infobar_delegate_->Accept(); | 174 infobar_delegate_->Accept(); |
| 177 return; | 175 return; |
| 178 } | 176 } |
| 179 | 177 |
| 178 if (permission_prompt_->ShouldShowPersistenceToggle()) |
| 179 permission_prompt_->TogglePersist(persist); |
| 180 permission_prompt_->Accept(); | 180 permission_prompt_->Accept(); |
| 181 } | 181 } |
| 182 | 182 |
| 183 void PermissionDialogDelegate::Cancel(JNIEnv* env, | 183 void PermissionDialogDelegate::Cancel(JNIEnv* env, |
| 184 const JavaParamRef<jobject>& obj, | 184 const JavaParamRef<jobject>& obj, |
| 185 jboolean persist) { | 185 jboolean persist) { |
| 186 if (infobar_delegate_) { | 186 if (infobar_delegate_) { |
| 187 if (infobar_delegate_->ShouldShowPersistenceToggle()) | 187 if (infobar_delegate_->ShouldShowPersistenceToggle()) |
| 188 infobar_delegate_->set_persist(persist); | 188 infobar_delegate_->set_persist(persist); |
| 189 infobar_delegate_->Cancel(); | 189 infobar_delegate_->Cancel(); |
| 190 return; | 190 return; |
| 191 } | 191 } |
| 192 | 192 |
| 193 if (permission_prompt_->ShouldShowPersistenceToggle()) |
| 194 permission_prompt_->TogglePersist(persist); |
| 193 permission_prompt_->Deny(); | 195 permission_prompt_->Deny(); |
| 194 } | 196 } |
| 195 | 197 |
| 196 void PermissionDialogDelegate::Dismissed(JNIEnv* env, | 198 void PermissionDialogDelegate::Dismissed(JNIEnv* env, |
| 197 const JavaParamRef<jobject>& obj) { | 199 const JavaParamRef<jobject>& obj) { |
| 198 if (infobar_delegate_) { | 200 if (infobar_delegate_) { |
| 199 infobar_delegate_->InfoBarDismissed(); | 201 infobar_delegate_->InfoBarDismissed(); |
| 200 return; | 202 return; |
| 201 } | 203 } |
| 202 | 204 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 navigation_handle->IsSameDocument()) { | 264 navigation_handle->IsSameDocument()) { |
| 263 return; | 265 return; |
| 264 } | 266 } |
| 265 | 267 |
| 266 DismissDialog(); | 268 DismissDialog(); |
| 267 } | 269 } |
| 268 | 270 |
| 269 void PermissionDialogDelegate::WebContentsDestroyed() { | 271 void PermissionDialogDelegate::WebContentsDestroyed() { |
| 270 DismissDialog(); | 272 DismissDialog(); |
| 271 } | 273 } |
| OLD | NEW |