Chromium Code Reviews| Index: chrome/browser/ui/android/autofill/password_generation_popup_view_android.cc |
| diff --git a/chrome/browser/ui/android/autofill/password_generation_popup_view_android.cc b/chrome/browser/ui/android/autofill/password_generation_popup_view_android.cc |
| index a0f48c64dd42dbb5412ee65323d26e9fada2def1..84c0a751090353cca04288f8fe7095fe8718a9e0 100644 |
| --- a/chrome/browser/ui/android/autofill/password_generation_popup_view_android.cc |
| +++ b/chrome/browser/ui/android/autofill/password_generation_popup_view_android.cc |
| @@ -35,9 +35,14 @@ void PasswordGenerationPopupViewAndroid::SavedPasswordsLinkClicked( |
| void PasswordGenerationPopupViewAndroid::Dismissed( |
| JNIEnv* env, |
| const JavaParamRef<jobject>& obj) { |
| - if (controller_) |
| - controller_->ViewDestroyed(); |
| + if (controller_) { |
|
no sievers
2016/07/14 23:14:31
We have to be careful not to leak the View (by lea
Jinsuk Kim
2016/07/15 05:46:26
Done.
|
| + ui::ViewAndroid* view_android = controller_->container_view(); |
| + DCHECK(view_android); |
| + view_android->RemoveAnchorView(popup_.obj()); |
| + |
| + controller_->ViewDestroyed(); |
| + } |
| delete this; |
| } |
| @@ -61,10 +66,11 @@ void PasswordGenerationPopupViewAndroid::Show() { |
| DCHECK(view_android); |
| + popup_.Reset(view_android->AcquireAnchorView()); |
| java_object_.Reset(Java_PasswordGenerationPopupBridge_create( |
| - env, reinterpret_cast<intptr_t>(this), |
| - view_android->GetWindowAndroid()->GetJavaObject().obj(), |
| - view_android->GetViewAndroidDelegate().obj())); |
| + env, popup_.obj(), controller_->element_bounds().width(), |
| + reinterpret_cast<intptr_t>(this), |
| + view_android->GetWindowAndroid()->GetJavaObject().obj())); |
| UpdateBoundsAndRedrawPopup(); |
| } |
| @@ -82,14 +88,10 @@ gfx::Size PasswordGenerationPopupViewAndroid::GetPreferredSizeOfPasswordView() { |
| void PasswordGenerationPopupViewAndroid::UpdateBoundsAndRedrawPopup() { |
| JNIEnv* env = base::android::AttachCurrentThread(); |
| - Java_PasswordGenerationPopupBridge_setAnchorRect( |
| - env, |
| - java_object_.obj(), |
| - controller_->element_bounds().x(), |
| - controller_->element_bounds().y(), |
| - controller_->element_bounds().width(), |
| - controller_->element_bounds().height()); |
| + ui::ViewAndroid* view_android = controller_->container_view(); |
| + DCHECK(view_android); |
| + view_android->SetAnchorRect(popup_.obj(), controller_->element_bounds()); |
| ScopedJavaLocalRef<jstring> password = |
| base::android::ConvertUTF16ToJavaString(env, controller_->password()); |
| ScopedJavaLocalRef<jstring> suggestion = |