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 "chrome/browser/android/resource_mapper.h" |
9 #include "chrome/browser/ui/android/window_android_helper.h" | 10 #include "chrome/browser/ui/android/window_android_helper.h" |
10 #include "chrome/browser/ui/autofill/autofill_popup_controller.h" | 11 #include "chrome/browser/ui/autofill/autofill_popup_controller.h" |
11 #include "content/public/browser/android/content_view_core.h" | 12 #include "content/public/browser/android/content_view_core.h" |
12 #include "jni/AutofillPopupBridge_jni.h" | 13 #include "jni/AutofillPopupBridge_jni.h" |
13 #include "ui/base/android/view_android.h" | 14 #include "ui/base/android/view_android.h" |
14 #include "ui/base/android/window_android.h" | 15 #include "ui/base/android/window_android.h" |
| 16 #include "ui/base/resource/resource_bundle.h" |
| 17 #include "ui/gfx/android/java_bitmap.h" |
15 #include "ui/gfx/rect.h" | 18 #include "ui/gfx/rect.h" |
16 | 19 |
17 namespace autofill { | 20 namespace autofill { |
18 | 21 |
19 AutofillPopupViewAndroid::AutofillPopupViewAndroid( | 22 AutofillPopupViewAndroid::AutofillPopupViewAndroid( |
20 AutofillPopupController* controller) | 23 AutofillPopupController* controller) |
21 : controller_(controller) {} | 24 : controller_(controller) {} |
22 | 25 |
23 AutofillPopupViewAndroid::~AutofillPopupViewAndroid() {} | 26 AutofillPopupViewAndroid::~AutofillPopupViewAndroid() {} |
24 | 27 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 61 |
59 ScopedJavaLocalRef<jobjectArray> data_array = | 62 ScopedJavaLocalRef<jobjectArray> data_array = |
60 Java_AutofillPopupBridge_createAutofillSuggestionArray(env, count); | 63 Java_AutofillPopupBridge_createAutofillSuggestionArray(env, count); |
61 | 64 |
62 for (size_t i = 0; i < count; ++i) { | 65 for (size_t i = 0; i < count; ++i) { |
63 ScopedJavaLocalRef<jstring> name = | 66 ScopedJavaLocalRef<jstring> name = |
64 base::android::ConvertUTF16ToJavaString(env, controller_->names()[i]); | 67 base::android::ConvertUTF16ToJavaString(env, controller_->names()[i]); |
65 ScopedJavaLocalRef<jstring> subtext = | 68 ScopedJavaLocalRef<jstring> subtext = |
66 base::android::ConvertUTF16ToJavaString(env, | 69 base::android::ConvertUTF16ToJavaString(env, |
67 controller_->subtexts()[i]); | 70 controller_->subtexts()[i]); |
| 71 int android_icon_id = 0; |
| 72 if (!controller_->icons()[i].empty()) { |
| 73 android_icon_id = ResourceMapper::MapFromChromiumId( |
| 74 controller_->GetIconResourceID(controller_->icons()[i])); |
| 75 } |
| 76 |
68 Java_AutofillPopupBridge_addToAutofillSuggestionArray( | 77 Java_AutofillPopupBridge_addToAutofillSuggestionArray( |
69 env, | 78 env, |
70 data_array.obj(), | 79 data_array.obj(), |
71 i, | 80 i, |
72 name.obj(), | 81 name.obj(), |
73 subtext.obj(), | 82 subtext.obj(), |
| 83 android_icon_id, |
74 controller_->identifiers()[i]); | 84 controller_->identifiers()[i]); |
75 } | 85 } |
76 | 86 |
77 Java_AutofillPopupBridge_show( | 87 Java_AutofillPopupBridge_show( |
78 env, java_object_.obj(), data_array.obj(), controller_->IsRTL()); | 88 env, java_object_.obj(), data_array.obj(), controller_->IsRTL()); |
79 } | 89 } |
80 | 90 |
81 void AutofillPopupViewAndroid::SuggestionSelected(JNIEnv* env, | 91 void AutofillPopupViewAndroid::SuggestionSelected(JNIEnv* env, |
82 jobject obj, | 92 jobject obj, |
83 jint list_index) { | 93 jint list_index) { |
(...skipping 14 matching lines...) Expand all Loading... |
98 return RegisterNativesImpl(env); | 108 return RegisterNativesImpl(env); |
99 } | 109 } |
100 | 110 |
101 // static | 111 // static |
102 AutofillPopupView* AutofillPopupView::Create( | 112 AutofillPopupView* AutofillPopupView::Create( |
103 AutofillPopupController* controller) { | 113 AutofillPopupController* controller) { |
104 return new AutofillPopupViewAndroid(controller); | 114 return new AutofillPopupViewAndroid(controller); |
105 } | 115 } |
106 | 116 |
107 } // namespace autofill | 117 } // namespace autofill |
OLD | NEW |