| 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 | 153 |
| 154 std::vector<int> content_settings_types{ | 154 std::vector<int> content_settings_types{ |
| 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 ConvertUTF16ToJavaString(env, permission_prompt_->GetLinkText()), |
| 164 ConvertUTF16ToJavaString(env, base::string16()), primaryButtonText, | 164 primaryButtonText, secondaryButtonText, |
| 165 secondaryButtonText, permission_prompt_->ShouldShowPersistenceToggle())); | 165 permission_prompt_->ShouldShowPersistenceToggle())); |
| 166 } | 166 } |
| 167 | 167 |
| 168 void PermissionDialogDelegate::Accept(JNIEnv* env, | 168 void PermissionDialogDelegate::Accept(JNIEnv* env, |
| 169 const JavaParamRef<jobject>& obj, | 169 const JavaParamRef<jobject>& obj, |
| 170 jboolean persist) { | 170 jboolean persist) { |
| 171 if (infobar_delegate_) { | 171 if (infobar_delegate_) { |
| 172 if (infobar_delegate_->ShouldShowPersistenceToggle()) | 172 if (infobar_delegate_->ShouldShowPersistenceToggle()) |
| 173 infobar_delegate_->set_persist(persist); | 173 infobar_delegate_->set_persist(persist); |
| 174 infobar_delegate_->Accept(); | 174 infobar_delegate_->Accept(); |
| 175 return; | 175 return; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 204 | 204 |
| 205 permission_prompt_->Closing(); | 205 permission_prompt_->Closing(); |
| 206 } | 206 } |
| 207 | 207 |
| 208 void PermissionDialogDelegate::LinkClicked(JNIEnv* env, | 208 void PermissionDialogDelegate::LinkClicked(JNIEnv* env, |
| 209 const JavaParamRef<jobject>& obj) { | 209 const JavaParamRef<jobject>& obj) { |
| 210 // Don't call delegate_->LinkClicked() because that relies on having an | 210 // Don't call delegate_->LinkClicked() because that relies on having an |
| 211 // InfoBarService as an owner() to open the link. That will fail since the | 211 // InfoBarService as an owner() to open the link. That will fail since the |
| 212 // wrapped delegate has no owner (it hasn't been added as an infobar). | 212 // wrapped delegate has no owner (it hasn't been added as an infobar). |
| 213 if (tab_->web_contents()) { | 213 if (tab_->web_contents()) { |
| 214 if (infobar_delegate_) { | 214 GURL linkURL = infobar_delegate_ ? infobar_delegate_->GetLinkURL() |
| 215 tab_->web_contents()->OpenURL(content::OpenURLParams( | 215 : permission_prompt_->GetLinkURL(); |
| 216 infobar_delegate_->GetLinkURL(), content::Referrer(), | 216 tab_->web_contents()->OpenURL(content::OpenURLParams( |
| 217 WindowOpenDisposition::NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK, | 217 linkURL, content::Referrer(), WindowOpenDisposition::NEW_FOREGROUND_TAB, |
| 218 false)); | 218 ui::PAGE_TRANSITION_LINK, false)); |
| 219 } | |
| 220 // TODO(timloh): Show a 'learn more' link in the PermissionRequestManager | |
| 221 // codepath for EME. | |
| 222 } | 219 } |
| 223 } | 220 } |
| 224 | 221 |
| 225 void PermissionDialogDelegate::Destroy(JNIEnv* env, | 222 void PermissionDialogDelegate::Destroy(JNIEnv* env, |
| 226 const JavaParamRef<jobject>& obj) { | 223 const JavaParamRef<jobject>& obj) { |
| 227 delete this; | 224 delete this; |
| 228 } | 225 } |
| 229 | 226 |
| 230 PermissionDialogDelegate::PermissionDialogDelegate( | 227 PermissionDialogDelegate::PermissionDialogDelegate( |
| 231 TabAndroid* tab, | 228 TabAndroid* tab, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 navigation_handle->IsSameDocument()) { | 261 navigation_handle->IsSameDocument()) { |
| 265 return; | 262 return; |
| 266 } | 263 } |
| 267 | 264 |
| 268 DismissDialog(); | 265 DismissDialog(); |
| 269 } | 266 } |
| 270 | 267 |
| 271 void PermissionDialogDelegate::WebContentsDestroyed() { | 268 void PermissionDialogDelegate::WebContentsDestroyed() { |
| 272 DismissDialog(); | 269 DismissDialog(); |
| 273 } | 270 } |
| OLD | NEW |