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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 new AutofillMetrics::FormEventLogger(true /* is_for_credit_card */)), | 201 new AutofillMetrics::FormEventLogger(true /* is_for_credit_card */)), |
202 has_logged_autofill_enabled_(false), | 202 has_logged_autofill_enabled_(false), |
203 has_logged_address_suggestions_count_(false), | 203 has_logged_address_suggestions_count_(false), |
204 did_show_suggestions_(false), | 204 did_show_suggestions_(false), |
205 user_did_type_(false), | 205 user_did_type_(false), |
206 user_did_autofill_(false), | 206 user_did_autofill_(false), |
207 user_did_edit_autofilled_field_(false), | 207 user_did_edit_autofilled_field_(false), |
208 user_did_accept_upload_prompt_(false), | 208 user_did_accept_upload_prompt_(false), |
209 external_delegate_(NULL), | 209 external_delegate_(NULL), |
210 test_delegate_(NULL), | 210 test_delegate_(NULL), |
| 211 #if defined(OS_ANDROID) |
| 212 autofill_assistant_(this), |
| 213 #endif |
211 weak_ptr_factory_(this) { | 214 weak_ptr_factory_(this) { |
212 if (enable_download_manager == ENABLE_AUTOFILL_DOWNLOAD_MANAGER) { | 215 if (enable_download_manager == ENABLE_AUTOFILL_DOWNLOAD_MANAGER) { |
213 download_manager_.reset(new AutofillDownloadManager(driver, this)); | 216 download_manager_.reset(new AutofillDownloadManager(driver, this)); |
214 } | 217 } |
215 CountryNames::SetLocaleString(app_locale_); | 218 CountryNames::SetLocaleString(app_locale_); |
216 if (personal_data_ && client_) | 219 if (personal_data_ && client_) |
217 personal_data_->OnSyncServiceInitialized(client_->GetSyncService()); | 220 personal_data_->OnSyncServiceInitialized(client_->GetSyncService()); |
218 } | 221 } |
219 | 222 |
220 AutofillManager::~AutofillManager() {} | 223 AutofillManager::~AutofillManager() {} |
(...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1278 void AutofillManager::Reset() { | 1281 void AutofillManager::Reset() { |
1279 // Note that upload_request_ is not reset here because the prompt to | 1282 // Note that upload_request_ is not reset here because the prompt to |
1280 // save a card is shown after page navigation. | 1283 // save a card is shown after page navigation. |
1281 ProcessPendingFormForUpload(); | 1284 ProcessPendingFormForUpload(); |
1282 DCHECK(!pending_form_data_); | 1285 DCHECK(!pending_form_data_); |
1283 form_structures_.clear(); | 1286 form_structures_.clear(); |
1284 address_form_event_logger_.reset( | 1287 address_form_event_logger_.reset( |
1285 new AutofillMetrics::FormEventLogger(false /* is_for_credit_card */)); | 1288 new AutofillMetrics::FormEventLogger(false /* is_for_credit_card */)); |
1286 credit_card_form_event_logger_.reset( | 1289 credit_card_form_event_logger_.reset( |
1287 new AutofillMetrics::FormEventLogger(true /* is_for_credit_card */)); | 1290 new AutofillMetrics::FormEventLogger(true /* is_for_credit_card */)); |
| 1291 #if defined(OS_ANDROID) |
| 1292 autofill_assistant_.Reset(); |
| 1293 #endif |
1288 has_logged_autofill_enabled_ = false; | 1294 has_logged_autofill_enabled_ = false; |
1289 has_logged_address_suggestions_count_ = false; | 1295 has_logged_address_suggestions_count_ = false; |
1290 did_show_suggestions_ = false; | 1296 did_show_suggestions_ = false; |
1291 user_did_type_ = false; | 1297 user_did_type_ = false; |
1292 user_did_autofill_ = false; | 1298 user_did_autofill_ = false; |
1293 user_did_edit_autofilled_field_ = false; | 1299 user_did_edit_autofilled_field_ = false; |
1294 masked_card_ = CreditCard(); | 1300 masked_card_ = CreditCard(); |
1295 unmasking_query_id_ = -1; | 1301 unmasking_query_id_ = -1; |
1296 unmasking_form_ = FormData(); | 1302 unmasking_form_ = FormData(); |
1297 unmasking_field_ = FormFieldData(); | 1303 unmasking_field_ = FormFieldData(); |
(...skipping 19 matching lines...) Expand all Loading... |
1317 new AutofillMetrics::FormEventLogger(true /* is_for_credit_card */)), | 1323 new AutofillMetrics::FormEventLogger(true /* is_for_credit_card */)), |
1318 has_logged_autofill_enabled_(false), | 1324 has_logged_autofill_enabled_(false), |
1319 has_logged_address_suggestions_count_(false), | 1325 has_logged_address_suggestions_count_(false), |
1320 did_show_suggestions_(false), | 1326 did_show_suggestions_(false), |
1321 user_did_type_(false), | 1327 user_did_type_(false), |
1322 user_did_autofill_(false), | 1328 user_did_autofill_(false), |
1323 user_did_edit_autofilled_field_(false), | 1329 user_did_edit_autofilled_field_(false), |
1324 unmasking_query_id_(-1), | 1330 unmasking_query_id_(-1), |
1325 external_delegate_(NULL), | 1331 external_delegate_(NULL), |
1326 test_delegate_(NULL), | 1332 test_delegate_(NULL), |
| 1333 #if defined(OS_ANDROID) |
| 1334 autofill_assistant_(this), |
| 1335 #endif |
1327 weak_ptr_factory_(this) { | 1336 weak_ptr_factory_(this) { |
1328 DCHECK(driver_); | 1337 DCHECK(driver_); |
1329 DCHECK(client_); | 1338 DCHECK(client_); |
1330 CountryNames::SetLocaleString(app_locale_); | 1339 CountryNames::SetLocaleString(app_locale_); |
1331 } | 1340 } |
1332 | 1341 |
1333 bool AutofillManager::RefreshDataModels() { | 1342 bool AutofillManager::RefreshDataModels() { |
1334 if (!IsAutofillEnabled()) | 1343 if (!IsAutofillEnabled()) |
1335 return false; | 1344 return false; |
1336 | 1345 |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1765 if (!queryable_forms.empty() || !non_queryable_forms.empty()) { | 1774 if (!queryable_forms.empty() || !non_queryable_forms.empty()) { |
1766 AutofillMetrics::LogUserHappinessMetric(AutofillMetrics::FORMS_LOADED); | 1775 AutofillMetrics::LogUserHappinessMetric(AutofillMetrics::FORMS_LOADED); |
1767 #if defined(OS_IOS) | 1776 #if defined(OS_IOS) |
1768 // Log this from same location as AutofillMetrics::FORMS_LOADED to ensure | 1777 // Log this from same location as AutofillMetrics::FORMS_LOADED to ensure |
1769 // that KeyboardAccessoryButtonsIOS and UserHappiness UMA metrics will be | 1778 // that KeyboardAccessoryButtonsIOS and UserHappiness UMA metrics will be |
1770 // directly comparable. | 1779 // directly comparable. |
1771 KeyboardAccessoryMetricsLogger::OnFormsLoaded(); | 1780 KeyboardAccessoryMetricsLogger::OnFormsLoaded(); |
1772 #endif | 1781 #endif |
1773 } | 1782 } |
1774 | 1783 |
| 1784 #if defined(OS_ANDROID) |
| 1785 // When a credit card form is parsed and conditions are met, show an infobar |
| 1786 // prompt for credit card assisted filling. Upon accepting the infobar, the |
| 1787 // form will automatically be filled with the user's information through this |
| 1788 // class' FillCreditCardForm(). |
| 1789 if (autofill_assistant_.CanShowCreditCardAssist(form_structures_.get())) { |
| 1790 const std::vector<CreditCard*> cards = |
| 1791 personal_data_->GetCreditCardsToSuggest(); |
| 1792 // Expired cards are last in the sorted order, so if the first one is |
| 1793 // expired, they all are. |
| 1794 if (!cards.empty() && !cards.front()->IsExpired(base::Time::Now())) |
| 1795 autofill_assistant_.ShowAssistForCreditCard(*cards.front()); |
| 1796 } |
| 1797 #endif |
| 1798 |
1775 // For the |non_queryable_forms|, we have all the field type info we're ever | 1799 // For the |non_queryable_forms|, we have all the field type info we're ever |
1776 // going to get about them. For the other forms, we'll wait until we get a | 1800 // going to get about them. For the other forms, we'll wait until we get a |
1777 // response from the server. | 1801 // response from the server. |
1778 driver_->SendAutofillTypePredictionsToRenderer(non_queryable_forms); | 1802 driver_->SendAutofillTypePredictionsToRenderer(non_queryable_forms); |
1779 } | 1803 } |
1780 | 1804 |
1781 int AutofillManager::BackendIDToInt(const std::string& backend_id) const { | 1805 int AutofillManager::BackendIDToInt(const std::string& backend_id) const { |
1782 if (!base::IsValidGUID(backend_id)) | 1806 if (!base::IsValidGUID(backend_id)) |
1783 return 0; | 1807 return 0; |
1784 | 1808 |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2041 if (i > 0) | 2065 if (i > 0) |
2042 fputs("Next oldest form:\n", file); | 2066 fputs("Next oldest form:\n", file); |
2043 } | 2067 } |
2044 fputs("\n", file); | 2068 fputs("\n", file); |
2045 | 2069 |
2046 fclose(file); | 2070 fclose(file); |
2047 } | 2071 } |
2048 #endif // ENABLE_FORM_DEBUG_DUMP | 2072 #endif // ENABLE_FORM_DEBUG_DUMP |
2049 | 2073 |
2050 } // namespace autofill | 2074 } // namespace autofill |
OLD | NEW |