| OLD | NEW | 
|    1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |    1 // Copyright (c) 2015 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_keyboard_accessory_view.h" |    5 #include "chrome/browser/ui/android/autofill/autofill_keyboard_accessory_view.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/android/resource_mapper.h" | 
|   10 #include "chrome/browser/ui/android/window_android_helper.h" |   10 #include "chrome/browser/ui/android/window_android_helper.h" | 
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  103       AddToJavaArray(suggestion, *controller_, env, data_array.obj(), position, |  103       AddToJavaArray(suggestion, *controller_, env, data_array.obj(), position, | 
|  104                      deletable); |  104                      deletable); | 
|  105       positions_[position++] = i; |  105       positions_[position++] = i; | 
|  106     } |  106     } | 
|  107   } |  107   } | 
|  108  |  108  | 
|  109   Java_AutofillKeyboardAccessoryBridge_show( |  109   Java_AutofillKeyboardAccessoryBridge_show( | 
|  110       env, java_object_.obj(), data_array.obj(), controller_->IsRTL()); |  110       env, java_object_.obj(), data_array.obj(), controller_->IsRTL()); | 
|  111 } |  111 } | 
|  112  |  112  | 
|  113 void AutofillKeyboardAccessoryView::SuggestionSelected(JNIEnv* env, |  113 void AutofillKeyboardAccessoryView::SuggestionSelected( | 
|  114                                                        jobject obj, |  114     JNIEnv* env, | 
|  115                                                        jint list_index) { |  115     const JavaParamRef<jobject>& obj, | 
 |  116     jint list_index) { | 
|  116   // Race: Hide() may have already run. |  117   // Race: Hide() may have already run. | 
|  117   if (controller_) |  118   if (controller_) | 
|  118     controller_->AcceptSuggestion(positions_[list_index]); |  119     controller_->AcceptSuggestion(positions_[list_index]); | 
|  119 } |  120 } | 
|  120  |  121  | 
|  121 void AutofillKeyboardAccessoryView::DeletionRequested(JNIEnv* env, |  122 void AutofillKeyboardAccessoryView::DeletionRequested( | 
|  122                                                       jobject obj, |  123     JNIEnv* env, | 
|  123                                                       jint list_index) { |  124     const JavaParamRef<jobject>& obj, | 
 |  125     jint list_index) { | 
|  124   if (!controller_) |  126   if (!controller_) | 
|  125     return; |  127     return; | 
|  126  |  128  | 
|  127   base::string16 confirmation_title, confirmation_body; |  129   base::string16 confirmation_title, confirmation_body; | 
|  128   if (!controller_->GetRemovalConfirmationText( |  130   if (!controller_->GetRemovalConfirmationText( | 
|  129           positions_[list_index], &confirmation_title, &confirmation_body)) { |  131           positions_[list_index], &confirmation_title, &confirmation_body)) { | 
|  130     return; |  132     return; | 
|  131   } |  133   } | 
|  132  |  134  | 
|  133   deleting_index_ = positions_[list_index]; |  135   deleting_index_ = positions_[list_index]; | 
|  134   Java_AutofillKeyboardAccessoryBridge_confirmDeletion( |  136   Java_AutofillKeyboardAccessoryBridge_confirmDeletion( | 
|  135       env, java_object_.obj(), |  137       env, java_object_.obj(), | 
|  136       base::android::ConvertUTF16ToJavaString(env, confirmation_title).obj(), |  138       base::android::ConvertUTF16ToJavaString(env, confirmation_title).obj(), | 
|  137       base::android::ConvertUTF16ToJavaString(env, confirmation_body).obj()); |  139       base::android::ConvertUTF16ToJavaString(env, confirmation_body).obj()); | 
|  138 } |  140 } | 
|  139  |  141  | 
|  140 void AutofillKeyboardAccessoryView::DeletionConfirmed(JNIEnv* env, |  142 void AutofillKeyboardAccessoryView::DeletionConfirmed( | 
|  141                                                       jobject obj) { |  143     JNIEnv* env, | 
 |  144     const JavaParamRef<jobject>& obj) { | 
|  142   if (!controller_) |  145   if (!controller_) | 
|  143     return; |  146     return; | 
|  144  |  147  | 
|  145   CHECK_GE(deleting_index_, 0); |  148   CHECK_GE(deleting_index_, 0); | 
|  146   controller_->RemoveSuggestion(deleting_index_); |  149   controller_->RemoveSuggestion(deleting_index_); | 
|  147 } |  150 } | 
|  148  |  151  | 
|  149 void AutofillKeyboardAccessoryView::ViewDismissed(JNIEnv* env, jobject obj) { |  152 void AutofillKeyboardAccessoryView::ViewDismissed( | 
 |  153     JNIEnv* env, | 
 |  154     const JavaParamRef<jobject>& obj) { | 
|  150   if (controller_) |  155   if (controller_) | 
|  151     controller_->ViewDestroyed(); |  156     controller_->ViewDestroyed(); | 
|  152  |  157  | 
|  153   delete this; |  158   delete this; | 
|  154 } |  159 } | 
|  155  |  160  | 
|  156 void AutofillKeyboardAccessoryView::InvalidateRow(size_t) { |  161 void AutofillKeyboardAccessoryView::InvalidateRow(size_t) { | 
|  157 } |  162 } | 
|  158  |  163  | 
|  159 // static |  164 // static | 
|  160 bool AutofillKeyboardAccessoryView::RegisterAutofillKeyboardAccessoryView( |  165 bool AutofillKeyboardAccessoryView::RegisterAutofillKeyboardAccessoryView( | 
|  161     JNIEnv* env) { |  166     JNIEnv* env) { | 
|  162   return RegisterNativesImpl(env); |  167   return RegisterNativesImpl(env); | 
|  163 } |  168 } | 
|  164  |  169  | 
|  165 }  // namespace autofill |  170 }  // namespace autofill | 
| OLD | NEW |