| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/autofill/personal_data_manager.h" | 5 #include "chrome/browser/autofill/personal_data_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/browser/autofill/autofill-inl.h" | 13 #include "chrome/browser/autofill/autofill-inl.h" |
| 14 #include "chrome/browser/autofill/autofill_field.h" | 14 #include "chrome/browser/autofill/autofill_field.h" |
| 15 #include "chrome/browser/autofill/autofill_metrics.h" | 15 #include "chrome/browser/autofill/autofill_metrics.h" |
| 16 #include "chrome/browser/autofill/autofill_scanner.h" | 16 #include "chrome/browser/autofill/autofill_regexes.h" |
| 17 #include "chrome/browser/autofill/form_structure.h" | 17 #include "chrome/browser/autofill/form_structure.h" |
| 18 #include "chrome/browser/autofill/phone_number.h" | 18 #include "chrome/browser/autofill/phone_number.h" |
| 19 #include "chrome/browser/autofill/phone_number_i18n.h" | 19 #include "chrome/browser/autofill/phone_number_i18n.h" |
| 20 #include "chrome/browser/autofill/select_control_handler.h" | 20 #include "chrome/browser/autofill/select_control_handler.h" |
| 21 #include "chrome/browser/prefs/pref_service.h" | 21 #include "chrome/browser/prefs/pref_service.h" |
| 22 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
| 23 #include "chrome/browser/sync/profile_sync_service.h" | 23 #include "chrome/browser/sync/profile_sync_service.h" |
| 24 #include "chrome/browser/webdata/web_data_service.h" | 24 #include "chrome/browser/webdata/web_data_service.h" |
| 25 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
| 26 #include "content/browser/browser_thread.h" | 26 #include "content/browser/browser_thread.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 | 69 |
| 70 template<typename T> | 70 template<typename T> |
| 71 T* address_of(T& v) { | 71 T* address_of(T& v) { |
| 72 return &v; | 72 return &v; |
| 73 } | 73 } |
| 74 | 74 |
| 75 bool IsValidEmail(const string16& value) { | 75 bool IsValidEmail(const string16& value) { |
| 76 // This regex is more permissive than the official rfc2822 spec on the | 76 // This regex is more permissive than the official rfc2822 spec on the |
| 77 // subject, but it does reject obvious non-email addresses. | 77 // subject, but it does reject obvious non-email addresses. |
| 78 const string16 kEmailPattern = ASCIIToUTF16("^[^@]+@[^@]+\\.[a-z]{2,6}$"); | 78 const string16 kEmailPattern = ASCIIToUTF16("^[^@]+@[^@]+\\.[a-z]{2,6}$"); |
| 79 return autofill::MatchString(value, kEmailPattern); | 79 return autofill::MatchesPattern(value, kEmailPattern); |
| 80 } | 80 } |
| 81 | 81 |
| 82 // Valid for US zip codes only. | 82 // Valid for US zip codes only. |
| 83 bool IsValidZip(const string16& value) { | 83 bool IsValidZip(const string16& value) { |
| 84 // Basic US zip code matching. | 84 // Basic US zip code matching. |
| 85 const string16 kZipPattern = ASCIIToUTF16("^\\d{5}(-\\d{4})?$"); | 85 const string16 kZipPattern = ASCIIToUTF16("^\\d{5}(-\\d{4})?$"); |
| 86 return autofill::MatchString(value, kZipPattern); | 86 return autofill::MatchesPattern(value, kZipPattern); |
| 87 } | 87 } |
| 88 | 88 |
| 89 // Returns true if minimum requirements for import of a given |profile| have | 89 // Returns true if minimum requirements for import of a given |profile| have |
| 90 // been met. An address submitted via a form must have at least these fields | 90 // been met. An address submitted via a form must have at least these fields |
| 91 // filled. No verification of validity of the contents is preformed. This is | 91 // filled. No verification of validity of the contents is preformed. This is |
| 92 // and existence check only. | 92 // and existence check only. |
| 93 bool IsMinimumAddress(const AutofillProfile& profile) { | 93 bool IsMinimumAddress(const AutofillProfile& profile) { |
| 94 return !profile.GetInfo(ADDRESS_HOME_LINE1).empty() && | 94 return !profile.GetInfo(ADDRESS_HOME_LINE1).empty() && |
| 95 !profile.GetInfo(ADDRESS_HOME_CITY).empty() && | 95 !profile.GetInfo(ADDRESS_HOME_CITY).empty() && |
| 96 !profile.GetInfo(ADDRESS_HOME_STATE).empty() && | 96 !profile.GetInfo(ADDRESS_HOME_STATE).empty() && |
| (...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 968 } | 968 } |
| 969 | 969 |
| 970 const AutofillMetrics* PersonalDataManager::metric_logger() const { | 970 const AutofillMetrics* PersonalDataManager::metric_logger() const { |
| 971 return metric_logger_.get(); | 971 return metric_logger_.get(); |
| 972 } | 972 } |
| 973 | 973 |
| 974 void PersonalDataManager::set_metric_logger( | 974 void PersonalDataManager::set_metric_logger( |
| 975 const AutofillMetrics* metric_logger) { | 975 const AutofillMetrics* metric_logger) { |
| 976 metric_logger_.reset(metric_logger); | 976 metric_logger_.reset(metric_logger); |
| 977 } | 977 } |
| OLD | NEW |