Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/string_split.h" | 10 #include "base/string_split.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 126 const GURL& source_url, | 126 const GURL& source_url, |
| 127 const content::SSLStatus& ssl_status, | 127 const content::SSLStatus& ssl_status, |
| 128 const base::Callback<void(const FormStructure*)>& callback) | 128 const base::Callback<void(const FormStructure*)>& callback) |
| 129 : profile_(Profile::FromBrowserContext(contents->GetBrowserContext())), | 129 : profile_(Profile::FromBrowserContext(contents->GetBrowserContext())), |
| 130 contents_(contents), | 130 contents_(contents), |
| 131 form_structure_(form), | 131 form_structure_(form), |
| 132 source_url_(source_url), | 132 source_url_(source_url), |
| 133 ssl_status_(ssl_status), | 133 ssl_status_(ssl_status), |
| 134 callback_(callback), | 134 callback_(callback), |
| 135 wallet_client_(profile_->GetRequestContext()), | 135 wallet_client_(profile_->GetRequestContext()), |
| 136 refresh_wallet_items_in_progress_(false), | |
| 137 refresh_wallet_items_queued_(false), | |
| 138 had_wallet_error_(false), | |
| 136 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_email_(this)), | 139 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_email_(this)), |
| 137 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_cc_(this)), | 140 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_cc_(this)), |
| 138 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_billing_(this)), | 141 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_billing_(this)), |
| 139 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_shipping_(this)), | 142 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_shipping_(this)), |
| 140 popup_controller_(NULL), | 143 popup_controller_(NULL), |
| 141 section_showing_popup_(SECTION_BILLING) { | 144 section_showing_popup_(SECTION_BILLING) { |
| 142 // TODO(estade): |this| should observe PersonalDataManager. | 145 // TODO(estade): |this| should observe PersonalDataManager. |
| 143 // TODO(estade): remove duplicates from |form|? | 146 // TODO(estade): remove duplicates from |form|? |
| 144 | 147 |
| 145 content::NavigationEntry* entry = contents->GetController().GetActiveEntry(); | 148 content::NavigationEntry* entry = contents->GetController().GetActiveEntry(); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 216 &requested_shipping_fields_); | 219 &requested_shipping_fields_); |
| 217 | 220 |
| 218 GenerateSuggestionsModels(); | 221 GenerateSuggestionsModels(); |
| 219 | 222 |
| 220 // TODO(estade): don't show the dialog if the site didn't specify the right | 223 // TODO(estade): don't show the dialog if the site didn't specify the right |
| 221 // fields. First we must figure out what the "right" fields are. | 224 // fields. First we must figure out what the "right" fields are. |
| 222 view_.reset(AutofillDialogView::Create(this)); | 225 view_.reset(AutofillDialogView::Create(this)); |
| 223 view_->Show(); | 226 view_->Show(); |
| 224 | 227 |
| 225 // Request sugar info after the view is showing to simplify code for now. | 228 // Request sugar info after the view is showing to simplify code for now. |
| 226 wallet_client_.GetWalletItems(this); | 229 ScheduleRefreshWalletItems(); |
| 227 } | 230 } |
| 228 | 231 |
| 229 void AutofillDialogControllerImpl::Hide() { | 232 void AutofillDialogControllerImpl::Hide() { |
| 230 if (view_) | 233 if (view_) |
| 231 view_->Hide(); | 234 view_->Hide(); |
| 232 } | 235 } |
| 233 | 236 |
| 234 //////////////////////////////////////////////////////////////////////////////// | 237 //////////////////////////////////////////////////////////////////////////////// |
| 235 // AutofillDialogController implementation. | 238 // AutofillDialogController implementation. |
| 236 | 239 |
| 237 string16 AutofillDialogControllerImpl::DialogTitle() const { | 240 string16 AutofillDialogControllerImpl::DialogTitle() const { |
| 238 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_TITLE); | 241 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_TITLE); |
| 239 } | 242 } |
| 240 | 243 |
| 244 string16 AutofillDialogControllerImpl::PayWithoutWallet() const { | |
| 245 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_PAY_WITHOUT_WALLET); | |
| 246 } | |
| 247 | |
| 241 string16 AutofillDialogControllerImpl::EditSuggestionText() const { | 248 string16 AutofillDialogControllerImpl::EditSuggestionText() const { |
| 242 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_EDIT); | 249 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_EDIT); |
| 243 } | 250 } |
| 244 | 251 |
| 245 string16 AutofillDialogControllerImpl::UseBillingForShippingText() const { | 252 string16 AutofillDialogControllerImpl::UseBillingForShippingText() const { |
| 246 return l10n_util::GetStringUTF16( | 253 return l10n_util::GetStringUTF16( |
| 247 IDS_AUTOFILL_DIALOG_USE_BILLING_FOR_SHIPPING); | 254 IDS_AUTOFILL_DIALOG_USE_BILLING_FOR_SHIPPING); |
| 248 } | 255 } |
| 249 | 256 |
| 250 string16 AutofillDialogControllerImpl::WalletOptionText() const { | 257 string16 AutofillDialogControllerImpl::WalletOptionText() const { |
| 251 // TODO(estade): real strings and l10n. | 258 // TODO(estade): real strings and l10n. |
| 252 return string16(ASCIIToUTF16("I love lamp.")); | 259 return string16(ASCIIToUTF16("I love lamp.")); |
| 253 } | 260 } |
| 254 | 261 |
| 255 string16 AutofillDialogControllerImpl::CancelButtonText() const { | 262 string16 AutofillDialogControllerImpl::CancelButtonText() const { |
| 256 return l10n_util::GetStringUTF16(IDS_CANCEL); | 263 return l10n_util::GetStringUTF16(IDS_CANCEL); |
| 257 } | 264 } |
| 258 | 265 |
| 259 string16 AutofillDialogControllerImpl::ConfirmButtonText() const { | 266 string16 AutofillDialogControllerImpl::ConfirmButtonText() const { |
| 260 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SUBMIT_BUTTON); | 267 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SUBMIT_BUTTON); |
| 261 } | 268 } |
| 262 | 269 |
| 263 string16 AutofillDialogControllerImpl::SignInText() const { | 270 string16 AutofillDialogControllerImpl::SignInText() const { |
| 264 // TODO(abodenha): real strings and l10n. | 271 // TODO(abodenha): real strings and l10n. |
| 265 return string16(ASCIIToUTF16("Sign in to use Google Wallet")); | 272 return ASCIIToUTF16("Sign in to use Google Wallet"); |
| 273 } | |
| 274 | |
| 275 string16 AutofillDialogControllerImpl::SignedInUser() const { | |
| 276 // TODO(dbeam): get the real signed in user. | |
| 277 DCHECK_EQ(SIGNED_IN, SignedInState()); | |
| 278 return ASCIIToUTF16("user@example.com"); | |
| 266 } | 279 } |
| 267 | 280 |
| 268 string16 AutofillDialogControllerImpl::CancelSignInText() const { | 281 string16 AutofillDialogControllerImpl::CancelSignInText() const { |
| 269 // TODO(abodenha): real strings and l10n. | 282 // TODO(abodenha): real strings and l10n. |
| 270 return string16(ASCIIToUTF16("Don't sign in.")); | 283 return ASCIIToUTF16("Don't sign in."); |
| 284 } | |
| 285 | |
| 286 string16 AutofillDialogControllerImpl::SaveLocallyText() const { | |
| 287 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SAVE_LOCALLY_CHECKBOX); | |
| 288 } | |
| 289 | |
| 290 string16 AutofillDialogControllerImpl::ProgressBarText() const { | |
| 291 return l10n_util::GetStringUTF16( | |
| 292 IDS_AUTOFILL_DIALOG_AUTOCHECKOUT_PROGRESS_BAR); | |
| 271 } | 293 } |
| 272 | 294 |
| 273 DialogSignedInState AutofillDialogControllerImpl::SignedInState() const { | 295 DialogSignedInState AutofillDialogControllerImpl::SignedInState() const { |
| 274 if (!wallet_items_) | 296 if (!wallet_items_) |
| 275 return REQUIRES_RESPONSE; | 297 return REQUIRES_RESPONSE; |
| 276 | 298 |
| 277 if (HasRequiredAction(wallet::GAIA_AUTH)) | 299 if (HasRequiredAction(wallet::GAIA_AUTH)) |
| 278 return REQUIRES_SIGN_IN; | 300 return REQUIRES_SIGN_IN; |
| 279 | 301 |
| 280 if (HasRequiredAction(wallet::PASSIVE_GAIA_AUTH)) | 302 if (HasRequiredAction(wallet::PASSIVE_GAIA_AUTH)) |
| 281 return REQUIRES_PASSIVE_SIGN_IN; | 303 return REQUIRES_PASSIVE_SIGN_IN; |
| 282 | 304 |
| 283 return SIGNED_IN; | 305 return SIGNED_IN; |
| 284 } | 306 } |
| 285 | 307 |
| 286 string16 AutofillDialogControllerImpl::SaveLocallyText() const { | 308 bool AutofillDialogControllerImpl::IsWalletAvailable() const { |
| 287 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SAVE_LOCALLY_CHECKBOX); | 309 return !had_wallet_error_; |
| 288 } | |
| 289 | |
| 290 string16 AutofillDialogControllerImpl::ProgressBarText() const { | |
| 291 return l10n_util::GetStringUTF16( | |
| 292 IDS_AUTOFILL_DIALOG_AUTOCHECKOUT_PROGRESS_BAR); | |
| 293 } | 310 } |
| 294 | 311 |
| 295 const DetailInputs& AutofillDialogControllerImpl::RequestedFieldsForSection( | 312 const DetailInputs& AutofillDialogControllerImpl::RequestedFieldsForSection( |
| 296 DialogSection section) const { | 313 DialogSection section) const { |
| 297 switch (section) { | 314 switch (section) { |
| 298 case SECTION_EMAIL: | 315 case SECTION_EMAIL: |
| 299 return requested_email_fields_; | 316 return requested_email_fields_; |
| 300 case SECTION_CC: | 317 case SECTION_CC: |
| 301 return requested_cc_fields_; | 318 return requested_cc_fields_; |
| 302 case SECTION_BILLING: | 319 case SECTION_BILLING: |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 547 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SECURITY_WARNING)); | 564 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SECURITY_WARNING)); |
| 548 } | 565 } |
| 549 | 566 |
| 550 if (!invoked_from_same_origin_) { | 567 if (!invoked_from_same_origin_) { |
| 551 return DialogNotification( | 568 return DialogNotification( |
| 552 DialogNotification::SECURITY_WARNING, | 569 DialogNotification::SECURITY_WARNING, |
| 553 l10n_util::GetStringFUTF16( | 570 l10n_util::GetStringFUTF16( |
| 554 IDS_AUTOFILL_DIALOG_SITE_WARNING, UTF8ToUTF16(source_url_.host()))); | 571 IDS_AUTOFILL_DIALOG_SITE_WARNING, UTF8ToUTF16(source_url_.host()))); |
| 555 } | 572 } |
| 556 | 573 |
| 574 if (had_wallet_error_) { | |
|
Evan Stade
2013/02/06 21:57:49
is the plan to have multiple notifications at once
Dan Beam
2013/02/07 01:22:40
I assume we'll never be *showing* multiple notific
Evan Stade
2013/02/07 01:54:42
I think we will want to show multiple notification
Dan Beam
2013/02/07 03:26:53
https://crbug.com/174814
| |
| 575 // TODO(dbeam): pass along the Wallet error or remove from the translation. | |
| 576 return DialogNotification( | |
| 577 DialogNotification::WALLET_ERROR, | |
| 578 l10n_util::GetStringFUTF16( | |
| 579 IDS_AUTOFILL_DIALOG_COMPLETE_WITHOUT_WALLET, | |
| 580 ASCIIToUTF16("[Wallet-Error]."))); | |
| 581 } | |
| 582 | |
| 557 return DialogNotification(); | 583 return DialogNotification(); |
| 558 } | 584 } |
| 559 | 585 |
| 560 void AutofillDialogControllerImpl::StartSignInFlow() { | 586 void AutofillDialogControllerImpl::StartSignInFlow() { |
| 561 DCHECK(registrar_.IsEmpty()); | 587 DCHECK(registrar_.IsEmpty()); |
| 562 | 588 |
| 563 content::Source<content::NavigationController> source( | 589 content::Source<content::NavigationController> source(&view_->ShowSignIn()); |
| 564 &view_->ShowSignIn()); | |
| 565 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, source); | 590 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, source); |
| 566 } | 591 } |
| 567 | 592 |
| 568 void AutofillDialogControllerImpl::EndSignInFlow() { | 593 void AutofillDialogControllerImpl::EndSignInFlow() { |
| 569 DCHECK(!registrar_.IsEmpty()); | 594 DCHECK(!registrar_.IsEmpty()); |
| 570 registrar_.RemoveAll(); | 595 registrar_.RemoveAll(); |
| 571 view_->HideSignIn(); | 596 view_->HideSignIn(); |
| 572 } | 597 } |
| 573 | 598 |
| 574 Profile* AutofillDialogControllerImpl::profile() { | 599 Profile* AutofillDialogControllerImpl::profile() { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 626 | 651 |
| 627 void AutofillDialogControllerImpl::Observe( | 652 void AutofillDialogControllerImpl::Observe( |
| 628 int type, | 653 int type, |
| 629 const content::NotificationSource& source, | 654 const content::NotificationSource& source, |
| 630 const content::NotificationDetails& details) { | 655 const content::NotificationDetails& details) { |
| 631 DCHECK_EQ(type, content::NOTIFICATION_NAV_ENTRY_COMMITTED); | 656 DCHECK_EQ(type, content::NOTIFICATION_NAV_ENTRY_COMMITTED); |
| 632 content::LoadCommittedDetails* load_details = | 657 content::LoadCommittedDetails* load_details = |
| 633 content::Details<content::LoadCommittedDetails>(details).ptr(); | 658 content::Details<content::LoadCommittedDetails>(details).ptr(); |
| 634 if (wallet::IsSignInContinueUrl(load_details->entry->GetVirtualURL())) { | 659 if (wallet::IsSignInContinueUrl(load_details->entry->GetVirtualURL())) { |
| 635 EndSignInFlow(); | 660 EndSignInFlow(); |
| 636 // TODO(dbeam): the fetcher can't handle being called multiple times. | 661 ScheduleRefreshWalletItems(); |
| 637 // Address this soon as we will be re-fetching wallet items after every | |
| 638 // required action is resolved. | |
| 639 wallet_client_.GetWalletItems(this); | |
| 640 } | 662 } |
| 641 } | 663 } |
| 642 | 664 |
| 643 //////////////////////////////////////////////////////////////////////////////// | 665 //////////////////////////////////////////////////////////////////////////////// |
| 644 // SuggestionsMenuModelDelegate | 666 // SuggestionsMenuModelDelegate |
| 645 | 667 |
| 646 void AutofillDialogControllerImpl::SuggestionItemSelected( | 668 void AutofillDialogControllerImpl::SuggestionItemSelected( |
| 647 const SuggestionsMenuModel& model) { | 669 const SuggestionsMenuModel& model) { |
| 648 DialogSection section = SectionForSuggestionsMenuModel(model); | 670 DialogSection section = SectionForSuggestionsMenuModel(model); |
| 649 section_editing_state_[section] = false; | 671 section_editing_state_[section] = false; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 664 } | 686 } |
| 665 | 687 |
| 666 void AutofillDialogControllerImpl::OnDidEscrowSensitiveInformation( | 688 void AutofillDialogControllerImpl::OnDidEscrowSensitiveInformation( |
| 667 const std::string& escrow_handle) { | 689 const std::string& escrow_handle) { |
| 668 NOTIMPLEMENTED() << " escrow_handle=" << escrow_handle; | 690 NOTIMPLEMENTED() << " escrow_handle=" << escrow_handle; |
| 669 } | 691 } |
| 670 | 692 |
| 671 void AutofillDialogControllerImpl::OnDidGetFullWallet( | 693 void AutofillDialogControllerImpl::OnDidGetFullWallet( |
| 672 scoped_ptr<wallet::FullWallet> full_wallet) { | 694 scoped_ptr<wallet::FullWallet> full_wallet) { |
| 673 NOTIMPLEMENTED(); | 695 NOTIMPLEMENTED(); |
| 696 WalletRequestCompleted(true); | |
| 674 } | 697 } |
| 675 | 698 |
| 676 void AutofillDialogControllerImpl::OnDidGetWalletItems( | 699 void AutofillDialogControllerImpl::OnDidGetWalletItems( |
| 677 scoped_ptr<wallet::WalletItems> wallet_items) { | 700 scoped_ptr<wallet::WalletItems> wallet_items) { |
| 701 bool items_changed = !wallet_items_ || *wallet_items != *wallet_items_; | |
| 678 wallet_items_ = wallet_items.Pass(); | 702 wallet_items_ = wallet_items.Pass(); |
| 679 view_->UpdateAccountChooser(); | 703 WalletRequestCompleted(true); |
| 680 view_->UpdateNotificationArea(); | 704 |
| 705 if (items_changed) { | |
| 706 view_->UpdateAccountChooser(); | |
| 707 view_->UpdateNotificationArea(); | |
| 708 } | |
| 681 } | 709 } |
| 682 | 710 |
| 683 void AutofillDialogControllerImpl::OnDidSaveAddress( | 711 void AutofillDialogControllerImpl::OnDidSaveAddress( |
| 684 const std::string& address_id) { | 712 const std::string& address_id) { |
| 685 NOTIMPLEMENTED() << " address_id=" << address_id; | 713 NOTIMPLEMENTED() << " address_id=" << address_id; |
| 714 WalletRequestCompleted(true); | |
| 686 } | 715 } |
| 687 | 716 |
| 688 void AutofillDialogControllerImpl::OnDidSaveInstrument( | 717 void AutofillDialogControllerImpl::OnDidSaveInstrument( |
| 689 const std::string& instrument_id) { | 718 const std::string& instrument_id) { |
| 690 NOTIMPLEMENTED() << " instrument_id=" << instrument_id; | 719 NOTIMPLEMENTED() << " instrument_id=" << instrument_id; |
| 720 WalletRequestCompleted(true); | |
| 691 } | 721 } |
| 692 | 722 |
| 693 void AutofillDialogControllerImpl::OnDidSaveInstrumentAndAddress( | 723 void AutofillDialogControllerImpl::OnDidSaveInstrumentAndAddress( |
| 694 const std::string& instrument_id, const std::string& address_id) { | 724 const std::string& instrument_id, const std::string& address_id) { |
| 695 NOTIMPLEMENTED() << " instrument_id=" << instrument_id | 725 NOTIMPLEMENTED() << " instrument_id=" << instrument_id |
| 696 << ", address_id=" << address_id; | 726 << ", address_id=" << address_id; |
| 727 WalletRequestCompleted(true); | |
| 697 } | 728 } |
| 698 | 729 |
| 699 void AutofillDialogControllerImpl::OnDidSendAutocheckoutStatus() { | 730 void AutofillDialogControllerImpl::OnDidSendAutocheckoutStatus() { |
| 700 NOTIMPLEMENTED(); | 731 NOTIMPLEMENTED(); |
| 732 WalletRequestCompleted(true); | |
| 701 } | 733 } |
| 702 | 734 |
| 703 void AutofillDialogControllerImpl::OnWalletError() { | 735 void AutofillDialogControllerImpl::OnWalletError() { |
| 704 NOTIMPLEMENTED(); | 736 WalletRequestCompleted(false); |
| 705 wallet_items_.reset(); | |
| 706 } | 737 } |
| 707 | 738 |
| 708 void AutofillDialogControllerImpl::OnMalformedResponse() { | 739 void AutofillDialogControllerImpl::OnMalformedResponse() { |
| 709 NOTIMPLEMENTED(); | 740 WalletRequestCompleted(false); |
| 710 wallet_items_.reset(); | |
| 711 } | 741 } |
| 712 | 742 |
| 713 void AutofillDialogControllerImpl::OnNetworkError(int response_code) { | 743 void AutofillDialogControllerImpl::OnNetworkError(int response_code) { |
| 714 NOTIMPLEMENTED() << " response_code=" << response_code; | 744 WalletRequestCompleted(false); |
| 715 wallet_items_.reset(); | |
| 716 } | 745 } |
| 717 | 746 |
| 718 //////////////////////////////////////////////////////////////////////////////// | 747 //////////////////////////////////////////////////////////////////////////////// |
| 719 | 748 |
| 720 bool AutofillDialogControllerImpl::HandleKeyPressEventInInput( | 749 bool AutofillDialogControllerImpl::HandleKeyPressEventInInput( |
| 721 const content::NativeWebKeyboardEvent& event) { | 750 const content::NativeWebKeyboardEvent& event) { |
| 722 if (popup_controller_) | 751 if (popup_controller_) |
| 723 return popup_controller_->HandleKeyPressEvent(event); | 752 return popup_controller_->HandleKeyPressEvent(event); |
| 724 | 753 |
| 725 return false; | 754 return false; |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 747 bool AutofillDialogControllerImpl::HasRequiredAction( | 776 bool AutofillDialogControllerImpl::HasRequiredAction( |
| 748 wallet::RequiredAction action) const { | 777 wallet::RequiredAction action) const { |
| 749 if (!wallet_items_) | 778 if (!wallet_items_) |
| 750 return false; | 779 return false; |
| 751 | 780 |
| 752 const std::vector<wallet::RequiredAction>& actions = | 781 const std::vector<wallet::RequiredAction>& actions = |
| 753 wallet_items_->required_actions(); | 782 wallet_items_->required_actions(); |
| 754 return std::find(actions.begin(), actions.end(), action) != actions.end(); | 783 return std::find(actions.begin(), actions.end(), action) != actions.end(); |
| 755 } | 784 } |
| 756 | 785 |
| 786 void AutofillDialogControllerImpl::ScheduleRefreshWalletItems() { | |
| 787 if (had_wallet_error_ || refresh_wallet_items_queued_) | |
|
Evan Stade
2013/02/06 21:57:49
the second half of this check seems unnecessary/un
Dan Beam
2013/02/07 01:22:40
Done.
| |
| 788 return; | |
| 789 | |
| 790 if (refresh_wallet_items_in_progress_) { | |
| 791 refresh_wallet_items_queued_ = true; | |
| 792 return; | |
| 793 } | |
| 794 | |
| 795 wallet_client_.GetWalletItems(this); | |
|
Evan Stade
2013/02/06 21:57:49
you sohuld set refresh_wallet_items_queued_ to fal
Dan Beam
2013/02/07 01:22:40
Done.
| |
| 796 refresh_wallet_items_in_progress_ = true; | |
| 797 } | |
| 798 | |
| 799 void AutofillDialogControllerImpl::WalletRequestCompleted(bool success) { | |
| 800 // |wallet_client_| only handles 1 request at a time, so this can be safely | |
| 801 // set to false every time regardless of which type of request completed. | |
| 802 refresh_wallet_items_in_progress_ = false; | |
|
Evan Stade
2013/02/06 21:57:49
this can be done here, but why should it be? Can't
Dan Beam
2013/02/07 01:22:40
if I move this to OnDidGetWalletItems(), what happ
Evan Stade
2013/02/07 01:54:42
fair enough.
| |
| 803 | |
| 804 if (!success) { | |
| 805 if (!had_wallet_error_) { | |
|
Evan Stade
2013/02/06 21:57:49
this check seems wrong, the wallet error text may
Dan Beam
2013/02/07 01:22:40
Right now we stop at the first wallet error, but s
| |
| 806 had_wallet_error_ = true; | |
|
Evan Stade
2013/02/06 21:57:49
when do you set had_wallet_error_ to false
Dan Beam
2013/02/07 01:22:40
never, by design -- at the first error we stop int
| |
| 807 wallet_items_.reset(); | |
| 808 view_->UpdateAccountChooser(); | |
| 809 view_->UpdateNotificationArea(); | |
| 810 } | |
| 811 return; | |
| 812 } | |
| 813 | |
| 814 if (refresh_wallet_items_queued_) { | |
| 815 refresh_wallet_items_queued_ = false; | |
| 816 ScheduleRefreshWalletItems(); | |
| 817 } | |
| 818 } | |
| 819 | |
| 757 void AutofillDialogControllerImpl::GenerateSuggestionsModels() { | 820 void AutofillDialogControllerImpl::GenerateSuggestionsModels() { |
| 758 PersonalDataManager* manager = GetManager(); | 821 PersonalDataManager* manager = GetManager(); |
| 759 const std::vector<CreditCard*>& cards = manager->credit_cards(); | 822 const std::vector<CreditCard*>& cards = manager->credit_cards(); |
| 760 for (size_t i = 0; i < cards.size(); ++i) { | 823 for (size_t i = 0; i < cards.size(); ++i) { |
| 761 suggested_cc_.AddKeyedItem(cards[i]->guid(), cards[i]->Label()); | 824 suggested_cc_.AddKeyedItem(cards[i]->guid(), cards[i]->Label()); |
| 762 } | 825 } |
| 763 // TODO(estade): real strings and i18n. | 826 // TODO(estade): real strings and i18n. |
| 764 suggested_cc_.AddKeyedItem("", ASCIIToUTF16("Enter new card")); | 827 suggested_cc_.AddKeyedItem("", ASCIIToUTF16("Enter new card")); |
| 765 | 828 |
| 766 const std::vector<AutofillProfile*>& profiles = manager->GetProfiles(); | 829 const std::vector<AutofillProfile*>& profiles = manager->GetProfiles(); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 933 } | 996 } |
| 934 | 997 |
| 935 void AutofillDialogControllerImpl::HidePopup() { | 998 void AutofillDialogControllerImpl::HidePopup() { |
| 936 if (popup_controller_) { | 999 if (popup_controller_) { |
| 937 popup_controller_->Hide(); | 1000 popup_controller_->Hide(); |
| 938 ControllerDestroyed(); | 1001 ControllerDestroyed(); |
| 939 } | 1002 } |
| 940 } | 1003 } |
| 941 | 1004 |
| 942 } // namespace autofill | 1005 } // namespace autofill |
| OLD | NEW |