| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ui/android/infobars/confirm_infobar.h" | 5 #include "chrome/browser/ui/android/infobars/confirm_infobar.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 content::ContentViewCore::FromWebContents(web_contents); | 69 content::ContentViewCore::FromWebContents(web_contents); |
| 70 DCHECK(cvc); | 70 DCHECK(cvc); |
| 71 return cvc->GetWindowAndroid()->GetJavaObject(); | 71 return cvc->GetWindowAndroid()->GetJavaObject(); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void ConfirmInfoBar::OnLinkClicked(JNIEnv* env, | 74 void ConfirmInfoBar::OnLinkClicked(JNIEnv* env, |
| 75 const JavaParamRef<jobject>& obj) { | 75 const JavaParamRef<jobject>& obj) { |
| 76 if (!owner()) | 76 if (!owner()) |
| 77 return; // We're closing; don't call anything, it might access the owner. | 77 return; // We're closing; don't call anything, it might access the owner. |
| 78 | 78 |
| 79 if (GetDelegate()->LinkClicked(NEW_FOREGROUND_TAB)) | 79 if (GetDelegate()->LinkClicked(WindowOpenDisposition::NEW_FOREGROUND_TAB)) |
| 80 RemoveSelf(); | 80 RemoveSelf(); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void ConfirmInfoBar::ProcessButton(int action) { | 83 void ConfirmInfoBar::ProcessButton(int action) { |
| 84 if (!owner()) | 84 if (!owner()) |
| 85 return; // We're closing; don't call anything, it might access the owner. | 85 return; // We're closing; don't call anything, it might access the owner. |
| 86 | 86 |
| 87 DCHECK((action == InfoBarAndroid::ACTION_OK) || | 87 DCHECK((action == InfoBarAndroid::ACTION_OK) || |
| 88 (action == InfoBarAndroid::ACTION_CANCEL)); | 88 (action == InfoBarAndroid::ACTION_CANCEL)); |
| 89 ConfirmInfoBarDelegate* delegate = GetDelegate(); | 89 ConfirmInfoBarDelegate* delegate = GetDelegate(); |
| 90 if ((action == InfoBarAndroid::ACTION_OK) ? | 90 if ((action == InfoBarAndroid::ACTION_OK) ? |
| 91 delegate->Accept() : delegate->Cancel()) | 91 delegate->Accept() : delegate->Cancel()) |
| 92 RemoveSelf(); | 92 RemoveSelf(); |
| 93 } | 93 } |
| 94 | 94 |
| 95 ConfirmInfoBarDelegate* ConfirmInfoBar::GetDelegate() { | 95 ConfirmInfoBarDelegate* ConfirmInfoBar::GetDelegate() { |
| 96 return delegate()->AsConfirmInfoBarDelegate(); | 96 return delegate()->AsConfirmInfoBarDelegate(); |
| 97 } | 97 } |
| 98 | 98 |
| 99 base::string16 ConfirmInfoBar::GetTextFor( | 99 base::string16 ConfirmInfoBar::GetTextFor( |
| 100 ConfirmInfoBarDelegate::InfoBarButton button) { | 100 ConfirmInfoBarDelegate::InfoBarButton button) { |
| 101 ConfirmInfoBarDelegate* delegate = GetDelegate(); | 101 ConfirmInfoBarDelegate* delegate = GetDelegate(); |
| 102 return (delegate->GetButtons() & button) ? | 102 return (delegate->GetButtons() & button) ? |
| 103 delegate->GetButtonLabel(button) : base::string16(); | 103 delegate->GetButtonLabel(button) : base::string16(); |
| 104 } | 104 } |
| OLD | NEW |