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 #if defined(OS_ANDROID) |
| 213 assist_manager_(this), |
| 214 #endif |
212 weak_ptr_factory_(this) { | 215 weak_ptr_factory_(this) { |
213 if (enable_download_manager == ENABLE_AUTOFILL_DOWNLOAD_MANAGER) { | 216 if (enable_download_manager == ENABLE_AUTOFILL_DOWNLOAD_MANAGER) { |
214 download_manager_.reset(new AutofillDownloadManager(driver, this)); | 217 download_manager_.reset(new AutofillDownloadManager(driver, this)); |
215 } | 218 } |
216 CountryNames::SetLocaleString(app_locale_); | 219 CountryNames::SetLocaleString(app_locale_); |
217 if (personal_data_ && client_) | 220 if (personal_data_ && client_) |
218 personal_data_->OnSyncServiceInitialized(client_->GetSyncService()); | 221 personal_data_->OnSyncServiceInitialized(client_->GetSyncService()); |
219 } | 222 } |
220 | 223 |
221 AutofillManager::~AutofillManager() {} | 224 AutofillManager::~AutofillManager() {} |
(...skipping 1062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1284 void AutofillManager::Reset() { | 1287 void AutofillManager::Reset() { |
1285 // Note that upload_request_ is not reset here because the prompt to | 1288 // Note that upload_request_ is not reset here because the prompt to |
1286 // save a card is shown after page navigation. | 1289 // save a card is shown after page navigation. |
1287 ProcessPendingFormForUpload(); | 1290 ProcessPendingFormForUpload(); |
1288 DCHECK(!pending_form_data_); | 1291 DCHECK(!pending_form_data_); |
1289 form_structures_.clear(); | 1292 form_structures_.clear(); |
1290 address_form_event_logger_.reset( | 1293 address_form_event_logger_.reset( |
1291 new AutofillMetrics::FormEventLogger(false /* is_for_credit_card */)); | 1294 new AutofillMetrics::FormEventLogger(false /* is_for_credit_card */)); |
1292 credit_card_form_event_logger_.reset( | 1295 credit_card_form_event_logger_.reset( |
1293 new AutofillMetrics::FormEventLogger(true /* is_for_credit_card */)); | 1296 new AutofillMetrics::FormEventLogger(true /* is_for_credit_card */)); |
| 1297 #if defined(OS_ANDROID) |
| 1298 assist_manager_.Reset(); |
| 1299 #endif |
1294 has_logged_autofill_enabled_ = false; | 1300 has_logged_autofill_enabled_ = false; |
1295 has_logged_address_suggestions_count_ = false; | 1301 has_logged_address_suggestions_count_ = false; |
1296 did_show_suggestions_ = false; | 1302 did_show_suggestions_ = false; |
1297 user_did_type_ = false; | 1303 user_did_type_ = false; |
1298 user_did_autofill_ = false; | 1304 user_did_autofill_ = false; |
1299 user_did_edit_autofilled_field_ = false; | 1305 user_did_edit_autofilled_field_ = false; |
1300 masked_card_ = CreditCard(); | 1306 masked_card_ = CreditCard(); |
1301 unmasking_query_id_ = -1; | 1307 unmasking_query_id_ = -1; |
1302 unmasking_form_ = FormData(); | 1308 unmasking_form_ = FormData(); |
1303 unmasking_field_ = FormFieldData(); | 1309 unmasking_field_ = FormFieldData(); |
(...skipping 19 matching lines...) Expand all Loading... |
1323 new AutofillMetrics::FormEventLogger(true /* is_for_credit_card */)), | 1329 new AutofillMetrics::FormEventLogger(true /* is_for_credit_card */)), |
1324 has_logged_autofill_enabled_(false), | 1330 has_logged_autofill_enabled_(false), |
1325 has_logged_address_suggestions_count_(false), | 1331 has_logged_address_suggestions_count_(false), |
1326 did_show_suggestions_(false), | 1332 did_show_suggestions_(false), |
1327 user_did_type_(false), | 1333 user_did_type_(false), |
1328 user_did_autofill_(false), | 1334 user_did_autofill_(false), |
1329 user_did_edit_autofilled_field_(false), | 1335 user_did_edit_autofilled_field_(false), |
1330 unmasking_query_id_(-1), | 1336 unmasking_query_id_(-1), |
1331 external_delegate_(NULL), | 1337 external_delegate_(NULL), |
1332 test_delegate_(NULL), | 1338 test_delegate_(NULL), |
| 1339 #if defined(OS_ANDROID) |
| 1340 assist_manager_(this), |
| 1341 #endif |
1333 weak_ptr_factory_(this) { | 1342 weak_ptr_factory_(this) { |
1334 DCHECK(driver_); | 1343 DCHECK(driver_); |
1335 DCHECK(client_); | 1344 DCHECK(client_); |
1336 CountryNames::SetLocaleString(app_locale_); | 1345 CountryNames::SetLocaleString(app_locale_); |
1337 } | 1346 } |
1338 | 1347 |
1339 bool AutofillManager::RefreshDataModels() { | 1348 bool AutofillManager::RefreshDataModels() { |
1340 if (!IsAutofillEnabled()) | 1349 if (!IsAutofillEnabled()) |
1341 return false; | 1350 return false; |
1342 | 1351 |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1771 if (!queryable_forms.empty() || !non_queryable_forms.empty()) { | 1780 if (!queryable_forms.empty() || !non_queryable_forms.empty()) { |
1772 AutofillMetrics::LogUserHappinessMetric(AutofillMetrics::FORMS_LOADED); | 1781 AutofillMetrics::LogUserHappinessMetric(AutofillMetrics::FORMS_LOADED); |
1773 #if defined(OS_IOS) | 1782 #if defined(OS_IOS) |
1774 // Log this from same location as AutofillMetrics::FORMS_LOADED to ensure | 1783 // Log this from same location as AutofillMetrics::FORMS_LOADED to ensure |
1775 // that KeyboardAccessoryButtonsIOS and UserHappiness UMA metrics will be | 1784 // that KeyboardAccessoryButtonsIOS and UserHappiness UMA metrics will be |
1776 // directly comparable. | 1785 // directly comparable. |
1777 KeyboardAccessoryMetricsLogger::OnFormsLoaded(); | 1786 KeyboardAccessoryMetricsLogger::OnFormsLoaded(); |
1778 #endif | 1787 #endif |
1779 } | 1788 } |
1780 | 1789 |
| 1790 #if defined(OS_ANDROID) |
| 1791 if (assist_manager_.CanShowCreditCardAssist(form_structures_.get())) { |
| 1792 const std::vector<CreditCard*> cards = |
| 1793 personal_data_->GetCreditCardsToSuggest(); |
| 1794 // Expired cards are last in the sorted order, so if the first one is |
| 1795 // expired, they all are. |
| 1796 if (!cards.empty() && !cards.front()->IsExpired(base::Time::Now())) |
| 1797 assist_manager_.ShowAssistForCreditCard(*cards.front()); |
| 1798 } |
| 1799 #endif |
| 1800 |
1781 // For the |non_queryable_forms|, we have all the field type info we're ever | 1801 // 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 | 1802 // going to get about them. For the other forms, we'll wait until we get a |
1783 // response from the server. | 1803 // response from the server. |
1784 driver_->SendAutofillTypePredictionsToRenderer(non_queryable_forms); | 1804 driver_->SendAutofillTypePredictionsToRenderer(non_queryable_forms); |
1785 } | 1805 } |
1786 | 1806 |
1787 int AutofillManager::BackendIDToInt(const std::string& backend_id) const { | 1807 int AutofillManager::BackendIDToInt(const std::string& backend_id) const { |
1788 if (!base::IsValidGUID(backend_id)) | 1808 if (!base::IsValidGUID(backend_id)) |
1789 return 0; | 1809 return 0; |
1790 | 1810 |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2047 if (i > 0) | 2067 if (i > 0) |
2048 fputs("Next oldest form:\n", file); | 2068 fputs("Next oldest form:\n", file); |
2049 } | 2069 } |
2050 fputs("\n", file); | 2070 fputs("\n", file); |
2051 | 2071 |
2052 fclose(file); | 2072 fclose(file); |
2053 } | 2073 } |
2054 #endif // ENABLE_FORM_DEBUG_DUMP | 2074 #endif // ENABLE_FORM_DEBUG_DUMP |
2055 | 2075 |
2056 } // namespace autofill | 2076 } // namespace autofill |
OLD | NEW |