| 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 <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 962 } | 962 } |
| 963 | 963 |
| 964 bool AutofillDialogControllerImpl::ShouldShowAccountChooser() const { | 964 bool AutofillDialogControllerImpl::ShouldShowAccountChooser() const { |
| 965 return !ShouldShowSpinner() && GetManager()->IsCountryOfInterest("US"); | 965 return !ShouldShowSpinner() && GetManager()->IsCountryOfInterest("US"); |
| 966 } | 966 } |
| 967 | 967 |
| 968 bool AutofillDialogControllerImpl::ShouldShowSignInWebView() const { | 968 bool AutofillDialogControllerImpl::ShouldShowSignInWebView() const { |
| 969 return !signin_registrar_.IsEmpty(); | 969 return !signin_registrar_.IsEmpty(); |
| 970 } | 970 } |
| 971 | 971 |
| 972 GURL AutofillDialogControllerImpl::SignInUrl() const { | |
| 973 return wallet::GetSignInUrl(); | |
| 974 } | |
| 975 | |
| 976 bool AutofillDialogControllerImpl::ShouldOfferToSaveInChrome() const { | 972 bool AutofillDialogControllerImpl::ShouldOfferToSaveInChrome() const { |
| 977 return IsAutofillEnabled() && | 973 return IsAutofillEnabled() && |
| 978 !IsPayingWithWallet() && | 974 !IsPayingWithWallet() && |
| 979 !profile_->IsOffTheRecord() && | 975 !profile_->IsOffTheRecord() && |
| 980 IsManuallyEditingAnySection() && | 976 IsManuallyEditingAnySection() && |
| 981 !ShouldShowSpinner(); | 977 !ShouldShowSpinner(); |
| 982 } | 978 } |
| 983 | 979 |
| 984 bool AutofillDialogControllerImpl::ShouldSaveInChrome() const { | 980 bool AutofillDialogControllerImpl::ShouldSaveInChrome() const { |
| 985 return profile_->GetPrefs()->GetBoolean(::prefs::kAutofillDialogSaveData); | 981 return profile_->GetPrefs()->GetBoolean(::prefs::kAutofillDialogSaveData); |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1166 if (!ShouldShowSpinner()) | 1162 if (!ShouldShowSpinner()) |
| 1167 waiting_for_explicit_sign_in_response_ = false; | 1163 waiting_for_explicit_sign_in_response_ = false; |
| 1168 | 1164 |
| 1169 switch (SignedInState()) { | 1165 switch (SignedInState()) { |
| 1170 case SIGNED_IN: | 1166 case SIGNED_IN: |
| 1171 LogDialogLatencyToShow(); | 1167 LogDialogLatencyToShow(); |
| 1172 break; | 1168 break; |
| 1173 | 1169 |
| 1174 case REQUIRES_SIGN_IN: | 1170 case REQUIRES_SIGN_IN: |
| 1175 if (handling_use_wallet_link_click_) | 1171 if (handling_use_wallet_link_click_) |
| 1176 SignInLinkClicked(); | 1172 ShowSignIn(wallet::GetSignInUrl(GetWalletClient()->user_index())); |
| 1177 // Fall through. | 1173 // Fall through. |
| 1178 case SIGN_IN_DISABLED: | 1174 case SIGN_IN_DISABLED: |
| 1179 // Switch to the local account and refresh the dialog. | 1175 // Switch to the local account and refresh the dialog. |
| 1180 signin_helper_.reset(); | 1176 signin_helper_.reset(); |
| 1181 OnWalletSigninError(); | 1177 OnWalletSigninError(); |
| 1182 handling_use_wallet_link_click_ = false; | 1178 handling_use_wallet_link_click_ = false; |
| 1183 break; | 1179 break; |
| 1184 | 1180 |
| 1185 case REQUIRES_PASSIVE_SIGN_IN: | 1181 case REQUIRES_PASSIVE_SIGN_IN: |
| 1186 // Attempt to passively sign in the user. | 1182 // Attempt to passively sign in the user. |
| (...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2262 } | 2258 } |
| 2263 | 2259 |
| 2264 return notifications; | 2260 return notifications; |
| 2265 } | 2261 } |
| 2266 | 2262 |
| 2267 void AutofillDialogControllerImpl::LinkClicked(const GURL& url) { | 2263 void AutofillDialogControllerImpl::LinkClicked(const GURL& url) { |
| 2268 OpenTabWithUrl(url); | 2264 OpenTabWithUrl(url); |
| 2269 } | 2265 } |
| 2270 | 2266 |
| 2271 void AutofillDialogControllerImpl::SignInLinkClicked() { | 2267 void AutofillDialogControllerImpl::SignInLinkClicked() { |
| 2268 AddAccount(); |
| 2269 } |
| 2270 |
| 2271 void AutofillDialogControllerImpl::ShowSignIn(const GURL& url) { |
| 2272 ScopedViewUpdates updates(view_.get()); | 2272 ScopedViewUpdates updates(view_.get()); |
| 2273 | 2273 |
| 2274 if (SignedInState() == NOT_CHECKED) { | 2274 if (SignedInState() == NOT_CHECKED) { |
| 2275 handling_use_wallet_link_click_ = true; | 2275 handling_use_wallet_link_click_ = true; |
| 2276 account_chooser_model_->SelectWalletAccount(0); | 2276 account_chooser_model_->SelectWalletAccount(0); |
| 2277 FetchWalletCookie(); | 2277 FetchWalletCookie(); |
| 2278 } else if (signin_registrar_.IsEmpty()) { | 2278 } else if (signin_registrar_.IsEmpty()) { |
| 2279 // Start sign in. | 2279 // Start sign in. |
| 2280 waiting_for_explicit_sign_in_response_ = true; | 2280 waiting_for_explicit_sign_in_response_ = true; |
| 2281 content::Source<content::NavigationController> source(view_->ShowSignIn()); | 2281 content::Source<content::NavigationController> source( |
| 2282 view_->ShowSignIn(url)); |
| 2282 signin_registrar_.Add( | 2283 signin_registrar_.Add( |
| 2283 this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, source); | 2284 this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, source); |
| 2284 | 2285 |
| 2285 GetMetricLogger().LogDialogUiEvent( | 2286 GetMetricLogger().LogDialogUiEvent( |
| 2286 AutofillMetrics::DIALOG_UI_SIGNIN_SHOWN); | 2287 AutofillMetrics::DIALOG_UI_SIGNIN_SHOWN); |
| 2287 } else { | 2288 } else { |
| 2288 waiting_for_explicit_sign_in_response_ = false; | 2289 waiting_for_explicit_sign_in_response_ = false; |
| 2289 HideSignIn(); | 2290 HideSignIn(); |
| 2290 } | 2291 } |
| 2291 | 2292 |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2618 | 2619 |
| 2619 void AutofillDialogControllerImpl::OnPassiveSigninSuccess() { | 2620 void AutofillDialogControllerImpl::OnPassiveSigninSuccess() { |
| 2620 FetchWalletCookie(); | 2621 FetchWalletCookie(); |
| 2621 } | 2622 } |
| 2622 | 2623 |
| 2623 void AutofillDialogControllerImpl::OnPassiveSigninFailure( | 2624 void AutofillDialogControllerImpl::OnPassiveSigninFailure( |
| 2624 const GoogleServiceAuthError& error) { | 2625 const GoogleServiceAuthError& error) { |
| 2625 signin_helper_.reset(); | 2626 signin_helper_.reset(); |
| 2626 passive_failed_ = true; | 2627 passive_failed_ = true; |
| 2627 | 2628 |
| 2628 if (handling_use_wallet_link_click_ || | 2629 // When the user clicks on "use wallet" or a second account and passive auth |
| 2629 GetWalletClient()->user_index() != 0) { | 2630 // fails, try explicit sign in. |
| 2630 // TODO(estade): When a secondary account is selected and fails passive | 2631 if (handling_use_wallet_link_click_ || GetWalletClient()->user_index() != 0) { |
| 2631 // auth, we show a sign in page. Currently we show the generic add account | 2632 ShowSignIn(wallet::GetSignInUrl(GetWalletClient()->user_index())); |
| 2632 // page, but we should instead show sign in for the selected account. | |
| 2633 // http://crbug.com/323327 | |
| 2634 SignInLinkClicked(); | |
| 2635 handling_use_wallet_link_click_ = false; | 2633 handling_use_wallet_link_click_ = false; |
| 2636 } | 2634 } |
| 2637 | 2635 |
| 2638 OnWalletSigninError(); | 2636 OnWalletSigninError(); |
| 2639 } | 2637 } |
| 2640 | 2638 |
| 2641 void AutofillDialogControllerImpl::OnDidFetchWalletCookieValue( | 2639 void AutofillDialogControllerImpl::OnDidFetchWalletCookieValue( |
| 2642 const std::string& cookie_value) { | 2640 const std::string& cookie_value) { |
| 2643 wallet_cookie_value_ = cookie_value; | 2641 wallet_cookie_value_ = cookie_value; |
| 2644 signin_helper_.reset(); | 2642 signin_helper_.reset(); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2740 // and address. | 2738 // and address. |
| 2741 wallet_items_.reset(); | 2739 wallet_items_.reset(); |
| 2742 GetWalletItems(); | 2740 GetWalletItems(); |
| 2743 } else { | 2741 } else { |
| 2744 SuggestionsUpdated(); | 2742 SuggestionsUpdated(); |
| 2745 UpdateAccountChooserView(); | 2743 UpdateAccountChooserView(); |
| 2746 } | 2744 } |
| 2747 } | 2745 } |
| 2748 | 2746 |
| 2749 void AutofillDialogControllerImpl::AddAccount() { | 2747 void AutofillDialogControllerImpl::AddAccount() { |
| 2750 SignInLinkClicked(); | 2748 ShowSignIn(wallet::GetAddAccountUrl()); |
| 2751 } | 2749 } |
| 2752 | 2750 |
| 2753 void AutofillDialogControllerImpl::UpdateAccountChooserView() { | 2751 void AutofillDialogControllerImpl::UpdateAccountChooserView() { |
| 2754 if (view_) { | 2752 if (view_) { |
| 2755 ScopedViewUpdates updates(view_.get()); | 2753 ScopedViewUpdates updates(view_.get()); |
| 2756 view_->UpdateAccountChooser(); | 2754 view_->UpdateAccountChooser(); |
| 2757 view_->UpdateNotificationArea(); | 2755 view_->UpdateNotificationArea(); |
| 2758 } | 2756 } |
| 2759 } | 2757 } |
| 2760 | 2758 |
| (...skipping 1396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4157 view_->UpdateButtonStrip(); | 4155 view_->UpdateButtonStrip(); |
| 4158 } | 4156 } |
| 4159 | 4157 |
| 4160 void AutofillDialogControllerImpl::FetchWalletCookie() { | 4158 void AutofillDialogControllerImpl::FetchWalletCookie() { |
| 4161 net::URLRequestContextGetter* request_context = profile_->GetRequestContext(); | 4159 net::URLRequestContextGetter* request_context = profile_->GetRequestContext(); |
| 4162 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context)); | 4160 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context)); |
| 4163 signin_helper_->StartWalletCookieValueFetch(); | 4161 signin_helper_->StartWalletCookieValueFetch(); |
| 4164 } | 4162 } |
| 4165 | 4163 |
| 4166 } // namespace autofill | 4164 } // namespace autofill |
| OLD | NEW |