Index: chrome/browser/ui/android/autofill/autofill_popup_view_android.cc |
diff --git a/chrome/browser/ui/android/autofill/autofill_popup_view_android.cc b/chrome/browser/ui/android/autofill/autofill_popup_view_android.cc |
index 02bcfdd2e062c0277b689fa8b3208d63253c2f8d..0b976a96ab1b92cf7ee0d6e08c457e2cfdc023ef 100644 |
--- a/chrome/browser/ui/android/autofill/autofill_popup_view_android.cc |
+++ b/chrome/browser/ui/android/autofill/autofill_popup_view_android.cc |
@@ -36,11 +36,14 @@ void AutofillPopupViewAndroid::Show() { |
ui::ViewAndroid* view_android = controller_->container_view(); |
DCHECK(view_android); |
+ popup_view_ = view_android->AcquireAnchorView(); |
+ if (popup_view_.is_null()) |
+ return; |
java_object_.Reset(Java_AutofillPopupBridge_create( |
- env, reinterpret_cast<intptr_t>(this), |
- view_android->GetWindowAndroid()->GetJavaObject().obj(), |
- view_android->GetViewAndroidDelegate().obj())); |
+ env, popup_view_.view(env).obj(), controller_->element_bounds().width(), |
+ reinterpret_cast<intptr_t>(this), |
+ view_android->GetWindowAndroid()->GetJavaObject().obj())); |
UpdateBoundsAndRedrawPopup(); |
} |
@@ -48,18 +51,24 @@ void AutofillPopupViewAndroid::Show() { |
void AutofillPopupViewAndroid::Hide() { |
controller_ = NULL; |
JNIEnv* env = base::android::AttachCurrentThread(); |
- Java_AutofillPopupBridge_dismiss(env, java_object_.obj()); |
+ if (!java_object_.is_null()) { |
+ Java_AutofillPopupBridge_dismiss(env, java_object_.obj()); |
+ } else { |
+ // Hide() should delete |this| either via Java dismiss or directly. |
+ delete this; |
+ } |
} |
void AutofillPopupViewAndroid::UpdateBoundsAndRedrawPopup() { |
+ if (java_object_.is_null() || popup_view_.is_null()) |
Ted C
2016/07/27 20:10:47
we are only null checking popup_view here because
Jinsuk Kim
2016/07/29 06:09:13
That's correct. Added the null checking in defensi
|
+ return; |
+ |
+ ui::ViewAndroid* view_android = controller_->container_view(); |
+ |
+ DCHECK(view_android); |
JNIEnv* env = base::android::AttachCurrentThread(); |
- Java_AutofillPopupBridge_setAnchorRect( |
- env, |
- java_object_.obj(), |
- controller_->element_bounds().x(), |
- controller_->element_bounds().y(), |
- controller_->element_bounds().width(), |
- controller_->element_bounds().height()); |
+ view_android->SetAnchorRect(popup_view_.view(env), |
boliu
2016/07/27 16:20:26
need null check
Ted C
2016/07/27 20:10:47
for view_android right? popup_view_ is null check
Jinsuk Kim
2016/07/29 06:09:13
Oh what Bo means by that is I need to change the w
|
+ controller_->element_bounds()); |
size_t count = controller_->GetLineCount(); |
ScopedJavaLocalRef<jobjectArray> data_array = |
@@ -106,7 +115,7 @@ void AutofillPopupViewAndroid::DeletionRequested( |
JNIEnv* env, |
const JavaParamRef<jobject>& obj, |
jint list_index) { |
- if (!controller_) |
+ if (!controller_ || java_object_.is_null()) |
return; |
base::string16 confirmation_title, confirmation_body; |