| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/autofill/autofill_dialog_controller_impl.h" | 5 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 case ADDRESS_HOME_COUNTRY: | 680 case ADDRESS_HOME_COUNTRY: |
| 681 return &country_combobox_model_; | 681 return &country_combobox_model_; |
| 682 | 682 |
| 683 default: | 683 default: |
| 684 return NULL; | 684 return NULL; |
| 685 } | 685 } |
| 686 } | 686 } |
| 687 | 687 |
| 688 ui::MenuModel* AutofillDialogControllerImpl::MenuModelForSection( | 688 ui::MenuModel* AutofillDialogControllerImpl::MenuModelForSection( |
| 689 DialogSection section) { | 689 DialogSection section) { |
| 690 SuggestionsMenuModel* model = SuggestionsMenuModelForSection(section); |
| 691 // The shipping section menu is special. It will always show because there is |
| 692 // a choice between "Use billing" and "enter new". |
| 693 if (section == SECTION_SHIPPING) |
| 694 return model; |
| 695 |
| 696 // For other sections, only show a menu if there's at least one suggestion. |
| 697 for (int i = 0; i < model->GetItemCount(); ++i) { |
| 698 if (IsASuggestionItemKey(model->GetItemKeyAt(i))) |
| 699 return model; |
| 700 } |
| 701 |
| 702 return NULL; |
| 703 } |
| 704 |
| 705 #if defined(OS_ANDROID) |
| 706 ui::MenuModel* AutofillDialogControllerImpl::MenuModelForSectionHack( |
| 707 DialogSection section) { |
| 690 return SuggestionsMenuModelForSection(section); | 708 return SuggestionsMenuModelForSection(section); |
| 691 } | 709 } |
| 710 #endif |
| 692 | 711 |
| 693 ui::MenuModel* AutofillDialogControllerImpl::MenuModelForAccountChooser() { | 712 ui::MenuModel* AutofillDialogControllerImpl::MenuModelForAccountChooser() { |
| 694 // If there were unrecoverable Wallet errors, or if there are choices other | 713 // If there were unrecoverable Wallet errors, or if there are choices other |
| 695 // than "Pay without the wallet", show the full menu. | 714 // than "Pay without the wallet", show the full menu. |
| 696 if (account_chooser_model_.had_wallet_error() || | 715 if (account_chooser_model_.had_wallet_error() || |
| 697 account_chooser_model_.HasAccountsToChoose()) { | 716 account_chooser_model_.HasAccountsToChoose()) { |
| 698 return &account_chooser_model_; | 717 return &account_chooser_model_; |
| 699 } | 718 } |
| 700 | 719 |
| 701 // Otherwise, there is no menu, just a sign in link. | 720 // Otherwise, there is no menu, just a sign in link. |
| (...skipping 1669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2371 url, | 2390 url, |
| 2372 content::PAGE_TRANSITION_AUTO_BOOKMARK); | 2391 content::PAGE_TRANSITION_AUTO_BOOKMARK); |
| 2373 params.disposition = NEW_FOREGROUND_TAB; | 2392 params.disposition = NEW_FOREGROUND_TAB; |
| 2374 chrome::Navigate(¶ms); | 2393 chrome::Navigate(¶ms); |
| 2375 #else | 2394 #else |
| 2376 // TODO(estade): use TabModelList? | 2395 // TODO(estade): use TabModelList? |
| 2377 #endif | 2396 #endif |
| 2378 } | 2397 } |
| 2379 | 2398 |
| 2380 } // namespace autofill | 2399 } // namespace autofill |
| OLD | NEW |