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" |
11 #include "chrome/browser/ui/android/autofill/autofill_keyboard_accessory_view.h" | 11 #include "chrome/browser/ui/android/autofill/autofill_keyboard_accessory_view.h" |
12 #include "chrome/browser/ui/android/view_android_helper.h" | 12 #include "chrome/browser/ui/android/view_android_helper.h" |
13 #include "chrome/browser/ui/autofill/autofill_popup_controller.h" | 13 #include "chrome/browser/ui/autofill/autofill_popup_controller.h" |
| 14 #include "chrome/browser/ui/autofill/autofill_popup_view_helper.h" |
14 #include "components/autofill/core/browser/suggestion.h" | 15 #include "components/autofill/core/browser/suggestion.h" |
15 #include "components/autofill/core/common/autofill_util.h" | 16 #include "components/autofill/core/common/autofill_util.h" |
16 #include "content/public/browser/android/content_view_core.h" | 17 #include "content/public/browser/android/content_view_core.h" |
17 #include "jni/AutofillPopupBridge_jni.h" | 18 #include "jni/AutofillPopupBridge_jni.h" |
18 #include "ui/android/view_android.h" | 19 #include "ui/android/view_android.h" |
19 #include "ui/android/window_android.h" | 20 #include "ui/android/window_android.h" |
20 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
21 #include "ui/gfx/android/java_bitmap.h" | 22 #include "ui/gfx/android/java_bitmap.h" |
22 #include "ui/gfx/geometry/rect_f.h" | 23 #include "ui/gfx/geometry/rect_f.h" |
23 | 24 |
24 namespace autofill { | 25 namespace autofill { |
25 | 26 |
26 AutofillPopupViewAndroid::AutofillPopupViewAndroid( | 27 AutofillPopupViewAndroid::AutofillPopupViewAndroid( |
27 AutofillPopupController* controller) | 28 AutofillPopupController* controller) |
28 : controller_(controller), | 29 : controller_(controller), deleting_index_(-1) {} |
29 deleting_index_(-1) {} | |
30 | 30 |
31 AutofillPopupViewAndroid::~AutofillPopupViewAndroid() {} | 31 AutofillPopupViewAndroid::~AutofillPopupViewAndroid() {} |
32 | 32 |
33 void AutofillPopupViewAndroid::Show() { | 33 void AutofillPopupViewAndroid::Show() { |
34 JNIEnv* env = base::android::AttachCurrentThread(); | 34 JNIEnv* env = base::android::AttachCurrentThread(); |
35 ui::ViewAndroid* view_android = controller_->container_view(); | 35 ui::ViewAndroid* view_android = controller_->container_view(); |
36 | 36 |
37 DCHECK(view_android); | 37 DCHECK(view_android); |
38 | 38 |
39 java_object_.Reset(Java_AutofillPopupBridge_create( | 39 java_object_.Reset(Java_AutofillPopupBridge_create( |
(...skipping 28 matching lines...) Expand all Loading... |
68 ScopedJavaLocalRef<jstring> value = base::android::ConvertUTF16ToJavaString( | 68 ScopedJavaLocalRef<jstring> value = base::android::ConvertUTF16ToJavaString( |
69 env, controller_->GetElidedValueAt(i)); | 69 env, controller_->GetElidedValueAt(i)); |
70 ScopedJavaLocalRef<jstring> label = | 70 ScopedJavaLocalRef<jstring> label = |
71 base::android::ConvertUTF16ToJavaString( | 71 base::android::ConvertUTF16ToJavaString( |
72 env, controller_->GetElidedLabelAt(i)); | 72 env, controller_->GetElidedLabelAt(i)); |
73 int android_icon_id = 0; | 73 int android_icon_id = 0; |
74 | 74 |
75 const autofill::Suggestion& suggestion = controller_->GetSuggestionAt(i); | 75 const autofill::Suggestion& suggestion = controller_->GetSuggestionAt(i); |
76 if (!suggestion.icon.empty()) { | 76 if (!suggestion.icon.empty()) { |
77 android_icon_id = ResourceMapper::MapFromChromiumId( | 77 android_icon_id = ResourceMapper::MapFromChromiumId( |
78 controller_->GetIconResourceID(suggestion.icon)); | 78 controller_->view_helper()->GetIconResourceID(suggestion.icon)); |
79 } | 79 } |
80 | 80 |
81 bool deletable = | 81 bool deletable = |
82 controller_->GetRemovalConfirmationText(i, nullptr, nullptr); | 82 controller_->GetRemovalConfirmationText(i, nullptr, nullptr); |
83 Java_AutofillPopupBridge_addToAutofillSuggestionArray( | 83 Java_AutofillPopupBridge_addToAutofillSuggestionArray( |
84 env, | 84 env, |
85 data_array.obj(), | 85 data_array.obj(), |
86 i, | 86 i, |
87 value.obj(), | 87 value.obj(), |
88 label.obj(), | 88 label.obj(), |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 // static | 156 // static |
157 AutofillPopupView* AutofillPopupView::Create( | 157 AutofillPopupView* AutofillPopupView::Create( |
158 AutofillPopupController* controller) { | 158 AutofillPopupController* controller) { |
159 if (IsKeyboardAccessoryEnabled()) | 159 if (IsKeyboardAccessoryEnabled()) |
160 return new AutofillKeyboardAccessoryView(controller); | 160 return new AutofillKeyboardAccessoryView(controller); |
161 | 161 |
162 return new AutofillPopupViewAndroid(controller); | 162 return new AutofillPopupViewAndroid(controller); |
163 } | 163 } |
164 | 164 |
165 } // namespace autofill | 165 } // namespace autofill |
OLD | NEW |