| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/android/autofill/autofill_popup_view_android.h" | 5 #include "chrome/browser/ui/android/autofill/autofill_popup_view_android.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
| 9 #include "chrome/browser/ui/android/window_android_helper.h" | 9 #include "chrome/browser/ui/android/window_android_helper.h" |
| 10 #include "chrome/browser/ui/autofill/autofill_popup_controller.h" | 10 #include "chrome/browser/ui/autofill/autofill_popup_controller.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 java_object_.Reset(Java_AutofillPopupBridge_create( | 31 java_object_.Reset(Java_AutofillPopupBridge_create( |
| 32 env, | 32 env, |
| 33 reinterpret_cast<intptr_t>(this), | 33 reinterpret_cast<intptr_t>(this), |
| 34 view_android->GetWindowAndroid()->GetJavaObject().obj(), | 34 view_android->GetWindowAndroid()->GetJavaObject().obj(), |
| 35 view_android->GetJavaObject().obj())); | 35 view_android->GetJavaObject().obj())); |
| 36 | 36 |
| 37 UpdateBoundsAndRedrawPopup(); | 37 UpdateBoundsAndRedrawPopup(); |
| 38 } | 38 } |
| 39 | 39 |
| 40 void AutofillPopupViewAndroid::Hide() { | 40 void AutofillPopupViewAndroid::Hide() { |
| 41 controller_ = NULL; |
| 41 JNIEnv* env = base::android::AttachCurrentThread(); | 42 JNIEnv* env = base::android::AttachCurrentThread(); |
| 42 Java_AutofillPopupBridge_hide(env, java_object_.obj()); | 43 Java_AutofillPopupBridge_hide(env, java_object_.obj()); |
| 43 delete this; | |
| 44 } | 44 } |
| 45 | 45 |
| 46 void AutofillPopupViewAndroid::UpdateBoundsAndRedrawPopup() { | 46 void AutofillPopupViewAndroid::UpdateBoundsAndRedrawPopup() { |
| 47 JNIEnv* env = base::android::AttachCurrentThread(); | 47 JNIEnv* env = base::android::AttachCurrentThread(); |
| 48 Java_AutofillPopupBridge_setAnchorRect( | 48 Java_AutofillPopupBridge_setAnchorRect( |
| 49 env, | 49 env, |
| 50 java_object_.obj(), | 50 java_object_.obj(), |
| 51 controller_->element_bounds().x(), | 51 controller_->element_bounds().x(), |
| 52 controller_->element_bounds().y(), | 52 controller_->element_bounds().y(), |
| 53 controller_->element_bounds().width(), | 53 controller_->element_bounds().width(), |
| (...skipping 23 matching lines...) Expand all Loading... |
| 77 Java_AutofillPopupBridge_show( | 77 Java_AutofillPopupBridge_show( |
| 78 env, java_object_.obj(), data_array.obj(), controller_->IsRTL()); | 78 env, java_object_.obj(), data_array.obj(), controller_->IsRTL()); |
| 79 } | 79 } |
| 80 | 80 |
| 81 void AutofillPopupViewAndroid::SuggestionSelected(JNIEnv* env, | 81 void AutofillPopupViewAndroid::SuggestionSelected(JNIEnv* env, |
| 82 jobject obj, | 82 jobject obj, |
| 83 jint list_index) { | 83 jint list_index) { |
| 84 controller_->AcceptSuggestion(list_index); | 84 controller_->AcceptSuggestion(list_index); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void AutofillPopupViewAndroid::RequestHide(JNIEnv* env, jobject obj) { | 87 void AutofillPopupViewAndroid::PopupDismissed(JNIEnv* env, jobject obj) { |
| 88 controller_->Hide(); | 88 if (controller_) |
| 89 controller_->ViewDestroyed(); |
| 90 |
| 91 delete this; |
| 89 } | 92 } |
| 90 | 93 |
| 91 void AutofillPopupViewAndroid::InvalidateRow(size_t) {} | 94 void AutofillPopupViewAndroid::InvalidateRow(size_t) {} |
| 92 | 95 |
| 93 // static | 96 // static |
| 94 bool AutofillPopupViewAndroid::RegisterAutofillPopupViewAndroid(JNIEnv* env) { | 97 bool AutofillPopupViewAndroid::RegisterAutofillPopupViewAndroid(JNIEnv* env) { |
| 95 return RegisterNativesImpl(env); | 98 return RegisterNativesImpl(env); |
| 96 } | 99 } |
| 97 | 100 |
| 98 // static | 101 // static |
| 99 AutofillPopupView* AutofillPopupView::Create( | 102 AutofillPopupView* AutofillPopupView::Create( |
| 100 AutofillPopupController* controller) { | 103 AutofillPopupController* controller) { |
| 101 return new AutofillPopupViewAndroid(controller); | 104 return new AutofillPopupViewAndroid(controller); |
| 102 } | 105 } |
| 103 | 106 |
| 104 } // namespace autofill | 107 } // namespace autofill |
| OLD | NEW |