| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 label.obj(), | 88 label.obj(), |
| 89 android_icon_id, | 89 android_icon_id, |
| 90 suggestion.frontend_id, | 90 suggestion.frontend_id, |
| 91 deletable); | 91 deletable); |
| 92 } | 92 } |
| 93 | 93 |
| 94 Java_AutofillPopupBridge_show( | 94 Java_AutofillPopupBridge_show( |
| 95 env, java_object_.obj(), data_array.obj(), controller_->IsRTL()); | 95 env, java_object_.obj(), data_array.obj(), controller_->IsRTL()); |
| 96 } | 96 } |
| 97 | 97 |
| 98 void AutofillPopupViewAndroid::SuggestionSelected(JNIEnv* env, | 98 void AutofillPopupViewAndroid::SuggestionSelected( |
| 99 jobject obj, | 99 JNIEnv* env, |
| 100 jint list_index) { | 100 const JavaParamRef<jobject>& obj, |
| 101 jint list_index) { |
| 101 // Race: Hide() may have already run. | 102 // Race: Hide() may have already run. |
| 102 if (controller_) | 103 if (controller_) |
| 103 controller_->AcceptSuggestion(list_index); | 104 controller_->AcceptSuggestion(list_index); |
| 104 } | 105 } |
| 105 | 106 |
| 106 void AutofillPopupViewAndroid::DeletionRequested(JNIEnv* env, | 107 void AutofillPopupViewAndroid::DeletionRequested( |
| 107 jobject obj, | 108 JNIEnv* env, |
| 108 jint list_index) { | 109 const JavaParamRef<jobject>& obj, |
| 110 jint list_index) { |
| 109 if (!controller_) | 111 if (!controller_) |
| 110 return; | 112 return; |
| 111 | 113 |
| 112 base::string16 confirmation_title, confirmation_body; | 114 base::string16 confirmation_title, confirmation_body; |
| 113 if (!controller_->GetRemovalConfirmationText(list_index, &confirmation_title, | 115 if (!controller_->GetRemovalConfirmationText(list_index, &confirmation_title, |
| 114 &confirmation_body)) { | 116 &confirmation_body)) { |
| 115 return; | 117 return; |
| 116 } | 118 } |
| 117 | 119 |
| 118 deleting_index_ = list_index; | 120 deleting_index_ = list_index; |
| 119 Java_AutofillPopupBridge_confirmDeletion( | 121 Java_AutofillPopupBridge_confirmDeletion( |
| 120 env, | 122 env, |
| 121 java_object_.obj(), | 123 java_object_.obj(), |
| 122 base::android::ConvertUTF16ToJavaString( | 124 base::android::ConvertUTF16ToJavaString( |
| 123 env, confirmation_title).obj(), | 125 env, confirmation_title).obj(), |
| 124 base::android::ConvertUTF16ToJavaString( | 126 base::android::ConvertUTF16ToJavaString( |
| 125 env, confirmation_body).obj()); | 127 env, confirmation_body).obj()); |
| 126 } | 128 } |
| 127 | 129 |
| 128 void AutofillPopupViewAndroid::DeletionConfirmed(JNIEnv* env, | 130 void AutofillPopupViewAndroid::DeletionConfirmed( |
| 129 jobject obj) { | 131 JNIEnv* env, |
| 132 const JavaParamRef<jobject>& obj) { |
| 130 if (!controller_) | 133 if (!controller_) |
| 131 return; | 134 return; |
| 132 | 135 |
| 133 CHECK_GE(deleting_index_, 0); | 136 CHECK_GE(deleting_index_, 0); |
| 134 controller_->RemoveSuggestion(deleting_index_); | 137 controller_->RemoveSuggestion(deleting_index_); |
| 135 } | 138 } |
| 136 | 139 |
| 137 void AutofillPopupViewAndroid::PopupDismissed(JNIEnv* env, jobject obj) { | 140 void AutofillPopupViewAndroid::PopupDismissed( |
| 141 JNIEnv* env, |
| 142 const JavaParamRef<jobject>& obj) { |
| 138 if (controller_) | 143 if (controller_) |
| 139 controller_->ViewDestroyed(); | 144 controller_->ViewDestroyed(); |
| 140 | 145 |
| 141 delete this; | 146 delete this; |
| 142 } | 147 } |
| 143 | 148 |
| 144 void AutofillPopupViewAndroid::InvalidateRow(size_t) {} | 149 void AutofillPopupViewAndroid::InvalidateRow(size_t) {} |
| 145 | 150 |
| 146 // static | 151 // static |
| 147 bool AutofillPopupViewAndroid::RegisterAutofillPopupViewAndroid(JNIEnv* env) { | 152 bool AutofillPopupViewAndroid::RegisterAutofillPopupViewAndroid(JNIEnv* env) { |
| 148 return RegisterNativesImpl(env); | 153 return RegisterNativesImpl(env); |
| 149 } | 154 } |
| 150 | 155 |
| 151 // static | 156 // static |
| 152 AutofillPopupView* AutofillPopupView::Create( | 157 AutofillPopupView* AutofillPopupView::Create( |
| 153 AutofillPopupController* controller) { | 158 AutofillPopupController* controller) { |
| 154 if (IsKeyboardAccessoryEnabled()) | 159 if (IsKeyboardAccessoryEnabled()) |
| 155 return new AutofillKeyboardAccessoryView(controller); | 160 return new AutofillKeyboardAccessoryView(controller); |
| 156 | 161 |
| 157 return new AutofillPopupViewAndroid(controller); | 162 return new AutofillPopupViewAndroid(controller); |
| 158 } | 163 } |
| 159 | 164 |
| 160 } // namespace autofill | 165 } // namespace autofill |
| OLD | NEW |