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 if (handling_use_wallet_link_click_ || GetWalletClient()->user_index() != 0) { |
groby-ooo-7-16
2014/10/17 20:14:12
Mind hoisting the comment (minus TODO) over? It's
Evan Stade
2014/10/17 20:43:18
Done.
| |
2629 GetWalletClient()->user_index() != 0) { | 2630 ShowSignIn(wallet::GetSignInUrl(GetWalletClient()->user_index())); |
2630 // TODO(estade): When a secondary account is selected and fails passive | |
2631 // auth, we show a sign in page. Currently we show the generic add account | |
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; | 2631 handling_use_wallet_link_click_ = false; |
2636 } | 2632 } |
2637 | 2633 |
2638 OnWalletSigninError(); | 2634 OnWalletSigninError(); |
2639 } | 2635 } |
2640 | 2636 |
2641 void AutofillDialogControllerImpl::OnDidFetchWalletCookieValue( | 2637 void AutofillDialogControllerImpl::OnDidFetchWalletCookieValue( |
2642 const std::string& cookie_value) { | 2638 const std::string& cookie_value) { |
2643 wallet_cookie_value_ = cookie_value; | 2639 wallet_cookie_value_ = cookie_value; |
2644 signin_helper_.reset(); | 2640 signin_helper_.reset(); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2740 // and address. | 2736 // and address. |
2741 wallet_items_.reset(); | 2737 wallet_items_.reset(); |
2742 GetWalletItems(); | 2738 GetWalletItems(); |
2743 } else { | 2739 } else { |
2744 SuggestionsUpdated(); | 2740 SuggestionsUpdated(); |
2745 UpdateAccountChooserView(); | 2741 UpdateAccountChooserView(); |
2746 } | 2742 } |
2747 } | 2743 } |
2748 | 2744 |
2749 void AutofillDialogControllerImpl::AddAccount() { | 2745 void AutofillDialogControllerImpl::AddAccount() { |
2750 SignInLinkClicked(); | 2746 ShowSignIn(wallet::GetAddAccountUrl()); |
2751 } | 2747 } |
2752 | 2748 |
2753 void AutofillDialogControllerImpl::UpdateAccountChooserView() { | 2749 void AutofillDialogControllerImpl::UpdateAccountChooserView() { |
2754 if (view_) { | 2750 if (view_) { |
2755 ScopedViewUpdates updates(view_.get()); | 2751 ScopedViewUpdates updates(view_.get()); |
2756 view_->UpdateAccountChooser(); | 2752 view_->UpdateAccountChooser(); |
2757 view_->UpdateNotificationArea(); | 2753 view_->UpdateNotificationArea(); |
2758 } | 2754 } |
2759 } | 2755 } |
2760 | 2756 |
(...skipping 1396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4157 view_->UpdateButtonStrip(); | 4153 view_->UpdateButtonStrip(); |
4158 } | 4154 } |
4159 | 4155 |
4160 void AutofillDialogControllerImpl::FetchWalletCookie() { | 4156 void AutofillDialogControllerImpl::FetchWalletCookie() { |
4161 net::URLRequestContextGetter* request_context = profile_->GetRequestContext(); | 4157 net::URLRequestContextGetter* request_context = profile_->GetRequestContext(); |
4162 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context)); | 4158 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context)); |
4163 signin_helper_->StartWalletCookieValueFetch(); | 4159 signin_helper_->StartWalletCookieValueFetch(); |
4164 } | 4160 } |
4165 | 4161 |
4166 } // namespace autofill | 4162 } // namespace autofill |
OLD | NEW |