| 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/window_android_helper.h" | 10 #include "chrome/browser/ui/android/window_android_helper.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 53 |
| 54 void AutofillKeyboardAccessoryView::UpdateBoundsAndRedrawPopup() { | 54 void AutofillKeyboardAccessoryView::UpdateBoundsAndRedrawPopup() { |
| 55 JNIEnv* env = base::android::AttachCurrentThread(); | 55 JNIEnv* env = base::android::AttachCurrentThread(); |
| 56 size_t count = controller_->GetLineCount(); | 56 size_t count = controller_->GetLineCount(); |
| 57 ScopedJavaLocalRef<jobjectArray> data_array = | 57 ScopedJavaLocalRef<jobjectArray> data_array = |
| 58 Java_AutofillKeyboardAccessoryBridge_createAutofillSuggestionArray(env, | 58 Java_AutofillKeyboardAccessoryBridge_createAutofillSuggestionArray(env, |
| 59 count); | 59 count); |
| 60 | 60 |
| 61 for (size_t i = 0; i < count; ++i) { | 61 for (size_t i = 0; i < count; ++i) { |
| 62 const autofill::Suggestion& suggestion = controller_->GetSuggestionAt(i); | 62 const autofill::Suggestion& suggestion = controller_->GetSuggestionAt(i); |
| 63 base::string16 value = suggestion.value; | |
| 64 if (!suggestion.label.empty()) { | |
| 65 value.append( | |
| 66 l10n_util::GetStringUTF16(IDS_AUTOFILL_ADDRESS_SUMMARY_SEPARATOR)); | |
| 67 value.append(suggestion.label); | |
| 68 } | |
| 69 | |
| 70 int android_icon_id = 0; | 63 int android_icon_id = 0; |
| 71 if (!suggestion.icon.empty()) { | 64 if (!suggestion.icon.empty()) { |
| 72 android_icon_id = ResourceMapper::MapFromChromiumId( | 65 android_icon_id = ResourceMapper::MapFromChromiumId( |
| 73 controller_->GetIconResourceID(suggestion.icon)); | 66 controller_->GetIconResourceID(suggestion.icon)); |
| 74 } | 67 } |
| 75 | 68 |
| 76 Java_AutofillKeyboardAccessoryBridge_addToAutofillSuggestionArray( | 69 Java_AutofillKeyboardAccessoryBridge_addToAutofillSuggestionArray( |
| 77 env, data_array.obj(), i, | 70 env, data_array.obj(), i, |
| 78 base::android::ConvertUTF16ToJavaString(env, value).obj(), | 71 base::android::ConvertUTF16ToJavaString(env, suggestion.value).obj(), |
| 72 base::android::ConvertUTF16ToJavaString(env, suggestion.label).obj(), |
| 79 android_icon_id, suggestion.frontend_id); | 73 android_icon_id, suggestion.frontend_id); |
| 80 } | 74 } |
| 81 | 75 |
| 82 Java_AutofillKeyboardAccessoryBridge_show( | 76 Java_AutofillKeyboardAccessoryBridge_show( |
| 83 env, java_object_.obj(), data_array.obj(), controller_->IsRTL()); | 77 env, java_object_.obj(), data_array.obj(), controller_->IsRTL()); |
| 84 } | 78 } |
| 85 | 79 |
| 86 void AutofillKeyboardAccessoryView::SuggestionSelected(JNIEnv* env, | 80 void AutofillKeyboardAccessoryView::SuggestionSelected(JNIEnv* env, |
| 87 jobject obj, | 81 jobject obj, |
| 88 jint list_index) { | 82 jint list_index) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 101 void AutofillKeyboardAccessoryView::InvalidateRow(size_t) { | 95 void AutofillKeyboardAccessoryView::InvalidateRow(size_t) { |
| 102 } | 96 } |
| 103 | 97 |
| 104 // static | 98 // static |
| 105 bool AutofillKeyboardAccessoryView::RegisterAutofillKeyboardAccessoryView( | 99 bool AutofillKeyboardAccessoryView::RegisterAutofillKeyboardAccessoryView( |
| 106 JNIEnv* env) { | 100 JNIEnv* env) { |
| 107 return RegisterNativesImpl(env); | 101 return RegisterNativesImpl(env); |
| 108 } | 102 } |
| 109 | 103 |
| 110 } // namespace autofill | 104 } // namespace autofill |
| OLD | NEW |