| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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_keyboard_accessory_view.h" | 5 #include "chrome/browser/ui/android/autofill/autofill_keyboard_accessory_view.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/android/resource_mapper.h" | 9 #include "chrome/browser/android/resource_mapper.h" |
| 10 #include "chrome/browser/ui/android/view_android_helper.h" | 10 #include "chrome/browser/ui/android/view_android_helper.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 Java_AutofillKeyboardAccessoryBridge_addToAutofillSuggestionArray( | 38 Java_AutofillKeyboardAccessoryBridge_addToAutofillSuggestionArray( |
| 39 env, data_array, position, | 39 env, data_array, position, |
| 40 base::android::ConvertUTF16ToJavaString(env, suggestion.value), | 40 base::android::ConvertUTF16ToJavaString(env, suggestion.value), |
| 41 base::android::ConvertUTF16ToJavaString(env, suggestion.label), | 41 base::android::ConvertUTF16ToJavaString(env, suggestion.label), |
| 42 android_icon_id, suggestion.frontend_id, deletable); | 42 android_icon_id, suggestion.frontend_id, deletable); |
| 43 } | 43 } |
| 44 | 44 |
| 45 } // namespace | 45 } // namespace |
| 46 | 46 |
| 47 AutofillKeyboardAccessoryView::AutofillKeyboardAccessoryView( | 47 AutofillKeyboardAccessoryView::AutofillKeyboardAccessoryView( |
| 48 AutofillPopupController* controller) | 48 AutofillPopupController* controller, |
| 49 : controller_(controller), deleting_index_(-1) { | 49 unsigned int animation_duration_millis, |
| 50 bool should_limit_label_width, |
| 51 bool is_first_suggestion_a_hint) |
| 52 : controller_(controller), |
| 53 animation_duration_millis_(animation_duration_millis), |
| 54 should_limit_label_width_(should_limit_label_width), |
| 55 is_first_suggestion_a_hint_(is_first_suggestion_a_hint), |
| 56 deleting_index_(-1) { |
| 50 JNIEnv* env = base::android::AttachCurrentThread(); | 57 JNIEnv* env = base::android::AttachCurrentThread(); |
| 51 java_object_.Reset(Java_AutofillKeyboardAccessoryBridge_create(env)); | 58 java_object_.Reset(Java_AutofillKeyboardAccessoryBridge_create(env)); |
| 52 } | 59 } |
| 53 | 60 |
| 54 AutofillKeyboardAccessoryView::~AutofillKeyboardAccessoryView() { | 61 AutofillKeyboardAccessoryView::~AutofillKeyboardAccessoryView() { |
| 55 JNIEnv* env = base::android::AttachCurrentThread(); | 62 JNIEnv* env = base::android::AttachCurrentThread(); |
| 56 Java_AutofillKeyboardAccessoryBridge_resetNativeViewPointer(env, | 63 Java_AutofillKeyboardAccessoryBridge_resetNativeViewPointer(env, |
| 57 java_object_); | 64 java_object_); |
| 58 } | 65 } |
| 59 | 66 |
| 60 void AutofillKeyboardAccessoryView::Show() { | 67 void AutofillKeyboardAccessoryView::Show() { |
| 61 JNIEnv* env = base::android::AttachCurrentThread(); | 68 JNIEnv* env = base::android::AttachCurrentThread(); |
| 62 ui::ViewAndroid* view_android = controller_->container_view(); | 69 ui::ViewAndroid* view_android = controller_->container_view(); |
| 63 DCHECK(view_android); | 70 DCHECK(view_android); |
| 64 Java_AutofillKeyboardAccessoryBridge_init( | 71 Java_AutofillKeyboardAccessoryBridge_init( |
| 65 env, java_object_, reinterpret_cast<intptr_t>(this), | 72 env, java_object_, reinterpret_cast<intptr_t>(this), |
| 66 view_android->GetWindowAndroid()->GetJavaObject()); | 73 view_android->GetWindowAndroid()->GetJavaObject(), |
| 74 animation_duration_millis_, should_limit_label_width_, |
| 75 is_first_suggestion_a_hint_); |
| 67 | 76 |
| 68 OnSuggestionsChanged(); | 77 OnSuggestionsChanged(); |
| 69 } | 78 } |
| 70 | 79 |
| 71 void AutofillKeyboardAccessoryView::Hide() { | 80 void AutofillKeyboardAccessoryView::Hide() { |
| 72 controller_ = nullptr; | 81 controller_ = nullptr; |
| 73 JNIEnv* env = base::android::AttachCurrentThread(); | 82 JNIEnv* env = base::android::AttachCurrentThread(); |
| 74 Java_AutofillKeyboardAccessoryBridge_dismiss(env, java_object_); | 83 Java_AutofillKeyboardAccessoryBridge_dismiss(env, java_object_); |
| 75 } | 84 } |
| 76 | 85 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 delete this; | 171 delete this; |
| 163 } | 172 } |
| 164 | 173 |
| 165 // static | 174 // static |
| 166 bool AutofillKeyboardAccessoryView::RegisterAutofillKeyboardAccessoryView( | 175 bool AutofillKeyboardAccessoryView::RegisterAutofillKeyboardAccessoryView( |
| 167 JNIEnv* env) { | 176 JNIEnv* env) { |
| 168 return RegisterNativesImpl(env); | 177 return RegisterNativesImpl(env); |
| 169 } | 178 } |
| 170 | 179 |
| 171 } // namespace autofill | 180 } // namespace autofill |
| OLD | NEW |