Chromium Code Reviews| 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 "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "chrome/browser/android/resource_mapper.h" | 10 #include "chrome/browser/android/resource_mapper.h" |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 AutofillPopupController* controller) | 29 AutofillPopupController* controller) |
| 30 : controller_(controller), deleting_index_(-1) {} | 30 : controller_(controller), deleting_index_(-1) {} |
| 31 | 31 |
| 32 AutofillPopupViewAndroid::~AutofillPopupViewAndroid() {} | 32 AutofillPopupViewAndroid::~AutofillPopupViewAndroid() {} |
| 33 | 33 |
| 34 void AutofillPopupViewAndroid::Show() { | 34 void AutofillPopupViewAndroid::Show() { |
| 35 JNIEnv* env = base::android::AttachCurrentThread(); | 35 JNIEnv* env = base::android::AttachCurrentThread(); |
| 36 ui::ViewAndroid* view_android = controller_->container_view(); | 36 ui::ViewAndroid* view_android = controller_->container_view(); |
| 37 | 37 |
| 38 DCHECK(view_android); | 38 DCHECK(view_android); |
| 39 | 39 ScopedJavaLocalRef<jobject> anchor_view = |
| 40 view_android->AcquireAnchorView(controller_->element_bounds()); | |
| 40 java_object_.Reset(Java_AutofillPopupBridge_create( | 41 java_object_.Reset(Java_AutofillPopupBridge_create( |
| 41 env, reinterpret_cast<intptr_t>(this), | 42 env, anchor_view.obj(), controller_->element_bounds().width(), |
| 43 reinterpret_cast<intptr_t>(this), | |
| 42 view_android->GetWindowAndroid()->GetJavaObject().obj(), | 44 view_android->GetWindowAndroid()->GetJavaObject().obj(), |
| 43 view_android->GetViewAndroidDelegate().obj())); | 45 view_android->GetViewAndroidDelegate().obj())); |
| 44 | 46 |
| 45 UpdateBoundsAndRedrawPopup(); | 47 UpdateBoundsAndRedrawPopup(); |
| 46 } | 48 } |
| 47 | 49 |
| 48 void AutofillPopupViewAndroid::Hide() { | 50 void AutofillPopupViewAndroid::Hide() { |
| 49 controller_ = NULL; | 51 controller_ = NULL; |
| 50 JNIEnv* env = base::android::AttachCurrentThread(); | 52 JNIEnv* env = base::android::AttachCurrentThread(); |
| 51 Java_AutofillPopupBridge_dismiss(env, java_object_.obj()); | 53 Java_AutofillPopupBridge_dismiss(env, java_object_.obj()); |
| 52 } | 54 } |
| 53 | 55 |
| 54 void AutofillPopupViewAndroid::UpdateBoundsAndRedrawPopup() { | 56 void AutofillPopupViewAndroid::UpdateBoundsAndRedrawPopup() { |
| 55 JNIEnv* env = base::android::AttachCurrentThread(); | 57 JNIEnv* env = base::android::AttachCurrentThread(); |
| 56 Java_AutofillPopupBridge_setAnchorRect( | |
|
no sievers
2016/07/12 21:57:27
So for this one we have to support repositioning i
Jinsuk Kim
2016/07/14 07:51:52
You're correct. Added back |ViewAndroidDelegate.se
| |
| 57 env, | |
| 58 java_object_.obj(), | |
| 59 controller_->element_bounds().x(), | |
| 60 controller_->element_bounds().y(), | |
| 61 controller_->element_bounds().width(), | |
| 62 controller_->element_bounds().height()); | |
| 63 | |
| 64 size_t count = controller_->GetLineCount(); | 58 size_t count = controller_->GetLineCount(); |
| 65 ScopedJavaLocalRef<jobjectArray> data_array = | 59 ScopedJavaLocalRef<jobjectArray> data_array = |
| 66 Java_AutofillPopupBridge_createAutofillSuggestionArray(env, count); | 60 Java_AutofillPopupBridge_createAutofillSuggestionArray(env, count); |
| 67 | 61 |
| 68 for (size_t i = 0; i < count; ++i) { | 62 for (size_t i = 0; i < count; ++i) { |
| 69 ScopedJavaLocalRef<jstring> value = base::android::ConvertUTF16ToJavaString( | 63 ScopedJavaLocalRef<jstring> value = base::android::ConvertUTF16ToJavaString( |
| 70 env, controller_->GetElidedValueAt(i)); | 64 env, controller_->GetElidedValueAt(i)); |
| 71 ScopedJavaLocalRef<jstring> label = | 65 ScopedJavaLocalRef<jstring> label = |
| 72 base::android::ConvertUTF16ToJavaString( | 66 base::android::ConvertUTF16ToJavaString( |
| 73 env, controller_->GetElidedLabelAt(i)); | 67 env, controller_->GetElidedLabelAt(i)); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 153 // static | 147 // static |
| 154 AutofillPopupView* AutofillPopupView::Create( | 148 AutofillPopupView* AutofillPopupView::Create( |
| 155 AutofillPopupController* controller) { | 149 AutofillPopupController* controller) { |
| 156 if (IsKeyboardAccessoryEnabled()) | 150 if (IsKeyboardAccessoryEnabled()) |
| 157 return new AutofillKeyboardAccessoryView(controller); | 151 return new AutofillKeyboardAccessoryView(controller); |
| 158 | 152 |
| 159 return new AutofillPopupViewAndroid(controller); | 153 return new AutofillPopupViewAndroid(controller); |
| 160 } | 154 } |
| 161 | 155 |
| 162 } // namespace autofill | 156 } // namespace autofill |
| OLD | NEW |