| 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 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 static_cast<DialogNotification::Type>(type), | 333 static_cast<DialogNotification::Type>(type), |
| 334 static_cast<bool>(checked)); | 334 static_cast<bool>(checked)); |
| 335 } | 335 } |
| 336 | 336 |
| 337 void AutofillDialogViewAndroid::EditingStart(JNIEnv* env, jobject obj, | 337 void AutofillDialogViewAndroid::EditingStart(JNIEnv* env, jobject obj, |
| 338 jint jsection) { | 338 jint jsection) { |
| 339 const DialogSection section = static_cast<DialogSection>(jsection); | 339 const DialogSection section = static_cast<DialogSection>(jsection); |
| 340 // TODO(estade): respect |suggestion_state.text_style|. | 340 // TODO(estade): respect |suggestion_state.text_style|. |
| 341 const SuggestionState& suggestion_state = | 341 const SuggestionState& suggestion_state = |
| 342 controller_->SuggestionStateForSection(section); | 342 controller_->SuggestionStateForSection(section); |
| 343 if (suggestion_state.text.empty()) { | 343 if (!suggestion_state.show) { |
| 344 // The section is already in the editing mode, or it's the "Add...". | 344 // The section is already in the editing mode, or it's the "Add...". |
| 345 return; | 345 return; |
| 346 } | 346 } |
| 347 | 347 |
| 348 controller_->EditClickedForSection(section); | 348 controller_->EditClickedForSection(section); |
| 349 UpdateOrFillSectionToJava(section, false, UNKNOWN_TYPE); | 349 UpdateOrFillSectionToJava(section, false, UNKNOWN_TYPE); |
| 350 } | 350 } |
| 351 | 351 |
| 352 jboolean AutofillDialogViewAndroid::EditingComplete(JNIEnv* env, | 352 jboolean AutofillDialogViewAndroid::EditingComplete(JNIEnv* env, |
| 353 jobject obj, | 353 jobject obj, |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 ScopedJavaLocalRef<jobject> icon = GetJavaBitmap(icon_value); | 568 ScopedJavaLocalRef<jobject> icon = GetJavaBitmap(icon_value); |
| 569 | 569 |
| 570 Java_AutofillDialogGlue_addToAutofillDialogMenuItemArray( | 570 Java_AutofillDialogGlue_addToAutofillDialogMenuItemArray( |
| 571 env, menu_array.obj(), i, | 571 env, menu_array.obj(), i, |
| 572 line1.obj(), line2.obj(), icon.obj(), | 572 line1.obj(), line2.obj(), icon.obj(), |
| 573 static_cast<int>(button_type)); | 573 static_cast<int>(button_type)); |
| 574 } | 574 } |
| 575 | 575 |
| 576 const SuggestionState& suggestion_state = | 576 const SuggestionState& suggestion_state = |
| 577 controller_->SuggestionStateForSection(section); | 577 controller_->SuggestionStateForSection(section); |
| 578 // TODO(estade): also make use of |horizontally_compact_text|. |
| 578 ScopedJavaLocalRef<jstring> suggestion_text = | 579 ScopedJavaLocalRef<jstring> suggestion_text = |
| 579 base::android::ConvertUTF16ToJavaString(env, suggestion_state.text); | 580 base::android::ConvertUTF16ToJavaString( |
| 581 env, suggestion_state.vertically_compact_text); |
| 580 ScopedJavaLocalRef<jstring> suggestion_text_extra = | 582 ScopedJavaLocalRef<jstring> suggestion_text_extra = |
| 581 base::android::ConvertUTF16ToJavaString(env, suggestion_state.extra_text); | 583 base::android::ConvertUTF16ToJavaString(env, suggestion_state.extra_text); |
| 582 ScopedJavaLocalRef<jobject> suggestion_icon = | 584 ScopedJavaLocalRef<jobject> suggestion_icon = |
| 583 GetJavaBitmap(suggestion_state.icon); | 585 GetJavaBitmap(suggestion_state.icon); |
| 584 ScopedJavaLocalRef<jobject> suggestion_icon_extra = | 586 ScopedJavaLocalRef<jobject> suggestion_icon_extra = |
| 585 GetJavaBitmap(suggestion_state.extra_icon); | 587 GetJavaBitmap(suggestion_state.extra_icon); |
| 586 | 588 |
| 587 Java_AutofillDialogGlue_updateSection(env, | 589 Java_AutofillDialogGlue_updateSection(env, |
| 588 java_object_.obj(), | 590 java_object_.obj(), |
| 589 section, | 591 section, |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 // Returns true and fills in the |label|, |sublabel| and |icon if | 789 // Returns true and fills in the |label|, |sublabel| and |icon if |
| 788 // a given |section| has the user input. | 790 // a given |section| has the user input. |
| 789 // TODO(aruslan): Remove/fix this once http://crbug.com/230685 is closed. | 791 // TODO(aruslan): Remove/fix this once http://crbug.com/230685 is closed. |
| 790 bool AutofillDialogViewAndroid::CollapseUserDataIntoMenuItem( | 792 bool AutofillDialogViewAndroid::CollapseUserDataIntoMenuItem( |
| 791 DialogSection section, | 793 DialogSection section, |
| 792 string16* label_to_set, | 794 string16* label_to_set, |
| 793 string16* sublabel_to_set, | 795 string16* sublabel_to_set, |
| 794 gfx::Image* icon_to_set) const { | 796 gfx::Image* icon_to_set) const { |
| 795 const SuggestionState& suggestion_state = | 797 const SuggestionState& suggestion_state = |
| 796 controller_->SuggestionStateForSection(section); | 798 controller_->SuggestionStateForSection(section); |
| 797 if (!suggestion_state.text.empty()) | 799 if (suggestion_state.show) |
| 798 return false; | 800 return false; |
| 799 | 801 |
| 800 DetailOutputMap inputs; | 802 DetailOutputMap inputs; |
| 801 GetUserInputImpl(section, &inputs); | 803 GetUserInputImpl(section, &inputs); |
| 802 | 804 |
| 803 string16 label; | 805 string16 label; |
| 804 string16 sublabel; | 806 string16 sublabel; |
| 805 gfx::Image icon; | 807 gfx::Image icon; |
| 806 | 808 |
| 807 switch (section) { | 809 switch (section) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 822 sublabel = pw.GetSublabel(); | 824 sublabel = pw.GetSublabel(); |
| 823 break; | 825 break; |
| 824 } | 826 } |
| 825 | 827 |
| 826 case SECTION_CC_BILLING: { | 828 case SECTION_CC_BILLING: { |
| 827 CreditCard card; | 829 CreditCard card; |
| 828 AutofillProfile profile; | 830 AutofillProfile profile; |
| 829 GetBillingInfoFromOutputs(inputs, &card, &profile); | 831 GetBillingInfoFromOutputs(inputs, &card, &profile); |
| 830 AutofillCreditCardWrapper ccw(&card); | 832 AutofillCreditCardWrapper ccw(&card); |
| 831 CollapsedAutofillProfileWrapper pw(&profile); | 833 CollapsedAutofillProfileWrapper pw(&profile); |
| 832 label = ccw.GetDisplayText(); | 834 base::string16 unused; |
| 835 ccw.GetDisplayText(&label, &unused); |
| 833 sublabel = pw.GetDisplayText(); | 836 sublabel = pw.GetDisplayText(); |
| 834 icon = ccw.GetIcon(); | 837 icon = ccw.GetIcon(); |
| 835 break; | 838 break; |
| 836 } | 839 } |
| 837 | 840 |
| 838 case SECTION_SHIPPING: { | 841 case SECTION_SHIPPING: { |
| 839 AutofillProfile profile; | 842 AutofillProfile profile; |
| 840 GetBillingInfoFromOutputs(inputs, NULL, &profile); | 843 GetBillingInfoFromOutputs(inputs, NULL, &profile); |
| 841 CollapsedAutofillProfileWrapper pw(&profile); | 844 CollapsedAutofillProfileWrapper pw(&profile); |
| 842 label = pw.GetDisplayText(); | 845 label = pw.GetDisplayText(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 856 | 859 |
| 857 if (label.empty()) | 860 if (label.empty()) |
| 858 return false; | 861 return false; |
| 859 | 862 |
| 860 *label_to_set = label; | 863 *label_to_set = label; |
| 861 *sublabel_to_set = sublabel; | 864 *sublabel_to_set = sublabel; |
| 862 *icon_to_set = icon; | 865 *icon_to_set = icon; |
| 863 return true; | 866 return true; |
| 864 } | 867 } |
| 865 } // namespace autofill | 868 } // namespace autofill |
| OLD | NEW |