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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 } // namespace | 218 } // namespace |
219 | 219 |
220 AutofillDialogController::~AutofillDialogController() {} | 220 AutofillDialogController::~AutofillDialogController() {} |
221 | 221 |
222 AutofillDialogControllerImpl::AutofillDialogControllerImpl( | 222 AutofillDialogControllerImpl::AutofillDialogControllerImpl( |
223 content::WebContents* contents, | 223 content::WebContents* contents, |
224 const FormData& form, | 224 const FormData& form, |
225 const GURL& source_url, | 225 const GURL& source_url, |
226 const AutofillMetrics& metric_logger, | 226 const AutofillMetrics& metric_logger, |
227 DialogType dialog_type, | 227 DialogType dialog_type, |
228 const base::Callback<void(const FormStructure*)>& callback) | 228 const base::Callback<void(const FormStructure*, |
| 229 const std::string&)>& callback) |
229 : profile_(Profile::FromBrowserContext(contents->GetBrowserContext())), | 230 : profile_(Profile::FromBrowserContext(contents->GetBrowserContext())), |
230 contents_(contents), | 231 contents_(contents), |
231 form_structure_(form, std::string()), | 232 form_structure_(form, std::string()), |
232 invoked_from_same_origin_(true), | 233 invoked_from_same_origin_(true), |
233 source_url_(source_url), | 234 source_url_(source_url), |
234 ssl_status_(form.ssl_status), | 235 ssl_status_(form.ssl_status), |
235 callback_(callback), | 236 callback_(callback), |
236 ALLOW_THIS_IN_INITIALIZER_LIST( | 237 ALLOW_THIS_IN_INITIALIZER_LIST( |
237 account_chooser_model_(this, profile_->GetPrefs())), | 238 account_chooser_model_(this, profile_->GetPrefs())), |
238 ALLOW_THIS_IN_INITIALIZER_LIST( | 239 ALLOW_THIS_IN_INITIALIZER_LIST( |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 AutofillMetrics::SECURITY_METRIC_CROSS_ORIGIN_FRAME); | 293 AutofillMetrics::SECURITY_METRIC_CROSS_ORIGIN_FRAME); |
293 } | 294 } |
294 | 295 |
295 // Determine what field types should be included in the dialog. | 296 // Determine what field types should be included in the dialog. |
296 bool has_types = false; | 297 bool has_types = false; |
297 bool has_sections = false; | 298 bool has_sections = false; |
298 form_structure_.ParseFieldTypesFromAutocompleteAttributes(&has_types, | 299 form_structure_.ParseFieldTypesFromAutocompleteAttributes(&has_types, |
299 &has_sections); | 300 &has_sections); |
300 // Fail if the author didn't specify autocomplete types. | 301 // Fail if the author didn't specify autocomplete types. |
301 if (!has_types) { | 302 if (!has_types) { |
302 callback_.Run(NULL); | 303 callback_.Run(NULL, std::string()); |
303 delete this; | 304 delete this; |
304 return; | 305 return; |
305 } | 306 } |
306 | 307 |
307 const DetailInput kEmailInputs[] = { | 308 const DetailInput kEmailInputs[] = { |
308 { 1, EMAIL_ADDRESS, IDS_AUTOFILL_DIALOG_PLACEHOLDER_EMAIL }, | 309 { 1, EMAIL_ADDRESS, IDS_AUTOFILL_DIALOG_PLACEHOLDER_EMAIL }, |
309 }; | 310 }; |
310 | 311 |
311 const DetailInput kCCInputs[] = { | 312 const DetailInput kCCInputs[] = { |
312 { 2, CREDIT_CARD_NUMBER, IDS_AUTOFILL_DIALOG_PLACEHOLDER_CARD_NUMBER }, | 313 { 2, CREDIT_CARD_NUMBER, IDS_AUTOFILL_DIALOG_PLACEHOLDER_CARD_NUMBER }, |
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
996 metric_logger_.LogDialogUiDuration( | 997 metric_logger_.LogDialogUiDuration( |
997 base::Time::Now() - dialog_shown_timestamp_, | 998 base::Time::Now() - dialog_shown_timestamp_, |
998 dialog_type_, | 999 dialog_type_, |
999 AutofillMetrics::DIALOG_CANCELED); | 1000 AutofillMetrics::DIALOG_CANCELED); |
1000 } | 1001 } |
1001 | 1002 |
1002 // If Autocheckout has an error, it's possible that the dialog will be | 1003 // If Autocheckout has an error, it's possible that the dialog will be |
1003 // submitted to start the flow and then cancelled to close the dialog after | 1004 // submitted to start the flow and then cancelled to close the dialog after |
1004 // the error. | 1005 // the error. |
1005 if (!callback_.is_null()) { | 1006 if (!callback_.is_null()) { |
1006 callback_.Run(NULL); | 1007 callback_.Run(NULL, std::string()); |
1007 callback_ = base::Callback<void(const FormStructure*)>(); | 1008 callback_ = base::Callback<void(const FormStructure*, |
| 1009 const std::string&)>(); |
1008 } | 1010 } |
1009 } | 1011 } |
1010 | 1012 |
1011 void AutofillDialogControllerImpl::OnSubmit() { | 1013 void AutofillDialogControllerImpl::OnSubmit() { |
1012 did_submit_ = true; | 1014 did_submit_ = true; |
1013 metric_logger_.LogDialogUiDuration( | 1015 metric_logger_.LogDialogUiDuration( |
1014 base::Time::Now() - dialog_shown_timestamp_, | 1016 base::Time::Now() - dialog_shown_timestamp_, |
1015 dialog_type_, | 1017 dialog_type_, |
1016 AutofillMetrics::DIALOG_ACCEPTED); | 1018 AutofillMetrics::DIALOG_ACCEPTED); |
1017 | 1019 |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1707 if (ShouldUseBillingForShipping()) { | 1709 if (ShouldUseBillingForShipping()) { |
1708 FillOutputForSectionWithComparator( | 1710 FillOutputForSectionWithComparator( |
1709 SECTION_BILLING, | 1711 SECTION_BILLING, |
1710 base::Bind(DetailInputMatchesShippingField)); | 1712 base::Bind(DetailInputMatchesShippingField)); |
1711 FillOutputForSectionWithComparator( | 1713 FillOutputForSectionWithComparator( |
1712 SECTION_CC, | 1714 SECTION_CC, |
1713 base::Bind(DetailInputMatchesShippingField)); | 1715 base::Bind(DetailInputMatchesShippingField)); |
1714 } else { | 1716 } else { |
1715 FillOutputForSection(SECTION_SHIPPING); | 1717 FillOutputForSection(SECTION_SHIPPING); |
1716 } | 1718 } |
1717 callback_.Run(&form_structure_); | 1719 if (wallet_items_) |
1718 callback_ = base::Callback<void(const FormStructure*)>(); | 1720 callback_.Run(&form_structure_, wallet_items_->google_transaction_id()); |
| 1721 else |
| 1722 callback_.Run(&form_structure_, std::string()); |
| 1723 callback_ = base::Callback<void(const FormStructure*, const std::string&)>(); |
1719 | 1724 |
1720 if (dialog_type_ == DIALOG_TYPE_REQUEST_AUTOCOMPLETE) { | 1725 if (dialog_type_ == DIALOG_TYPE_REQUEST_AUTOCOMPLETE) { |
1721 // This may delete us. | 1726 // This may delete us. |
1722 Hide(); | 1727 Hide(); |
1723 } | 1728 } |
1724 } | 1729 } |
1725 | 1730 |
1726 AutofillMetrics::DialogInitialUserStateMetric | 1731 AutofillMetrics::DialogInitialUserStateMetric |
1727 AutofillDialogControllerImpl::GetInitialUserState() const { | 1732 AutofillDialogControllerImpl::GetInitialUserState() const { |
1728 // Consider a user to be an Autofill user if the user has any credit cards | 1733 // Consider a user to be an Autofill user if the user has any credit cards |
(...skipping 18 matching lines...) Expand all Loading... |
1747 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL; | 1752 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL; |
1748 } | 1753 } |
1749 | 1754 |
1750 // Has Wallet items. | 1755 // Has Wallet items. |
1751 return has_autofill_profiles ? | 1756 return has_autofill_profiles ? |
1752 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL : | 1757 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL : |
1753 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL; | 1758 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL; |
1754 } | 1759 } |
1755 | 1760 |
1756 } // namespace autofill | 1761 } // namespace autofill |
OLD | NEW |