| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 #include "components/autofill/core/browser/autofill_type.h" | 44 #include "components/autofill/core/browser/autofill_type.h" |
| 45 #include "components/autofill/core/browser/country_names.h" | 45 #include "components/autofill/core/browser/country_names.h" |
| 46 #include "components/autofill/core/browser/credit_card.h" | 46 #include "components/autofill/core/browser/credit_card.h" |
| 47 #include "components/autofill/core/browser/field_types.h" | 47 #include "components/autofill/core/browser/field_types.h" |
| 48 #include "components/autofill/core/browser/form_structure.h" | 48 #include "components/autofill/core/browser/form_structure.h" |
| 49 #include "components/autofill/core/browser/personal_data_manager.h" | 49 #include "components/autofill/core/browser/personal_data_manager.h" |
| 50 #include "components/autofill/core/browser/phone_number.h" | 50 #include "components/autofill/core/browser/phone_number.h" |
| 51 #include "components/autofill/core/browser/phone_number_i18n.h" | 51 #include "components/autofill/core/browser/phone_number_i18n.h" |
| 52 #include "components/autofill/core/browser/popup_item_ids.h" | 52 #include "components/autofill/core/browser/popup_item_ids.h" |
| 53 #include "components/autofill/core/browser/validation.h" | 53 #include "components/autofill/core/browser/validation.h" |
| 54 #include "components/autofill/core/common/autofill_clock.h" |
| 54 #include "components/autofill/core/common/autofill_constants.h" | 55 #include "components/autofill/core/common/autofill_constants.h" |
| 55 #include "components/autofill/core/common/autofill_data_validation.h" | 56 #include "components/autofill/core/common/autofill_data_validation.h" |
| 56 #include "components/autofill/core/common/autofill_pref_names.h" | 57 #include "components/autofill/core/common/autofill_pref_names.h" |
| 57 #include "components/autofill/core/common/autofill_util.h" | 58 #include "components/autofill/core/common/autofill_util.h" |
| 58 #include "components/autofill/core/common/form_data.h" | 59 #include "components/autofill/core/common/form_data.h" |
| 59 #include "components/autofill/core/common/form_data_predictions.h" | 60 #include "components/autofill/core/common/form_data_predictions.h" |
| 60 #include "components/autofill/core/common/form_field_data.h" | 61 #include "components/autofill/core/common/form_field_data.h" |
| 61 #include "components/autofill/core/common/password_form_fill_data.h" | 62 #include "components/autofill/core/common/password_form_fill_data.h" |
| 62 #include "components/pref_registry/pref_registry_syncable.h" | 63 #include "components/pref_registry/pref_registry_syncable.h" |
| 63 #include "components/prefs/pref_service.h" | 64 #include "components/prefs/pref_service.h" |
| (...skipping 1131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1195 // All required data is available, start the upload process. | 1196 // All required data is available, start the upload process. |
| 1196 payments_client_->GetUploadDetails(upload_request_.profiles, app_locale_); | 1197 payments_client_->GetUploadDetails(upload_request_.profiles, app_locale_); |
| 1197 } | 1198 } |
| 1198 } | 1199 } |
| 1199 | 1200 |
| 1200 bool AutofillManager::GetProfilesForCreditCardUpload( | 1201 bool AutofillManager::GetProfilesForCreditCardUpload( |
| 1201 const CreditCard& card, | 1202 const CreditCard& card, |
| 1202 std::vector<AutofillProfile>* profiles, | 1203 std::vector<AutofillProfile>* profiles, |
| 1203 const GURL& source_url) const { | 1204 const GURL& source_url) const { |
| 1204 std::vector<AutofillProfile> candidate_profiles; | 1205 std::vector<AutofillProfile> candidate_profiles; |
| 1205 const base::Time now = base::Time::Now(); | 1206 const base::Time now = AutofillClock::Now(); |
| 1206 const base::TimeDelta fifteen_minutes = base::TimeDelta::FromMinutes(15); | 1207 const base::TimeDelta fifteen_minutes = base::TimeDelta::FromMinutes(15); |
| 1207 | 1208 |
| 1208 // First, collect all of the addresses used recently. | 1209 // First, collect all of the addresses used recently. |
| 1209 for (AutofillProfile* profile : personal_data_->GetProfiles()) { | 1210 for (AutofillProfile* profile : personal_data_->GetProfiles()) { |
| 1210 if ((now - profile->use_date()) < fifteen_minutes || | 1211 if ((now - profile->use_date()) < fifteen_minutes || |
| 1211 (now - profile->modification_date()) < fifteen_minutes) { | 1212 (now - profile->modification_date()) < fifteen_minutes) { |
| 1212 candidate_profiles.push_back(*profile); | 1213 candidate_profiles.push_back(*profile); |
| 1213 } | 1214 } |
| 1214 } | 1215 } |
| 1215 if (candidate_profiles.empty()) { | 1216 if (candidate_profiles.empty()) { |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1563 | 1564 |
| 1564 base::string16 value = | 1565 base::string16 value = |
| 1565 data_model.GetInfo(cached_field->Type(), app_locale_); | 1566 data_model.GetInfo(cached_field->Type(), app_locale_); |
| 1566 if (is_credit_card && | 1567 if (is_credit_card && |
| 1567 cached_field->Type().GetStorableType() == | 1568 cached_field->Type().GetStorableType() == |
| 1568 CREDIT_CARD_VERIFICATION_CODE) { | 1569 CREDIT_CARD_VERIFICATION_CODE) { |
| 1569 value = cvc; | 1570 value = cvc; |
| 1570 } else if (is_credit_card && IsCreditCardExpirationType( | 1571 } else if (is_credit_card && IsCreditCardExpirationType( |
| 1571 cached_field->Type().GetStorableType()) && | 1572 cached_field->Type().GetStorableType()) && |
| 1572 static_cast<const CreditCard*>(&data_model) | 1573 static_cast<const CreditCard*>(&data_model) |
| 1573 ->IsExpired(base::Time::Now())) { | 1574 ->IsExpired(AutofillClock::Now())) { |
| 1574 // Don't fill expired cards expiration date. | 1575 // Don't fill expired cards expiration date. |
| 1575 value = base::string16(); | 1576 value = base::string16(); |
| 1576 } | 1577 } |
| 1577 | 1578 |
| 1578 // Must match ForEachMatchingFormField() in form_autofill_util.cc. | 1579 // Must match ForEachMatchingFormField() in form_autofill_util.cc. |
| 1579 // Only notify autofilling of empty fields and the field that initiated | 1580 // Only notify autofilling of empty fields and the field that initiated |
| 1580 // the filling (note that "select-one" controls may not be empty but will | 1581 // the filling (note that "select-one" controls may not be empty but will |
| 1581 // still be autofilled). | 1582 // still be autofilled). |
| 1582 bool should_notify = | 1583 bool should_notify = |
| 1583 !is_credit_card && | 1584 !is_credit_card && |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1861 #if defined(OS_ANDROID) || defined(OS_IOS) | 1862 #if defined(OS_ANDROID) || defined(OS_IOS) |
| 1862 // When a credit card form is parsed and conditions are met, show an infobar | 1863 // When a credit card form is parsed and conditions are met, show an infobar |
| 1863 // prompt for credit card assisted filling. Upon accepting the infobar, the | 1864 // prompt for credit card assisted filling. Upon accepting the infobar, the |
| 1864 // form will automatically be filled with the user's information through this | 1865 // form will automatically be filled with the user's information through this |
| 1865 // class' FillCreditCardForm(). | 1866 // class' FillCreditCardForm(). |
| 1866 if (autofill_assistant_.CanShowCreditCardAssist(form_structures_)) { | 1867 if (autofill_assistant_.CanShowCreditCardAssist(form_structures_)) { |
| 1867 const std::vector<CreditCard*> cards = | 1868 const std::vector<CreditCard*> cards = |
| 1868 personal_data_->GetCreditCardsToSuggest(); | 1869 personal_data_->GetCreditCardsToSuggest(); |
| 1869 // Expired cards are last in the sorted order, so if the first one is | 1870 // Expired cards are last in the sorted order, so if the first one is |
| 1870 // expired, they all are. | 1871 // expired, they all are. |
| 1871 if (!cards.empty() && !cards.front()->IsExpired(base::Time::Now())) | 1872 if (!cards.empty() && !cards.front()->IsExpired(AutofillClock::Now())) |
| 1872 autofill_assistant_.ShowAssistForCreditCard(*cards.front()); | 1873 autofill_assistant_.ShowAssistForCreditCard(*cards.front()); |
| 1873 } | 1874 } |
| 1874 #endif | 1875 #endif |
| 1875 | 1876 |
| 1876 // For the |non_queryable_forms|, we have all the field type info we're ever | 1877 // For the |non_queryable_forms|, we have all the field type info we're ever |
| 1877 // going to get about them. For the other forms, we'll wait until we get a | 1878 // going to get about them. For the other forms, we'll wait until we get a |
| 1878 // response from the server. | 1879 // response from the server. |
| 1879 driver_->SendAutofillTypePredictionsToRenderer(non_queryable_forms); | 1880 driver_->SendAutofillTypePredictionsToRenderer(non_queryable_forms); |
| 1880 } | 1881 } |
| 1881 | 1882 |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2142 if (i > 0) | 2143 if (i > 0) |
| 2143 fputs("Next oldest form:\n", file); | 2144 fputs("Next oldest form:\n", file); |
| 2144 } | 2145 } |
| 2145 fputs("\n", file); | 2146 fputs("\n", file); |
| 2146 | 2147 |
| 2147 fclose(file); | 2148 fclose(file); |
| 2148 } | 2149 } |
| 2149 #endif // ENABLE_FORM_DEBUG_DUMP | 2150 #endif // ENABLE_FORM_DEBUG_DUMP |
| 2150 | 2151 |
| 2151 } // namespace autofill | 2152 } // namespace autofill |
| OLD | NEW |