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 popup_view_.reset(view_android->AcquireAnchorView()); |
|
no sievers
2016/07/18 22:14:16
I'd handle |anchor_view_.view_.is_null()| here and
Jinsuk Kim
2016/07/19 07:08:39
Done.
| |
| 40 java_object_.Reset(Java_AutofillPopupBridge_create( | 40 java_object_.Reset(Java_AutofillPopupBridge_create( |
| 41 env, reinterpret_cast<intptr_t>(this), | 41 env, popup_view_->obj(), controller_->element_bounds().width(), |
| 42 view_android->GetWindowAndroid()->GetJavaObject().obj(), | 42 reinterpret_cast<intptr_t>(this), |
| 43 view_android->GetViewAndroidDelegate().obj())); | 43 view_android->GetWindowAndroid()->GetJavaObject().obj())); |
| 44 | 44 |
| 45 UpdateBoundsAndRedrawPopup(); | 45 UpdateBoundsAndRedrawPopup(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 void AutofillPopupViewAndroid::Hide() { | 48 void AutofillPopupViewAndroid::Hide() { |
| 49 controller_ = NULL; | 49 controller_ = NULL; |
| 50 JNIEnv* env = base::android::AttachCurrentThread(); | 50 JNIEnv* env = base::android::AttachCurrentThread(); |
| 51 popup_view_.reset(); | |
|
no sievers
2016/07/18 22:14:16
See comment in password_generation_popup_view_andr
Jinsuk Kim
2016/07/19 07:08:39
Done. Removed it as we do not use unique_ptr any m
| |
| 51 Java_AutofillPopupBridge_dismiss(env, java_object_.obj()); | 52 Java_AutofillPopupBridge_dismiss(env, java_object_.obj()); |
| 52 } | 53 } |
| 53 | 54 |
| 54 void AutofillPopupViewAndroid::UpdateBoundsAndRedrawPopup() { | 55 void AutofillPopupViewAndroid::UpdateBoundsAndRedrawPopup() { |
| 56 ui::ViewAndroid* view_android = controller_->container_view(); | |
| 57 | |
| 58 DCHECK(view_android); | |
| 59 view_android->SetAnchorRect(popup_view_->ref(), | |
| 60 controller_->element_bounds()); | |
| 61 | |
| 55 JNIEnv* env = base::android::AttachCurrentThread(); | 62 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(); | 63 size_t count = controller_->GetLineCount(); |
| 65 ScopedJavaLocalRef<jobjectArray> data_array = | 64 ScopedJavaLocalRef<jobjectArray> data_array = |
| 66 Java_AutofillPopupBridge_createAutofillSuggestionArray(env, count); | 65 Java_AutofillPopupBridge_createAutofillSuggestionArray(env, count); |
| 67 | 66 |
| 68 for (size_t i = 0; i < count; ++i) { | 67 for (size_t i = 0; i < count; ++i) { |
| 69 ScopedJavaLocalRef<jstring> value = base::android::ConvertUTF16ToJavaString( | 68 ScopedJavaLocalRef<jstring> value = base::android::ConvertUTF16ToJavaString( |
| 70 env, controller_->GetElidedValueAt(i)); | 69 env, controller_->GetElidedValueAt(i)); |
| 71 ScopedJavaLocalRef<jstring> label = | 70 ScopedJavaLocalRef<jstring> label = |
| 72 base::android::ConvertUTF16ToJavaString( | 71 base::android::ConvertUTF16ToJavaString( |
| 73 env, controller_->GetElidedLabelAt(i)); | 72 env, controller_->GetElidedLabelAt(i)); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 if (!controller_) | 129 if (!controller_) |
| 131 return; | 130 return; |
| 132 | 131 |
| 133 CHECK_GE(deleting_index_, 0); | 132 CHECK_GE(deleting_index_, 0); |
| 134 controller_->RemoveSuggestion(deleting_index_); | 133 controller_->RemoveSuggestion(deleting_index_); |
| 135 } | 134 } |
| 136 | 135 |
| 137 void AutofillPopupViewAndroid::PopupDismissed( | 136 void AutofillPopupViewAndroid::PopupDismissed( |
| 138 JNIEnv* env, | 137 JNIEnv* env, |
| 139 const JavaParamRef<jobject>& obj) { | 138 const JavaParamRef<jobject>& obj) { |
| 140 if (controller_) | 139 if (controller_) { |
| 141 controller_->ViewDestroyed(); | 140 controller_->ViewDestroyed(); |
| 141 } | |
| 142 | 142 |
| 143 delete this; | 143 delete this; |
| 144 } | 144 } |
| 145 | 145 |
| 146 void AutofillPopupViewAndroid::InvalidateRow(size_t) {} | 146 void AutofillPopupViewAndroid::InvalidateRow(size_t) {} |
| 147 | 147 |
| 148 // static | 148 // static |
| 149 bool AutofillPopupViewAndroid::RegisterAutofillPopupViewAndroid(JNIEnv* env) { | 149 bool AutofillPopupViewAndroid::RegisterAutofillPopupViewAndroid(JNIEnv* env) { |
| 150 return RegisterNativesImpl(env); | 150 return RegisterNativesImpl(env); |
| 151 } | 151 } |
| 152 | 152 |
| 153 // static | 153 // static |
| 154 AutofillPopupView* AutofillPopupView::Create( | 154 AutofillPopupView* AutofillPopupView::Create( |
| 155 AutofillPopupController* controller) { | 155 AutofillPopupController* controller) { |
| 156 if (IsKeyboardAccessoryEnabled()) | 156 if (IsKeyboardAccessoryEnabled()) |
| 157 return new AutofillKeyboardAccessoryView(controller); | 157 return new AutofillKeyboardAccessoryView(controller); |
| 158 | 158 |
| 159 return new AutofillPopupViewAndroid(controller); | 159 return new AutofillPopupViewAndroid(controller); |
| 160 } | 160 } |
| 161 | 161 |
| 162 } // namespace autofill | 162 } // namespace autofill |
| OLD | NEW |