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