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" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 DCHECK(view_android); | 42 DCHECK(view_android); |
43 popup_view_ = view_android->AcquireAnchorView(); | 43 popup_view_ = view_android->AcquireAnchorView(); |
44 const ScopedJavaLocalRef<jobject> view = popup_view_.view(); | 44 const ScopedJavaLocalRef<jobject> view = popup_view_.view(); |
45 if (view.is_null()) | 45 if (view.is_null()) |
46 return; | 46 return; |
47 | 47 |
48 java_object_.Reset(Java_AutofillPopupBridge_create( | 48 java_object_.Reset(Java_AutofillPopupBridge_create( |
49 env, view, reinterpret_cast<intptr_t>(this), | 49 env, view, reinterpret_cast<intptr_t>(this), |
50 view_android->GetWindowAndroid()->GetJavaObject())); | 50 view_android->GetWindowAndroid()->GetJavaObject())); |
51 | 51 |
52 UpdateBoundsAndRedrawPopup(); | 52 OnSuggestionsChanged(); |
53 } | 53 } |
54 | 54 |
55 void AutofillPopupViewAndroid::Hide() { | 55 void AutofillPopupViewAndroid::Hide() { |
56 controller_ = NULL; | 56 controller_ = NULL; |
57 JNIEnv* env = base::android::AttachCurrentThread(); | 57 JNIEnv* env = base::android::AttachCurrentThread(); |
58 if (!java_object_.is_null()) { | 58 if (!java_object_.is_null()) { |
59 Java_AutofillPopupBridge_dismiss(env, java_object_); | 59 Java_AutofillPopupBridge_dismiss(env, java_object_); |
60 } else { | 60 } else { |
61 // Hide() should delete |this| either via Java dismiss or directly. | 61 // Hide() should delete |this| either via Java dismiss or directly. |
62 delete this; | 62 delete this; |
63 } | 63 } |
64 } | 64 } |
65 | 65 |
66 void AutofillPopupViewAndroid::UpdateBoundsAndRedrawPopup() { | 66 void AutofillPopupViewAndroid::OnSuggestionsChanged() { |
67 if (java_object_.is_null()) | 67 if (java_object_.is_null()) |
68 return; | 68 return; |
69 | 69 |
70 const ScopedJavaLocalRef<jobject> view = popup_view_.view(); | 70 const ScopedJavaLocalRef<jobject> view = popup_view_.view(); |
71 if (view.is_null()) | 71 if (view.is_null()) |
72 return; | 72 return; |
73 | 73 |
74 ui::ViewAndroid* view_android = controller_->container_view(); | 74 ui::ViewAndroid* view_android = controller_->container_view(); |
75 | 75 |
76 DCHECK(view_android); | 76 DCHECK(view_android); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 | 163 |
164 void AutofillPopupViewAndroid::PopupDismissed( | 164 void AutofillPopupViewAndroid::PopupDismissed( |
165 JNIEnv* env, | 165 JNIEnv* env, |
166 const JavaParamRef<jobject>& obj) { | 166 const JavaParamRef<jobject>& obj) { |
167 if (controller_) | 167 if (controller_) |
168 controller_->ViewDestroyed(); | 168 controller_->ViewDestroyed(); |
169 | 169 |
170 delete this; | 170 delete this; |
171 } | 171 } |
172 | 172 |
173 void AutofillPopupViewAndroid::InvalidateRow(size_t) {} | |
174 | |
175 // static | 173 // static |
176 bool AutofillPopupViewAndroid::RegisterAutofillPopupViewAndroid(JNIEnv* env) { | 174 bool AutofillPopupViewAndroid::RegisterAutofillPopupViewAndroid(JNIEnv* env) { |
177 return RegisterNativesImpl(env); | 175 return RegisterNativesImpl(env); |
178 } | 176 } |
179 | 177 |
180 // static | 178 // static |
181 AutofillPopupView* AutofillPopupView::Create( | 179 AutofillPopupView* AutofillPopupView::Create( |
182 AutofillPopupController* controller) { | 180 AutofillPopupController* controller) { |
183 if (IsKeyboardAccessoryEnabled()) | 181 if (IsKeyboardAccessoryEnabled()) |
184 return new AutofillKeyboardAccessoryView(controller); | 182 return new AutofillKeyboardAccessoryView(controller); |
185 | 183 |
186 return new AutofillPopupViewAndroid(controller); | 184 return new AutofillPopupViewAndroid(controller); |
187 } | 185 } |
188 | 186 |
189 } // namespace autofill | 187 } // namespace autofill |
OLD | NEW |