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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 | 118 |
119 } // namespace | 119 } // namespace |
120 | 120 |
121 AutofillDialogController::~AutofillDialogController() {} | 121 AutofillDialogController::~AutofillDialogController() {} |
122 | 122 |
123 AutofillDialogControllerImpl::AutofillDialogControllerImpl( | 123 AutofillDialogControllerImpl::AutofillDialogControllerImpl( |
124 content::WebContents* contents, | 124 content::WebContents* contents, |
125 const FormData& form, | 125 const FormData& form, |
126 const GURL& source_url, | 126 const GURL& source_url, |
127 const content::SSLStatus& ssl_status, | 127 const content::SSLStatus& ssl_status, |
| 128 const AutofillMetrics& metric_logger, |
| 129 DialogType dialog_type, |
128 const base::Callback<void(const FormStructure*)>& callback) | 130 const base::Callback<void(const FormStructure*)>& callback) |
129 : profile_(Profile::FromBrowserContext(contents->GetBrowserContext())), | 131 : profile_(Profile::FromBrowserContext(contents->GetBrowserContext())), |
130 contents_(contents), | 132 contents_(contents), |
131 form_structure_(form), | 133 form_structure_(form), |
132 source_url_(source_url), | 134 source_url_(source_url), |
133 ssl_status_(ssl_status), | 135 ssl_status_(ssl_status), |
134 callback_(callback), | 136 callback_(callback), |
135 wallet_client_(profile_->GetRequestContext()), | 137 wallet_client_(profile_->GetRequestContext()), |
136 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_email_(this)), | 138 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_email_(this)), |
137 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_cc_(this)), | 139 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_cc_(this)), |
138 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_billing_(this)), | 140 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_billing_(this)), |
139 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_shipping_(this)), | 141 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_shipping_(this)), |
140 popup_controller_(NULL), | 142 popup_controller_(NULL), |
141 section_showing_popup_(SECTION_BILLING) { | 143 section_showing_popup_(SECTION_BILLING), |
| 144 metric_logger_(metric_logger), |
| 145 dialog_type_(dialog_type) { |
142 // TODO(estade): |this| should observe PersonalDataManager. | 146 // TODO(estade): |this| should observe PersonalDataManager. |
143 // TODO(estade): remove duplicates from |form|? | 147 // TODO(estade): remove duplicates from |form|? |
144 | 148 |
145 content::NavigationEntry* entry = contents->GetController().GetActiveEntry(); | 149 content::NavigationEntry* entry = contents->GetController().GetActiveEntry(); |
146 const GURL& active_url = entry ? entry->GetURL() : web_contents()->GetURL(); | 150 const GURL& active_url = entry ? entry->GetURL() : web_contents()->GetURL(); |
147 invoked_from_same_origin_ = active_url.GetOrigin() == source_url_.GetOrigin(); | 151 invoked_from_same_origin_ = active_url.GetOrigin() == source_url_.GetOrigin(); |
148 } | 152 } |
149 | 153 |
150 AutofillDialogControllerImpl::~AutofillDialogControllerImpl() { | 154 AutofillDialogControllerImpl::~AutofillDialogControllerImpl() { |
151 if (popup_controller_) | 155 if (popup_controller_) |
152 popup_controller_->Hide(); | 156 popup_controller_->Hide(); |
153 } | 157 } |
154 | 158 |
155 void AutofillDialogControllerImpl::Show() { | 159 void AutofillDialogControllerImpl::Show() { |
| 160 dialog_shown_timestamp_ = base::Time::Now(); |
| 161 |
156 bool has_types = false; | 162 bool has_types = false; |
157 bool has_sections = false; | 163 bool has_sections = false; |
158 form_structure_.ParseFieldTypesFromAutocompleteAttributes(&has_types, | 164 form_structure_.ParseFieldTypesFromAutocompleteAttributes(&has_types, |
159 &has_sections); | 165 &has_sections); |
160 // Fail if the author didn't specify autocomplete types. | 166 // Fail if the author didn't specify autocomplete types. |
161 if (!has_types) { | 167 if (!has_types) { |
162 callback_.Run(NULL); | 168 callback_.Run(NULL); |
163 delete this; | 169 delete this; |
164 return; | 170 return; |
165 } | 171 } |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 SECTION_CC, | 526 SECTION_CC, |
521 base::Bind(DetailInputMatchesShippingField)); | 527 base::Bind(DetailInputMatchesShippingField)); |
522 } else { | 528 } else { |
523 FillOutputForSection(SECTION_SHIPPING); | 529 FillOutputForSection(SECTION_SHIPPING); |
524 } | 530 } |
525 callback_.Run(&form_structure_); | 531 callback_.Run(&form_structure_); |
526 } else { | 532 } else { |
527 callback_.Run(NULL); | 533 callback_.Run(NULL); |
528 } | 534 } |
529 | 535 |
| 536 AutofillMetrics::DialogDismissalAction metric = |
| 537 action == ACTION_SUBMIT ? |
| 538 AutofillMetrics::DIALOG_ACCEPTED : |
| 539 AutofillMetrics::DIALOG_CANCELED; |
| 540 metric_logger_.LogRequestAutocompleteUiDuration( |
| 541 base::Time::Now() - dialog_shown_timestamp_, dialog_type_, metric); |
| 542 |
530 delete this; | 543 delete this; |
531 } | 544 } |
532 | 545 |
533 void AutofillDialogControllerImpl::UpdateProgressBar(double value) { | 546 void AutofillDialogControllerImpl::UpdateProgressBar(double value) { |
534 view_->UpdateProgressBar(value); | 547 view_->UpdateProgressBar(value); |
535 } | 548 } |
536 | 549 |
537 DialogNotification AutofillDialogControllerImpl::CurrentNotification() const { | 550 DialogNotification AutofillDialogControllerImpl::CurrentNotification() const { |
538 if (HasRequiredAction(wallet::VERIFY_CVV)) { | 551 if (HasRequiredAction(wallet::VERIFY_CVV)) { |
539 return DialogNotification( | 552 return DialogNotification( |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
933 } | 946 } |
934 | 947 |
935 void AutofillDialogControllerImpl::HidePopup() { | 948 void AutofillDialogControllerImpl::HidePopup() { |
936 if (popup_controller_) { | 949 if (popup_controller_) { |
937 popup_controller_->Hide(); | 950 popup_controller_->Hide(); |
938 ControllerDestroyed(); | 951 ControllerDestroyed(); |
939 } | 952 } |
940 } | 953 } |
941 | 954 |
942 } // namespace autofill | 955 } // namespace autofill |
OLD | NEW |