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 "components/autofill/core/browser/autofill_manager.h" | 5 #include "components/autofill/core/browser/autofill_manager.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
202 new AutofillMetrics::FormEventLogger(true /* is_for_credit_card */)), | 202 new AutofillMetrics::FormEventLogger(true /* is_for_credit_card */)), |
203 has_logged_autofill_enabled_(false), | 203 has_logged_autofill_enabled_(false), |
204 has_logged_address_suggestions_count_(false), | 204 has_logged_address_suggestions_count_(false), |
205 did_show_suggestions_(false), | 205 did_show_suggestions_(false), |
206 user_did_type_(false), | 206 user_did_type_(false), |
207 user_did_autofill_(false), | 207 user_did_autofill_(false), |
208 user_did_edit_autofilled_field_(false), | 208 user_did_edit_autofilled_field_(false), |
209 user_did_accept_upload_prompt_(false), | 209 user_did_accept_upload_prompt_(false), |
210 external_delegate_(NULL), | 210 external_delegate_(NULL), |
211 test_delegate_(NULL), | 211 test_delegate_(NULL), |
212 assist_manager_(this), | |
212 weak_ptr_factory_(this) { | 213 weak_ptr_factory_(this) { |
213 if (enable_download_manager == ENABLE_AUTOFILL_DOWNLOAD_MANAGER) { | 214 if (enable_download_manager == ENABLE_AUTOFILL_DOWNLOAD_MANAGER) { |
214 download_manager_.reset(new AutofillDownloadManager(driver, this)); | 215 download_manager_.reset(new AutofillDownloadManager(driver, this)); |
215 } | 216 } |
216 CountryNames::SetLocaleString(app_locale_); | 217 CountryNames::SetLocaleString(app_locale_); |
217 if (personal_data_ && client_) | 218 if (personal_data_ && client_) |
218 personal_data_->OnSyncServiceInitialized(client_->GetSyncService()); | 219 personal_data_->OnSyncServiceInitialized(client_->GetSyncService()); |
219 } | 220 } |
220 | 221 |
221 AutofillManager::~AutofillManager() {} | 222 AutofillManager::~AutofillManager() {} |
(...skipping 1062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1284 void AutofillManager::Reset() { | 1285 void AutofillManager::Reset() { |
1285 // Note that upload_request_ is not reset here because the prompt to | 1286 // Note that upload_request_ is not reset here because the prompt to |
1286 // save a card is shown after page navigation. | 1287 // save a card is shown after page navigation. |
1287 ProcessPendingFormForUpload(); | 1288 ProcessPendingFormForUpload(); |
1288 DCHECK(!pending_form_data_); | 1289 DCHECK(!pending_form_data_); |
1289 form_structures_.clear(); | 1290 form_structures_.clear(); |
1290 address_form_event_logger_.reset( | 1291 address_form_event_logger_.reset( |
1291 new AutofillMetrics::FormEventLogger(false /* is_for_credit_card */)); | 1292 new AutofillMetrics::FormEventLogger(false /* is_for_credit_card */)); |
1292 credit_card_form_event_logger_.reset( | 1293 credit_card_form_event_logger_.reset( |
1293 new AutofillMetrics::FormEventLogger(true /* is_for_credit_card */)); | 1294 new AutofillMetrics::FormEventLogger(true /* is_for_credit_card */)); |
1295 assist_manager_.Reset(); | |
1294 has_logged_autofill_enabled_ = false; | 1296 has_logged_autofill_enabled_ = false; |
1295 has_logged_address_suggestions_count_ = false; | 1297 has_logged_address_suggestions_count_ = false; |
1296 did_show_suggestions_ = false; | 1298 did_show_suggestions_ = false; |
1297 user_did_type_ = false; | 1299 user_did_type_ = false; |
1298 user_did_autofill_ = false; | 1300 user_did_autofill_ = false; |
1299 user_did_edit_autofilled_field_ = false; | 1301 user_did_edit_autofilled_field_ = false; |
1300 masked_card_ = CreditCard(); | 1302 masked_card_ = CreditCard(); |
1301 unmasking_query_id_ = -1; | 1303 unmasking_query_id_ = -1; |
1302 unmasking_form_ = FormData(); | 1304 unmasking_form_ = FormData(); |
1303 unmasking_field_ = FormFieldData(); | 1305 unmasking_field_ = FormFieldData(); |
(...skipping 19 matching lines...) Expand all Loading... | |
1323 new AutofillMetrics::FormEventLogger(true /* is_for_credit_card */)), | 1325 new AutofillMetrics::FormEventLogger(true /* is_for_credit_card */)), |
1324 has_logged_autofill_enabled_(false), | 1326 has_logged_autofill_enabled_(false), |
1325 has_logged_address_suggestions_count_(false), | 1327 has_logged_address_suggestions_count_(false), |
1326 did_show_suggestions_(false), | 1328 did_show_suggestions_(false), |
1327 user_did_type_(false), | 1329 user_did_type_(false), |
1328 user_did_autofill_(false), | 1330 user_did_autofill_(false), |
1329 user_did_edit_autofilled_field_(false), | 1331 user_did_edit_autofilled_field_(false), |
1330 unmasking_query_id_(-1), | 1332 unmasking_query_id_(-1), |
1331 external_delegate_(NULL), | 1333 external_delegate_(NULL), |
1332 test_delegate_(NULL), | 1334 test_delegate_(NULL), |
1335 assist_manager_(this), | |
1333 weak_ptr_factory_(this) { | 1336 weak_ptr_factory_(this) { |
1334 DCHECK(driver_); | 1337 DCHECK(driver_); |
1335 DCHECK(client_); | 1338 DCHECK(client_); |
1336 CountryNames::SetLocaleString(app_locale_); | 1339 CountryNames::SetLocaleString(app_locale_); |
1337 } | 1340 } |
1338 | 1341 |
1339 bool AutofillManager::RefreshDataModels() { | 1342 bool AutofillManager::RefreshDataModels() { |
1340 if (!IsAutofillEnabled()) | 1343 if (!IsAutofillEnabled()) |
1341 return false; | 1344 return false; |
1342 | 1345 |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1771 if (!queryable_forms.empty() || !non_queryable_forms.empty()) { | 1774 if (!queryable_forms.empty() || !non_queryable_forms.empty()) { |
1772 AutofillMetrics::LogUserHappinessMetric(AutofillMetrics::FORMS_LOADED); | 1775 AutofillMetrics::LogUserHappinessMetric(AutofillMetrics::FORMS_LOADED); |
1773 #if defined(OS_IOS) | 1776 #if defined(OS_IOS) |
1774 // Log this from same location as AutofillMetrics::FORMS_LOADED to ensure | 1777 // Log this from same location as AutofillMetrics::FORMS_LOADED to ensure |
1775 // that KeyboardAccessoryButtonsIOS and UserHappiness UMA metrics will be | 1778 // that KeyboardAccessoryButtonsIOS and UserHappiness UMA metrics will be |
1776 // directly comparable. | 1779 // directly comparable. |
1777 KeyboardAccessoryMetricsLogger::OnFormsLoaded(); | 1780 KeyboardAccessoryMetricsLogger::OnFormsLoaded(); |
1778 #endif | 1781 #endif |
1779 } | 1782 } |
1780 | 1783 |
1784 if (assist_manager_.CanShowCreditCardAssist(form_structures_.get())) { | |
1785 const std::vector<CreditCard*> cards = | |
1786 personal_data_->GetCreditCardsToSuggest(); | |
1787 // Expired cards are last in the sorted order, so if the first one is | |
1788 // expired, they all are. | |
1789 if (!cards.empty() && !cards[0]->IsExpired(base::Time::Now())) | |
please use gerrit instead
2016/07/29 16:33:20
Nit: Using .front() instead of [0] would be more i
Mathieu
2016/07/29 20:19:17
Done.
| |
1790 assist_manager_.ShowAssistForCreditCard(*cards[0]); | |
please use gerrit instead
2016/07/29 16:33:20
Ditto
Mathieu
2016/07/29 20:19:17
Done.
| |
1791 } | |
1792 | |
1781 // For the |non_queryable_forms|, we have all the field type info we're ever | 1793 // For the |non_queryable_forms|, we have all the field type info we're ever |
1782 // going to get about them. For the other forms, we'll wait until we get a | 1794 // going to get about them. For the other forms, we'll wait until we get a |
1783 // response from the server. | 1795 // response from the server. |
1784 driver_->SendAutofillTypePredictionsToRenderer(non_queryable_forms); | 1796 driver_->SendAutofillTypePredictionsToRenderer(non_queryable_forms); |
1785 } | 1797 } |
1786 | 1798 |
1787 int AutofillManager::BackendIDToInt(const std::string& backend_id) const { | 1799 int AutofillManager::BackendIDToInt(const std::string& backend_id) const { |
1788 if (!base::IsValidGUID(backend_id)) | 1800 if (!base::IsValidGUID(backend_id)) |
1789 return 0; | 1801 return 0; |
1790 | 1802 |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2047 if (i > 0) | 2059 if (i > 0) |
2048 fputs("Next oldest form:\n", file); | 2060 fputs("Next oldest form:\n", file); |
2049 } | 2061 } |
2050 fputs("\n", file); | 2062 fputs("\n", file); |
2051 | 2063 |
2052 fclose(file); | 2064 fclose(file); |
2053 } | 2065 } |
2054 #endif // ENABLE_FORM_DEBUG_DUMP | 2066 #endif // ENABLE_FORM_DEBUG_DUMP |
2055 | 2067 |
2056 } // namespace autofill | 2068 } // namespace autofill |
OLD | NEW |