Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(924)

Side by Side Diff: chrome/browser/ui/android/infobars/simple_confirm_infobar_builder.cc

Issue 2019533002: [Android] Fix crash when closing tab during infobar cancellation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test on mobile Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 return (primary_str_.empty() ? 0 : BUTTON_OK) | 107 return (primary_str_.empty() ? 0 : BUTTON_OK) |
108 (secondary_str_.empty() ? 0 : BUTTON_CANCEL); 108 (secondary_str_.empty() ? 0 : BUTTON_CANCEL);
109 } 109 }
110 110
111 base::string16 111 base::string16
112 SimpleConfirmInfoBarDelegate::GetButtonLabel(InfoBarButton button) const { 112 SimpleConfirmInfoBarDelegate::GetButtonLabel(InfoBarButton button) const {
113 return button == BUTTON_OK ? primary_str_ : secondary_str_; 113 return button == BUTTON_OK ? primary_str_ : secondary_str_;
114 } 114 }
115 115
116 bool SimpleConfirmInfoBarDelegate::Accept() { 116 bool SimpleConfirmInfoBarDelegate::Accept() {
117 Java_SimpleConfirmInfoBarBuilder_onInfoBarButtonClicked( 117 return !Java_SimpleConfirmInfoBarBuilder_onInfoBarButtonClicked(
118 base::android::AttachCurrentThread(), java_listener_.obj(), true); 118 base::android::AttachCurrentThread(), java_listener_.obj(), true);
119 return true;
120 } 119 }
121 120
122 bool SimpleConfirmInfoBarDelegate::Cancel() { 121 bool SimpleConfirmInfoBarDelegate::Cancel() {
123 Java_SimpleConfirmInfoBarBuilder_onInfoBarButtonClicked( 122 return !Java_SimpleConfirmInfoBarBuilder_onInfoBarButtonClicked(
124 base::android::AttachCurrentThread(), java_listener_.obj(), false); 123 base::android::AttachCurrentThread(), java_listener_.obj(), false);
125 return true;
126 } 124 }
127 125
128 } // anonymous namespace 126 } // anonymous namespace
129 127
130 // Native JNI methods --------------------------------------------------------- 128 // Native JNI methods ---------------------------------------------------------
131 129
132 void Create(JNIEnv* env, 130 void Create(JNIEnv* env,
133 const JavaParamRef<jclass>& j_caller, 131 const JavaParamRef<jclass>& j_caller,
134 const JavaParamRef<jobject>& j_tab, 132 const JavaParamRef<jobject>& j_tab,
135 jint j_identifier, 133 jint j_identifier,
(...skipping 26 matching lines...) Expand all
162 TabAndroid::GetNativeTab(env, j_tab)->web_contents()); 160 TabAndroid::GetNativeTab(env, j_tab)->web_contents());
163 service->AddInfoBar(service->CreateConfirmInfoBar( 161 service->AddInfoBar(service->CreateConfirmInfoBar(
164 base::WrapUnique(new SimpleConfirmInfoBarDelegate( 162 base::WrapUnique(new SimpleConfirmInfoBarDelegate(
165 j_listener, infobar_identifier, icon_bitmap, message_str, primary_str, 163 j_listener, infobar_identifier, icon_bitmap, message_str, primary_str,
166 secondary_str, auto_expire)))); 164 secondary_str, auto_expire))));
167 } 165 }
168 166
169 bool RegisterSimpleConfirmInfoBarBuilder(JNIEnv* env) { 167 bool RegisterSimpleConfirmInfoBarBuilder(JNIEnv* env) {
170 return RegisterNativesImpl(env); 168 return RegisterNativesImpl(env);
171 } 169 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698