Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(307)

Side by Side Diff: chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc

Issue 229723002: Better error reasons for rAc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: android Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 588
589 return true; 589 return true;
590 } 590 }
591 591
592 // static 592 // static
593 base::WeakPtr<AutofillDialogControllerImpl> 593 base::WeakPtr<AutofillDialogControllerImpl>
594 AutofillDialogControllerImpl::Create( 594 AutofillDialogControllerImpl::Create(
595 content::WebContents* contents, 595 content::WebContents* contents,
596 const FormData& form_structure, 596 const FormData& form_structure,
597 const GURL& source_url, 597 const GURL& source_url,
598 const base::Callback<void(const FormStructure*)>& callback) { 598 const AutofillManagerDelegate::ResultCallback& callback) {
599 // AutofillDialogControllerImpl owns itself. 599 // AutofillDialogControllerImpl owns itself.
600 AutofillDialogControllerImpl* autofill_dialog_controller = 600 AutofillDialogControllerImpl* autofill_dialog_controller =
601 new AutofillDialogControllerImpl(contents, 601 new AutofillDialogControllerImpl(contents,
602 form_structure, 602 form_structure,
603 source_url, 603 source_url,
604 callback); 604 callback);
605 return autofill_dialog_controller->weak_ptr_factory_.GetWeakPtr(); 605 return autofill_dialog_controller->weak_ptr_factory_.GetWeakPtr();
606 } 606 }
607 607
608 // static 608 // static
(...skipping 19 matching lines...) Expand all
628 ::prefs::kAutofillDialogWalletShippingSameAsBilling, 628 ::prefs::kAutofillDialogWalletShippingSameAsBilling,
629 false, 629 false,
630 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); 630 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
631 } 631 }
632 632
633 // static 633 // static
634 base::WeakPtr<AutofillDialogController> AutofillDialogController::Create( 634 base::WeakPtr<AutofillDialogController> AutofillDialogController::Create(
635 content::WebContents* contents, 635 content::WebContents* contents,
636 const FormData& form_structure, 636 const FormData& form_structure,
637 const GURL& source_url, 637 const GURL& source_url,
638 const base::Callback<void(const FormStructure*)>& callback) { 638 const AutofillManagerDelegate::ResultCallback& callback) {
639 return AutofillDialogControllerImpl::Create(contents, 639 return AutofillDialogControllerImpl::Create(contents,
640 form_structure, 640 form_structure,
641 source_url, 641 source_url,
642 callback); 642 callback);
643 } 643 }
644 644
645 void AutofillDialogControllerImpl::Show() { 645 void AutofillDialogControllerImpl::Show() {
646 dialog_shown_timestamp_ = base::Time::Now(); 646 dialog_shown_timestamp_ = base::Time::Now();
647 647
648 // Determine what field types should be included in the dialog. 648 // Determine what field types should be included in the dialog.
649 bool has_types = false; 649 bool has_types = false;
650 bool has_sections = false; 650 bool has_sections = false;
651 form_structure_.ParseFieldTypesFromAutocompleteAttributes( 651 form_structure_.ParseFieldTypesFromAutocompleteAttributes(
652 &has_types, &has_sections); 652 &has_types, &has_sections);
653 653
654 // Fail if the author didn't specify autocomplete types. 654 // Fail if the author didn't specify autocomplete types.
655 if (!has_types) { 655 if (!has_types) {
656 callback_.Run(NULL); 656 callback_.Run(AutofillManagerDelegate::AutocompleteResultErrorUnsupported,
657 NULL);
657 delete this; 658 delete this;
658 return; 659 return;
659 } 660 }
660 661
661 billing_country_combobox_model_.reset(new CountryComboboxModel( 662 billing_country_combobox_model_.reset(new CountryComboboxModel(
662 *GetManager(), 663 *GetManager(),
663 base::Bind(CountryFilter, 664 base::Bind(CountryFilter,
664 form_structure_.PossibleValues(ADDRESS_BILLING_COUNTRY)))); 665 form_structure_.PossibleValues(ADDRESS_BILLING_COUNTRY))));
665 shipping_country_combobox_model_.reset(new CountryComboboxModel( 666 shipping_country_combobox_model_.reset(new CountryComboboxModel(
666 *GetManager(), 667 *GetManager(),
(...skipping 1503 matching lines...) Expand 10 before | Expand all | Expand 10 after
2170 } 2171 }
2171 } 2172 }
2172 2173
2173 NOTREACHED(); 2174 NOTREACHED();
2174 } 2175 }
2175 2176
2176 bool AutofillDialogControllerImpl::OnCancel() { 2177 bool AutofillDialogControllerImpl::OnCancel() {
2177 HidePopup(); 2178 HidePopup();
2178 if (!is_submitting_) 2179 if (!is_submitting_)
2179 LogOnCancelMetrics(); 2180 LogOnCancelMetrics();
2180 callback_.Run(NULL); 2181 callback_.Run(AutofillManagerDelegate::AutocompleteResultErrorCancel, NULL);
2181 return true; 2182 return true;
2182 } 2183 }
2183 2184
2184 bool AutofillDialogControllerImpl::OnAccept() { 2185 bool AutofillDialogControllerImpl::OnAccept() {
2185 ScopedViewUpdates updates(view_.get()); 2186 ScopedViewUpdates updates(view_.get());
2186 choose_another_instrument_or_address_ = false; 2187 choose_another_instrument_or_address_ = false;
2187 wallet_server_validation_recoverable_ = true; 2188 wallet_server_validation_recoverable_ = true;
2188 HidePopup(); 2189 HidePopup();
2189 2190
2190 // This must come before SetIsSubmitting(). 2191 // This must come before SetIsSubmitting().
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
2658 bool AutofillDialogControllerImpl::IsSignInContinueUrl( 2659 bool AutofillDialogControllerImpl::IsSignInContinueUrl(
2659 const GURL& url, 2660 const GURL& url,
2660 size_t* user_index) const { 2661 size_t* user_index) const {
2661 return wallet::IsSignInContinueUrl(url, user_index); 2662 return wallet::IsSignInContinueUrl(url, user_index);
2662 } 2663 }
2663 2664
2664 AutofillDialogControllerImpl::AutofillDialogControllerImpl( 2665 AutofillDialogControllerImpl::AutofillDialogControllerImpl(
2665 content::WebContents* contents, 2666 content::WebContents* contents,
2666 const FormData& form_structure, 2667 const FormData& form_structure,
2667 const GURL& source_url, 2668 const GURL& source_url,
2668 const base::Callback<void(const FormStructure*)>& callback) 2669 const AutofillManagerDelegate::ResultCallback& callback)
2669 : WebContentsObserver(contents), 2670 : WebContentsObserver(contents),
2670 profile_(Profile::FromBrowserContext(contents->GetBrowserContext())), 2671 profile_(Profile::FromBrowserContext(contents->GetBrowserContext())),
2671 initial_user_state_(AutofillMetrics::DIALOG_USER_STATE_UNKNOWN), 2672 initial_user_state_(AutofillMetrics::DIALOG_USER_STATE_UNKNOWN),
2672 form_structure_(form_structure), 2673 form_structure_(form_structure),
2673 invoked_from_same_origin_(true), 2674 invoked_from_same_origin_(true),
2674 source_url_(source_url), 2675 source_url_(source_url),
2675 callback_(callback), 2676 callback_(callback),
2676 wallet_client_(profile_->GetRequestContext(), this, source_url), 2677 wallet_client_(profile_->GetRequestContext(), this, source_url),
2677 wallet_items_requested_(false), 2678 wallet_items_requested_(false),
2678 handling_use_wallet_link_click_(false), 2679 handling_use_wallet_link_click_(false),
(...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after
3733 if (!wallet_error_notification_ && 3734 if (!wallet_error_notification_ &&
3734 account_chooser_model_->HasAccountsToChoose()) { 3735 account_chooser_model_->HasAccountsToChoose()) {
3735 profile_->GetPrefs()->SetBoolean( 3736 profile_->GetPrefs()->SetBoolean(
3736 ::prefs::kAutofillDialogPayWithoutWallet, 3737 ::prefs::kAutofillDialogPayWithoutWallet,
3737 !account_chooser_model_->WalletIsSelected()); 3738 !account_chooser_model_->WalletIsSelected());
3738 } 3739 }
3739 3740
3740 LogOnFinishSubmitMetrics(); 3741 LogOnFinishSubmitMetrics();
3741 3742
3742 // Callback should be called as late as possible. 3743 // Callback should be called as late as possible.
3743 callback_.Run(&form_structure_); 3744 callback_.Run(AutofillManagerDelegate::AutocompleteResultSuccess,
3745 &form_structure_);
3744 data_was_passed_back_ = true; 3746 data_was_passed_back_ = true;
3745 3747
3746 // This might delete us. 3748 // This might delete us.
3747 Hide(); 3749 Hide();
3748 } 3750 }
3749 3751
3750 void AutofillDialogControllerImpl::PersistAutofillChoice( 3752 void AutofillDialogControllerImpl::PersistAutofillChoice(
3751 DialogSection section, 3753 DialogSection section,
3752 const std::string& guid) { 3754 const std::string& guid) {
3753 DCHECK(!IsPayingWithWallet() && ShouldOfferToSaveInChrome()); 3755 DCHECK(!IsPayingWithWallet() && ShouldOfferToSaveInChrome());
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
3938 view_->UpdateButtonStrip(); 3940 view_->UpdateButtonStrip();
3939 } 3941 }
3940 3942
3941 void AutofillDialogControllerImpl::FetchWalletCookie() { 3943 void AutofillDialogControllerImpl::FetchWalletCookie() {
3942 net::URLRequestContextGetter* request_context = profile_->GetRequestContext(); 3944 net::URLRequestContextGetter* request_context = profile_->GetRequestContext();
3943 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context)); 3945 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context));
3944 signin_helper_->StartWalletCookieValueFetch(); 3946 signin_helper_->StartWalletCookieValueFetch();
3945 } 3947 }
3946 3948
3947 } // namespace autofill 3949 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698