| 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/ui/android/infobars/simple_confirm_infobar_builder.h" | 5 #include "chrome/browser/ui/android/infobars/simple_confirm_infobar_builder.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 : icon_bitmap_; | 91 : icon_bitmap_; |
| 92 } | 92 } |
| 93 | 93 |
| 94 bool SimpleConfirmInfoBarDelegate::ShouldExpire( | 94 bool SimpleConfirmInfoBarDelegate::ShouldExpire( |
| 95 const NavigationDetails& details) const { | 95 const NavigationDetails& details) const { |
| 96 return auto_expire_ && ConfirmInfoBarDelegate::ShouldExpire(details); | 96 return auto_expire_ && ConfirmInfoBarDelegate::ShouldExpire(details); |
| 97 } | 97 } |
| 98 | 98 |
| 99 void SimpleConfirmInfoBarDelegate::InfoBarDismissed() { | 99 void SimpleConfirmInfoBarDelegate::InfoBarDismissed() { |
| 100 Java_SimpleConfirmInfoBarBuilder_onInfoBarDismissed( | 100 Java_SimpleConfirmInfoBarBuilder_onInfoBarDismissed( |
| 101 base::android::AttachCurrentThread(), java_listener_.obj()); | 101 base::android::AttachCurrentThread(), java_listener_); |
| 102 } | 102 } |
| 103 | 103 |
| 104 base::string16 SimpleConfirmInfoBarDelegate::GetMessageText() const { | 104 base::string16 SimpleConfirmInfoBarDelegate::GetMessageText() const { |
| 105 return message_str_; | 105 return message_str_; |
| 106 } | 106 } |
| 107 | 107 |
| 108 int SimpleConfirmInfoBarDelegate::GetButtons() const { | 108 int SimpleConfirmInfoBarDelegate::GetButtons() const { |
| 109 return (primary_str_.empty() ? 0 : BUTTON_OK) | | 109 return (primary_str_.empty() ? 0 : BUTTON_OK) | |
| 110 (secondary_str_.empty() ? 0 : BUTTON_CANCEL); | 110 (secondary_str_.empty() ? 0 : BUTTON_CANCEL); |
| 111 } | 111 } |
| 112 | 112 |
| 113 base::string16 | 113 base::string16 |
| 114 SimpleConfirmInfoBarDelegate::GetButtonLabel(InfoBarButton button) const { | 114 SimpleConfirmInfoBarDelegate::GetButtonLabel(InfoBarButton button) const { |
| 115 return button == BUTTON_OK ? primary_str_ : secondary_str_; | 115 return button == BUTTON_OK ? primary_str_ : secondary_str_; |
| 116 } | 116 } |
| 117 | 117 |
| 118 bool SimpleConfirmInfoBarDelegate::Accept() { | 118 bool SimpleConfirmInfoBarDelegate::Accept() { |
| 119 return !Java_SimpleConfirmInfoBarBuilder_onInfoBarButtonClicked( | 119 return !Java_SimpleConfirmInfoBarBuilder_onInfoBarButtonClicked( |
| 120 base::android::AttachCurrentThread(), java_listener_.obj(), true); | 120 base::android::AttachCurrentThread(), java_listener_, true); |
| 121 } | 121 } |
| 122 | 122 |
| 123 bool SimpleConfirmInfoBarDelegate::Cancel() { | 123 bool SimpleConfirmInfoBarDelegate::Cancel() { |
| 124 return !Java_SimpleConfirmInfoBarBuilder_onInfoBarButtonClicked( | 124 return !Java_SimpleConfirmInfoBarBuilder_onInfoBarButtonClicked( |
| 125 base::android::AttachCurrentThread(), java_listener_.obj(), false); | 125 base::android::AttachCurrentThread(), java_listener_, false); |
| 126 } | 126 } |
| 127 | 127 |
| 128 } // anonymous namespace | 128 } // anonymous namespace |
| 129 | 129 |
| 130 // Native JNI methods --------------------------------------------------------- | 130 // Native JNI methods --------------------------------------------------------- |
| 131 | 131 |
| 132 void Create(JNIEnv* env, | 132 void Create(JNIEnv* env, |
| 133 const JavaParamRef<jclass>& j_caller, | 133 const JavaParamRef<jclass>& j_caller, |
| 134 const JavaParamRef<jobject>& j_tab, | 134 const JavaParamRef<jobject>& j_tab, |
| 135 jint j_identifier, | 135 jint j_identifier, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 162 TabAndroid::GetNativeTab(env, j_tab)->web_contents()); | 162 TabAndroid::GetNativeTab(env, j_tab)->web_contents()); |
| 163 service->AddInfoBar(service->CreateConfirmInfoBar( | 163 service->AddInfoBar(service->CreateConfirmInfoBar( |
| 164 base::WrapUnique(new SimpleConfirmInfoBarDelegate( | 164 base::WrapUnique(new SimpleConfirmInfoBarDelegate( |
| 165 j_listener, infobar_identifier, icon_bitmap, message_str, primary_str, | 165 j_listener, infobar_identifier, icon_bitmap, message_str, primary_str, |
| 166 secondary_str, auto_expire)))); | 166 secondary_str, auto_expire)))); |
| 167 } | 167 } |
| 168 | 168 |
| 169 bool RegisterSimpleConfirmInfoBarBuilder(JNIEnv* env) { | 169 bool RegisterSimpleConfirmInfoBarBuilder(JNIEnv* env) { |
| 170 return RegisterNativesImpl(env); | 170 return RegisterNativesImpl(env); |
| 171 } | 171 } |
| OLD | NEW |