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

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: webview issues addressed 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 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;

Powered by Google App Engine
This is Rietveld 408576698