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

Unified Diff: chrome/browser/ui/android/autofill/password_generation_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/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..89f00f0553f8a54edd00c270d049a81e8f0f7884 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
@@ -61,10 +61,13 @@ void PasswordGenerationPopupViewAndroid::Show() {
DCHECK(view_android);
+ popup_ = view_android->AcquireAnchorView();
+ if (popup_.is_null())
+ return;
java_object_.Reset(Java_PasswordGenerationPopupBridge_create(
- env, reinterpret_cast<intptr_t>(this),
- view_android->GetWindowAndroid()->GetJavaObject().obj(),
- view_android->GetViewAndroidDelegate().obj()));
+ env, popup_.view(env).obj(), controller_->element_bounds().width(),
+ reinterpret_cast<intptr_t>(this),
+ view_android->GetWindowAndroid()->GetJavaObject().obj()));
UpdateBoundsAndRedrawPopup();
}
@@ -72,7 +75,12 @@ void PasswordGenerationPopupViewAndroid::Show() {
void PasswordGenerationPopupViewAndroid::Hide() {
controller_ = NULL;
JNIEnv* env = base::android::AttachCurrentThread();
- Java_PasswordGenerationPopupBridge_hide(env, java_object_.obj());
+ if (!java_object_.is_null()) {
+ Java_PasswordGenerationPopupBridge_hide(env, java_object_.obj());
+ } else {
+ // Hide() should delete |this| either via Java dismiss or directly.
+ delete this;
+ }
}
gfx::Size PasswordGenerationPopupViewAndroid::GetPreferredSizeOfPasswordView() {
@@ -81,15 +89,14 @@ gfx::Size PasswordGenerationPopupViewAndroid::GetPreferredSizeOfPasswordView() {
}
void PasswordGenerationPopupViewAndroid::UpdateBoundsAndRedrawPopup() {
+ if (java_object_.is_null())
+ return;
+
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_.view(env), controller_->element_bounds());
boliu 2016/07/27 16:20:26 null check
Jinsuk Kim 2016/07/29 06:09:13 Done up above.
ScopedJavaLocalRef<jstring> password =
base::android::ConvertUTF16ToJavaString(env, controller_->password());
ScopedJavaLocalRef<jstring> suggestion =

Powered by Google App Engine
This is Rietveld 408576698