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

Unified Diff: chrome/browser/ui/android/autofill/autofill_popup_view_android.cc

Issue 2103243002: Factor out ContentViewAndroidDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
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 663bd8b4192cd476f878eb1a6532e5e2d65692fb..82a56a02ead7d2985ba2b09c1b8eaf26d5f19b46 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().obj(), controller_->element_bounds().width(),
+ reinterpret_cast<intptr_t>(this),
+ view_android->GetWindowAndroid()->GetJavaObject().obj()));
UpdateBoundsAndRedrawPopup();
}
@@ -48,19 +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 {
+ PopupDismissedInternal();
no sievers 2016/07/20 18:46:04 Yes, good catch to not leak |this| here. But now
Jinsuk Kim 2016/07/20 23:19:03 Acknowledged. Called |delete this| directly and ad
+ }
}
void AutofillPopupViewAndroid::UpdateBoundsAndRedrawPopup() {
- 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());
+ if (java_object_.is_null() || popup_view_.is_null())
+ return;
+
+ ui::ViewAndroid* view_android = controller_->container_view();
+
+ DCHECK(view_android);
+ view_android->SetAnchorRect(popup_view_.view(),
+ controller_->element_bounds());
+ JNIEnv* env = base::android::AttachCurrentThread();
size_t count = controller_->GetLineCount();
ScopedJavaLocalRef<jobjectArray> data_array =
Java_AutofillPopupBridge_createAutofillSuggestionArray(env, count);
@@ -105,7 +113,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;
@@ -137,6 +145,10 @@ void AutofillPopupViewAndroid::DeletionConfirmed(
void AutofillPopupViewAndroid::PopupDismissed(
JNIEnv* env,
const JavaParamRef<jobject>& obj) {
+ PopupDismissedInternal();
+}
+
+void AutofillPopupViewAndroid::PopupDismissedInternal() {
if (controller_)
controller_->ViewDestroyed();

Powered by Google App Engine
This is Rietveld 408576698