OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_dialog_view_android.h" | 5 #include "chrome/browser/ui/android/autofill/autofill_dialog_view_android.h" |
6 #include "base/android/jni_android.h" | 6 #include "base/android/jni_android.h" |
7 #include "base/android/jni_array.h" | 7 #include "base/android/jni_array.h" |
8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
9 #include "base/android/scoped_java_ref.h" | 9 #include "base/android/scoped_java_ref.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 | 342 |
343 controller_->EditClickedForSection(section); | 343 controller_->EditClickedForSection(section); |
344 UpdateOrFillSectionToJava(section, false, UNKNOWN_TYPE); | 344 UpdateOrFillSectionToJava(section, false, UNKNOWN_TYPE); |
345 } | 345 } |
346 | 346 |
347 jboolean AutofillDialogViewAndroid::EditingComplete(JNIEnv* env, | 347 jboolean AutofillDialogViewAndroid::EditingComplete(JNIEnv* env, |
348 jobject obj, | 348 jobject obj, |
349 jint jsection) { | 349 jint jsection) { |
350 // Unfortunately, edits are not sent to the models, http://crbug.com/223919. | 350 // Unfortunately, edits are not sent to the models, http://crbug.com/223919. |
351 const DialogSection section = static_cast<DialogSection>(jsection); | 351 const DialogSection section = static_cast<DialogSection>(jsection); |
352 if (ValidateSection(section, AutofillDialogController::VALIDATE_FINAL)) { | 352 if (ValidateSection(section, VALIDATE_FINAL)) { |
353 UpdateOrFillSectionToJava(section, false, UNKNOWN_TYPE); | 353 UpdateOrFillSectionToJava(section, false, UNKNOWN_TYPE); |
354 return true; | 354 return true; |
355 } | 355 } |
356 | 356 |
357 return false; | 357 return false; |
358 } | 358 } |
359 | 359 |
360 void AutofillDialogViewAndroid::EditingCancel(JNIEnv* env, | 360 void AutofillDialogViewAndroid::EditingCancel(JNIEnv* env, |
361 jobject obj, | 361 jobject obj, |
362 jint jsection) { | 362 jint jsection) { |
(...skipping 26 matching lines...) Expand all Loading... |
389 string16 error_message = | 389 string16 error_message = |
390 controller_->InputValidityMessage(field_type, field_value); | 390 controller_->InputValidityMessage(field_type, field_value); |
391 ScopedJavaLocalRef<jstring> error_text = | 391 ScopedJavaLocalRef<jstring> error_text = |
392 base::android::ConvertUTF16ToJavaString(env, error_message); | 392 base::android::ConvertUTF16ToJavaString(env, error_message); |
393 return error_text; | 393 return error_text; |
394 } | 394 } |
395 | 395 |
396 void AutofillDialogViewAndroid::ValidateSection(JNIEnv* env, | 396 void AutofillDialogViewAndroid::ValidateSection(JNIEnv* env, |
397 jobject obj, | 397 jobject obj, |
398 jint section) { | 398 jint section) { |
399 ValidateSection(static_cast<DialogSection>(section), | 399 ValidateSection(static_cast<DialogSection>(section), VALIDATE_EDIT); |
400 AutofillDialogController::VALIDATE_EDIT); | |
401 } | 400 } |
402 | 401 |
403 void AutofillDialogViewAndroid::DialogSubmit(JNIEnv* env, jobject obj) { | 402 void AutofillDialogViewAndroid::DialogSubmit(JNIEnv* env, jobject obj) { |
404 // TODO(aurimas): add validation step. | 403 // TODO(aurimas): add validation step. |
405 controller_->OnAccept(); | 404 controller_->OnAccept(); |
406 } | 405 } |
407 | 406 |
408 void AutofillDialogViewAndroid::DialogCancel(JNIEnv* env, jobject obj) { | 407 void AutofillDialogViewAndroid::DialogCancel(JNIEnv* env, jobject obj) { |
409 controller_->OnCancel(); | 408 controller_->OnCancel(); |
410 Hide(); | 409 Hide(); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 base::android::ConvertJavaStringToUTF8(env, jlsid); | 450 base::android::ConvertJavaStringToUTF8(env, jlsid); |
452 // TODO(aruslan): bind to the automatic sign-in. | 451 // TODO(aruslan): bind to the automatic sign-in. |
453 // controller_->ContinueAutomaticSignIn(account_name, sid, lsid); | 452 // controller_->ContinueAutomaticSignIn(account_name, sid, lsid); |
454 } | 453 } |
455 | 454 |
456 // static | 455 // static |
457 bool AutofillDialogViewAndroid::RegisterAutofillDialogViewAndroid(JNIEnv* env) { | 456 bool AutofillDialogViewAndroid::RegisterAutofillDialogViewAndroid(JNIEnv* env) { |
458 return RegisterNativesImpl(env); | 457 return RegisterNativesImpl(env); |
459 } | 458 } |
460 | 459 |
461 bool AutofillDialogViewAndroid::ValidateSection( | 460 bool AutofillDialogViewAndroid::ValidateSection(DialogSection section, |
462 DialogSection section, AutofillDialogController::ValidationType type) { | 461 ValidationType type) { |
463 DetailOutputMap detail_outputs; | 462 DetailOutputMap detail_outputs; |
464 GetUserInput(section, &detail_outputs); | 463 GetUserInput(section, &detail_outputs); |
465 ValidityData invalid_inputs = | 464 ValidityData invalid_inputs = |
466 controller_->InputsAreValid(detail_outputs, type); | 465 controller_->InputsAreValid(detail_outputs, type); |
467 | 466 |
468 const size_t item_count = invalid_inputs.size(); | 467 const size_t item_count = invalid_inputs.size(); |
469 if (item_count == 0) return true; | 468 if (item_count == 0) return true; |
470 | 469 |
471 JNIEnv* env = base::android::AttachCurrentThread(); | 470 JNIEnv* env = base::android::AttachCurrentThread(); |
472 ScopedJavaLocalRef<jobjectArray> error_array = | 471 ScopedJavaLocalRef<jobjectArray> error_array = |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
848 | 847 |
849 if (label.empty()) | 848 if (label.empty()) |
850 return false; | 849 return false; |
851 | 850 |
852 *label_to_set = label; | 851 *label_to_set = label; |
853 *sublabel_to_set = sublabel; | 852 *sublabel_to_set = sublabel; |
854 *icon_to_set = icon; | 853 *icon_to_set = icon; |
855 return true; | 854 return true; |
856 } | 855 } |
857 } // namespace autofill | 856 } // namespace autofill |
OLD | NEW |