diff options
author | garykac@chromium.org <garykac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-10 19:50:44 +0000 |
---|---|---|
committer | garykac@chromium.org <garykac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-10 19:50:44 +0000 |
commit | 8f5f978d5b5b5473a04e065c02f33f4cb88407f4 (patch) | |
tree | 438fcbcb12207874ef80300eb45b95f271f2b1df | |
parent | 0836da0963a43e9abd8dae4bcadbec05e570cb96 (diff) | |
download | chromium_src-8f5f978d5b5b5473a04e065c02f33f4cb88407f4.zip chromium_src-8f5f978d5b5b5473a04e065c02f33f4cb88407f4.tar.gz chromium_src-8f5f978d5b5b5473a04e065c02f33f4cb88407f4.tar.bz2 |
Revert 205265 "payments dialog: remove edit links from Views UI"
Breaks Mac compile:
../../chrome/browser/ui/cocoa/autofill/autofill_section_container.mm:329:50: error: no member named 'editable' in 'autofill::SuggestionState'
[suggestContainer_ setEditable:suggestionState.editable];
~~~~~~~~~~~~~~~ ^
> payments dialog: remove edit links from Views UI
>
> BUG=245901
> R=aruslan@chromium.org, dbeam@chromium.org
>
> Review URL: https://codereview.chromium.org/16521002
TBR=estade@chromium.org
Review URL: https://codereview.chromium.org/16751002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@205279 0039d316-1c4b-4281-b951-d872f2087c98
11 files changed, 82 insertions, 15 deletions
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialog.java b/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialog.java index 61f2e7c..a7c9305 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialog.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialog.java @@ -525,6 +525,7 @@ public class AutofillDialog extends Dialog * @param suggestionIcon The suggestion icon. * @param suggestionTextExtra The suggestion text extra. * @param suggestionIconExtra The suggestion icon extra. + * @param suggestionSectionEditable Whether the section is editable. * @param menuItems The array that contains the dropdown items to be shown for the section. * @param selectedMenuItem The menu item that is currently selected or -1 otherwise. * @param clobberInputs Whether to clobber the user input. @@ -532,9 +533,10 @@ public class AutofillDialog extends Dialog */ public void updateSection(int section, boolean visible, AutofillDialogField[] dialogInputs, String suggestionText, Bitmap suggestionIcon, String suggestionTextExtra, - Bitmap suggestionIconExtra, AutofillDialogMenuItem[] menuItems, - int selectedMenuItem, boolean clobberInputs, - int fieldTypeToAlwaysClobber) { + Bitmap suggestionIconExtra, boolean suggestionSectionEditable, + AutofillDialogMenuItem[] menuItems, + int selectedMenuItem, boolean clobberInputs, + int fieldTypeToAlwaysClobber) { View currentField; String inputValue; @@ -580,7 +582,7 @@ public class AutofillDialog extends Dialog updateSectionMenuItems(section, suggestionText, suggestionIcon, suggestionTextExtra, suggestionIconExtra, - menuItems, selectedMenuItem); + suggestionSectionEditable, menuItems, selectedMenuItem); } /** @@ -590,16 +592,18 @@ public class AutofillDialog extends Dialog * @param suggestionIcon The suggestion icon. * @param suggestionTextExtra The suggestion text extra. * @param suggestionIconExtra The suggestion icon extra. + * @param suggestionSectionEditable Whether the section is editable. * @param menuItems The array that contains the dropdown items to be shown for the section. * @param selectedMenuItem The menu item that is currently selected or -1 otherwise. */ public void updateSectionMenuItems( int section, String suggestionText, Bitmap suggestionIcon, String suggestionTextExtra, - Bitmap suggestionIconExtra, AutofillDialogMenuItem[] menuItems, - int selectedMenuItem) { + Bitmap suggestionIconExtra, boolean suggestionSectionEditable, + AutofillDialogMenuItem[] menuItems, int selectedMenuItem) { mView.updateMenuItemsForSection( - section, suggestionText, suggestionIcon, suggestionTextExtra, suggestionIconExtra, - Arrays.asList(menuItems), selectedMenuItem); + section, suggestionText, suggestionIcon, suggestionTextExtra, + suggestionIconExtra, suggestionSectionEditable, + Arrays.asList(menuItems), selectedMenuItem); } /** diff --git a/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialogGlue.java b/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialogGlue.java index 84bd03f..373355d 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialogGlue.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialogGlue.java @@ -70,19 +70,21 @@ public class AutofillDialogGlue implements AutofillDialogDelegate, /** * @see AutofillDialog#updateSection(int, boolean, AutofillDialogField[], - * String, Bitmap, String, Bitmap, + * String, Bitmap, String, Bitmap, boolean, * AutofillDialogMenuItem[], int, boolean, int) */ @CalledByNative private void updateSection(int section, boolean visible, AutofillDialogField[] dialogInputs, String suggestionText, Bitmap suggestionIcon, String suggestionTextExtra, Bitmap suggestionIconExtra, + boolean suggestionSectionEditable, AutofillDialogMenuItem[] menuItems, int selectedMenuItem, boolean clobberInputs, int fieldTypeToAlwaysClobber) { mAutofillDialog.updateSection( section, visible, dialogInputs, suggestionText, suggestionIcon, suggestionTextExtra, suggestionIconExtra, + suggestionSectionEditable, menuItems, selectedMenuItem, clobberInputs, fieldTypeToAlwaysClobber); } diff --git a/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialogView.java b/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialogView.java index e3751da..be04712 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialogView.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialogView.java @@ -412,12 +412,14 @@ public class AutofillDialogView extends FrameLayout { * @param suggestionIcon The suggestion icon. * @param suggestionTextExtra The suggestion text extra. * @param suggestionIconExtra The suggestion icon extra. + * @param suggestionSectionEditable Whether the section is editable. * @param items The {@link AutofillDialogMenuItem} array to update the dropdown with. * @param selectedMenuItem The index of the selected menu item, or -1. */ public void updateMenuItemsForSection(int section, String suggestionText, Bitmap suggestionIcon, String suggestionTextExtra, Bitmap suggestionIconExtra, + boolean suggestionSectionEditable, List<AutofillDialogMenuItem> items, final int selectedMenuItem) { final Spinner spinner = mSpinners[section]; // Set the listener to null and reset it after updating the menu items to avoid getting an diff --git a/chrome/browser/ui/android/autofill/autofill_dialog_view_android.cc b/chrome/browser/ui/android/autofill/autofill_dialog_view_android.cc index ef1a361..72deb9f 100644 --- a/chrome/browser/ui/android/autofill/autofill_dialog_view_android.cc +++ b/chrome/browser/ui/android/autofill/autofill_dialog_view_android.cc @@ -583,6 +583,7 @@ void AutofillDialogViewAndroid::UpdateOrFillSectionToJava( suggestion_icon.obj(), suggestion_text_extra.obj(), suggestion_icon_extra.obj(), + suggestion_state.editable, menu_array.obj(), selected_item, clobber_inputs, diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc index 55bf0f3..935b041 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc @@ -931,7 +931,8 @@ SuggestionState AutofillDialogControllerImpl::SuggestionStateForSection( SuggestionTextStyleForSection(section), SuggestionIconForSection(section), ExtraSuggestionTextForSection(section), - ExtraSuggestionIconForSection(section)); + ExtraSuggestionIconForSection(section), + EditEnabledForSection(section)); } string16 AutofillDialogControllerImpl::SuggestionTextForSection( @@ -1106,6 +1107,19 @@ gfx::Image AutofillDialogControllerImpl::ExtraSuggestionIconForSection( return gfx::Image(); } +bool AutofillDialogControllerImpl::EditEnabledForSection( + DialogSection section) const { + if (SuggestionsMenuModelForSection(section)->GetItemKeyForCheckedItem() == + kSameAsBillingKey) { + return false; + } + + if (section == SECTION_CC_BILLING && IsSubmitPausedOn(wallet::VERIFY_CVV)) + return false; + + return true; +} + void AutofillDialogControllerImpl::EditClickedForSection( DialogSection section) { scoped_ptr<DataModelWrapper> model = CreateWrapper(section); diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h index e9f481c..9ddd9ea 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h @@ -370,6 +370,9 @@ class AutofillDialogControllerImpl : public AutofillDialogController, string16 ExtraSuggestionTextForSection(DialogSection section) const; gfx::Image ExtraSuggestionIconForSection(DialogSection section) const; + // Whether |section| should be showing an "Edit" link. + bool EditEnabledForSection(DialogSection section) const; + // Loads profiles that can suggest data for |type|. |field_contents| is the // part the user has already typed. |inputs| is the rest of section. // Identifying info is loaded into the last three outparams as well as diff --git a/chrome/browser/ui/autofill/autofill_dialog_types.cc b/chrome/browser/ui/autofill/autofill_dialog_types.cc index a70209d..8e35efc 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_types.cc +++ b/chrome/browser/ui/autofill/autofill_dialog_types.cc @@ -75,12 +75,14 @@ SuggestionState::SuggestionState(const string16& text, gfx::Font::FontStyle text_style, const gfx::Image& icon, const string16& extra_text, - const gfx::Image& extra_icon) + const gfx::Image& extra_icon, + bool editable) : text(text), text_style(text_style), icon(icon), extra_text(extra_text), - extra_icon(extra_icon) {} + extra_icon(extra_icon), + editable(editable) {} SuggestionState::~SuggestionState() {} AutofillMetrics::DialogUiEvent DialogSectionToUiEditEvent( diff --git a/chrome/browser/ui/autofill/autofill_dialog_types.h b/chrome/browser/ui/autofill/autofill_dialog_types.h index 62129a0..d3db1c3 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_types.h +++ b/chrome/browser/ui/autofill/autofill_dialog_types.h @@ -142,13 +142,15 @@ struct SuggestionState { gfx::Font::FontStyle text_style, const gfx::Image& icon, const string16& extra_text, - const gfx::Image& extra_icon); + const gfx::Image& extra_icon, + bool editable); ~SuggestionState(); string16 text; gfx::Font::FontStyle text_style; gfx::Image icon; string16 extra_text; gfx::Image extra_icon; + bool editable; }; enum ValidationType { diff --git a/chrome/browser/ui/autofill/mock_autofill_dialog_controller.cc b/chrome/browser/ui/autofill/mock_autofill_dialog_controller.cc index 8131283..4d5d0ba 100644 --- a/chrome/browser/ui/autofill/mock_autofill_dialog_controller.cc +++ b/chrome/browser/ui/autofill/mock_autofill_dialog_controller.cc @@ -107,7 +107,8 @@ SuggestionState MockAutofillDialogController::SuggestionStateForSection( gfx::Font::NORMAL, gfx::Image(), string16(), - gfx::Image()); + gfx::Image(), + false); } void MockAutofillDialogController::EditClickedForSection( diff --git a/chrome/browser/ui/views/autofill/autofill_dialog_views.cc b/chrome/browser/ui/views/autofill/autofill_dialog_views.cc index f564e4a..2a8055e 100644 --- a/chrome/browser/ui/views/autofill/autofill_dialog_views.cc +++ b/chrome/browser/ui/views/autofill/autofill_dialog_views.cc @@ -710,7 +710,8 @@ AutofillDialogViews::SuggestionView::SuggestionView( icon_(new views::ImageView()), label_container_(new SectionRowView()), decorated_( - new DecoratedTextfield(string16(), string16(), autofill_dialog)) { + new DecoratedTextfield(string16(), string16(), autofill_dialog)), + edit_link_(new views::Link(edit_label)) { // Label and icon. label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); label_->set_border(CreateLabelAlignmentBorder()); @@ -726,11 +727,27 @@ AutofillDialogViews::SuggestionView::SuggestionView( label_line_2_->SetVisible(false); AddChildView(label_line_2_); + // TODO(estade): The link needs to have a different color when hovered. + edit_link_->set_listener(autofill_dialog); + edit_link_->SetHorizontalAlignment(gfx::ALIGN_LEFT); + edit_link_->SetUnderline(false); + + // This container prevents the edit link from being horizontally stretched. + views::View* link_container = new views::View(); + link_container->SetLayoutManager( + new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); + link_container->AddChildView(edit_link_); + AddChildView(link_container); + SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); } AutofillDialogViews::SuggestionView::~SuggestionView() {} +void AutofillDialogViews::SuggestionView::SetEditable(bool editable) { + edit_link_->SetVisible(editable); +} + void AutofillDialogViews::SuggestionView::SetSuggestionText( const string16& text, gfx::Font::FontStyle text_style) { @@ -1251,6 +1268,17 @@ void AutofillDialogViews::OnDidChangeFocus( ShowErrorBubbleForViewIfNecessary(focused_now); } +void AutofillDialogViews::LinkClicked(views::Link* source, int event_flags) { + // Edit links. + for (DetailGroupMap::iterator iter = detail_groups_.begin(); + iter != detail_groups_.end(); ++iter) { + if (iter->second.suggested_info->Contains(source)) { + controller_->EditClickedForSection(iter->first); + return; + } + } +} + void AutofillDialogViews::OnSelectedIndexChanged(views::Combobox* combobox) { DetailsGroup* group = GroupForView(combobox); ValidateGroup(*group, VALIDATE_EDIT); @@ -1524,6 +1552,7 @@ void AutofillDialogViews::UpdateDetailsGroupState(const DetailsGroup& group) { group.suggested_info->SetSuggestionText(suggestion_state.text, suggestion_state.text_style); group.suggested_info->SetSuggestionIcon(suggestion_state.icon); + group.suggested_info->SetEditable(suggestion_state.editable); if (!suggestion_state.extra_text.empty()) { group.suggested_info->ShowTextfield( diff --git a/chrome/browser/ui/views/autofill/autofill_dialog_views.h b/chrome/browser/ui/views/autofill/autofill_dialog_views.h index 5387e7c..e3984df 100644 --- a/chrome/browser/ui/views/autofill/autofill_dialog_views.h +++ b/chrome/browser/ui/views/autofill/autofill_dialog_views.h @@ -67,6 +67,7 @@ class AutofillDialogViews : public AutofillDialogView, public views::ButtonListener, public views::TextfieldController, public views::FocusChangeListener, + public views::LinkListener, public views::ComboboxListener, public views::StyledLabelListener, public ui::AcceleratorTarget { @@ -149,6 +150,9 @@ class AutofillDialogViews : public AutofillDialogView, virtual void OnDidChangeFocus(views::View* focused_before, views::View* focused_now) OVERRIDE; + // views::LinkListener implementation: + virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; + // views::ComboboxListener implementation: virtual void OnSelectedIndexChanged(views::Combobox* combobox) OVERRIDE; @@ -368,6 +372,9 @@ class AutofillDialogViews : public AutofillDialogView, AutofillDialogViews* autofill_dialog); virtual ~SuggestionView(); + // Whether this section is editable or not. + void SetEditable(bool editable); + // Sets the display text of the suggestion. void SetSuggestionText(const string16& text, gfx::Font::FontStyle style); |