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 popup_view_ = view_android->AcquireAnchorView(); | |
| 40 if (popup_view_.is_null()) | |
| 41 return; | |
| 39 | 42 |
| 40 java_object_.Reset(Java_AutofillPopupBridge_create( | 43 java_object_.Reset(Java_AutofillPopupBridge_create( |
| 41 env, reinterpret_cast<intptr_t>(this), | 44 env, popup_view_.view().obj(), controller_->element_bounds().width(), |
| 42 view_android->GetWindowAndroid()->GetJavaObject().obj(), | 45 reinterpret_cast<intptr_t>(this), |
| 43 view_android->GetViewAndroidDelegate().obj())); | 46 view_android->GetWindowAndroid()->GetJavaObject().obj())); |
| 47 if (java_object_.is_null()) | |
|
no sievers
2016/07/19 22:29:30
nit: I'd not handle this since it's just a factory
Jinsuk Kim
2016/07/20 00:55:18
Done. Please see if the PopupDismissedInternal() l
| |
| 48 return; | |
| 44 | 49 |
| 45 UpdateBoundsAndRedrawPopup(); | 50 UpdateBoundsAndRedrawPopup(); |
| 46 } | 51 } |
| 47 | 52 |
| 48 void AutofillPopupViewAndroid::Hide() { | 53 void AutofillPopupViewAndroid::Hide() { |
| 49 controller_ = NULL; | 54 controller_ = NULL; |
| 50 JNIEnv* env = base::android::AttachCurrentThread(); | 55 JNIEnv* env = base::android::AttachCurrentThread(); |
| 51 Java_AutofillPopupBridge_dismiss(env, java_object_.obj()); | 56 Java_AutofillPopupBridge_dismiss(env, java_object_.obj()); |
| 52 } | 57 } |
| 53 | 58 |
| 54 void AutofillPopupViewAndroid::UpdateBoundsAndRedrawPopup() { | 59 void AutofillPopupViewAndroid::UpdateBoundsAndRedrawPopup() { |
| 60 ui::ViewAndroid* view_android = controller_->container_view(); | |
| 61 | |
| 62 DCHECK(view_android); | |
| 63 view_android->SetAnchorRect(popup_view_.view(), | |
| 64 controller_->element_bounds()); | |
| 65 | |
| 55 JNIEnv* env = base::android::AttachCurrentThread(); | 66 JNIEnv* env = base::android::AttachCurrentThread(); |
| 56 Java_AutofillPopupBridge_setAnchorRect( | |
| 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(); | 67 size_t count = controller_->GetLineCount(); |
| 65 ScopedJavaLocalRef<jobjectArray> data_array = | 68 ScopedJavaLocalRef<jobjectArray> data_array = |
| 66 Java_AutofillPopupBridge_createAutofillSuggestionArray(env, count); | 69 Java_AutofillPopupBridge_createAutofillSuggestionArray(env, count); |
| 67 | 70 |
| 68 for (size_t i = 0; i < count; ++i) { | 71 for (size_t i = 0; i < count; ++i) { |
| 69 ScopedJavaLocalRef<jstring> value = base::android::ConvertUTF16ToJavaString( | 72 ScopedJavaLocalRef<jstring> value = base::android::ConvertUTF16ToJavaString( |
| 70 env, controller_->GetElidedValueAt(i)); | 73 env, controller_->GetElidedValueAt(i)); |
| 71 ScopedJavaLocalRef<jstring> label = | 74 ScopedJavaLocalRef<jstring> label = |
| 72 base::android::ConvertUTF16ToJavaString( | 75 base::android::ConvertUTF16ToJavaString( |
| 73 env, controller_->GetElidedLabelAt(i)); | 76 env, controller_->GetElidedLabelAt(i)); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 153 // static | 156 // static |
| 154 AutofillPopupView* AutofillPopupView::Create( | 157 AutofillPopupView* AutofillPopupView::Create( |
| 155 AutofillPopupController* controller) { | 158 AutofillPopupController* controller) { |
| 156 if (IsKeyboardAccessoryEnabled()) | 159 if (IsKeyboardAccessoryEnabled()) |
| 157 return new AutofillKeyboardAccessoryView(controller); | 160 return new AutofillKeyboardAccessoryView(controller); |
| 158 | 161 |
| 159 return new AutofillPopupViewAndroid(controller); | 162 return new AutofillPopupViewAndroid(controller); |
| 160 } | 163 } |
| 161 | 164 |
| 162 } // namespace autofill | 165 } // namespace autofill |
| OLD | NEW |