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