OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include <string> | |
9 | 10 |
10 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/stl_util.h" | |
11 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
12 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
13 #include "chrome/browser/autofill/autofill-inl.h" | 15 #include "chrome/browser/autofill/autofill-inl.h" |
14 #include "chrome/browser/autofill/autofill_field.h" | 16 #include "chrome/browser/autofill/autofill_field.h" |
15 #include "chrome/browser/autofill/autofill_metrics.h" | 17 #include "chrome/browser/autofill/autofill_metrics.h" |
16 #include "chrome/browser/autofill/autofill_regexes.h" | 18 #include "chrome/browser/autofill/autofill_regexes.h" |
17 #include "chrome/browser/autofill/form_structure.h" | 19 #include "chrome/browser/autofill/form_structure.h" |
18 #include "chrome/browser/autofill/personal_data_manager_observer.h" | 20 #include "chrome/browser/autofill/personal_data_manager_observer.h" |
19 #include "chrome/browser/autofill/phone_number.h" | 21 #include "chrome/browser/autofill/phone_number.h" |
20 #include "chrome/browser/autofill/phone_number_i18n.h" | 22 #include "chrome/browser/autofill/phone_number_i18n.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 | 55 |
54 template<typename T, typename C> | 56 template<typename T, typename C> |
55 bool FindByGUID(const C& container, const std::string& guid) { | 57 bool FindByGUID(const C& container, const std::string& guid) { |
56 return std::find_if( | 58 return std::find_if( |
57 container.begin(), | 59 container.begin(), |
58 container.end(), | 60 container.end(), |
59 FormGroupMatchesByGUIDFunctor<T>(guid)) != container.end(); | 61 FormGroupMatchesByGUIDFunctor<T>(guid)) != container.end(); |
60 } | 62 } |
61 | 63 |
62 template<typename T> | 64 template<typename T> |
63 class DereferenceFunctor { | 65 class DereferenceFunctor { |
dhollowa
2012/04/30 16:03:09
While we're at it, this |DereferenceFunctor| can b
gavinp
2012/04/30 16:27:16
Done.
| |
64 public: | 66 public: |
65 template<typename T_Iterator> | 67 template<typename T_Iterator> |
66 const T& operator()(const T_Iterator& iterator) { | 68 const T& operator()(const T_Iterator& iterator) { |
67 return *iterator; | 69 return *iterator; |
68 } | 70 } |
69 }; | 71 }; |
70 | 72 |
71 template<typename T> | |
72 T* address_of(T& v) { | |
73 return &v; | |
74 } | |
75 | |
76 bool IsValidEmail(const string16& value) { | 73 bool IsValidEmail(const string16& value) { |
77 // This regex is more permissive than the official rfc2822 spec on the | 74 // This regex is more permissive than the official rfc2822 spec on the |
78 // subject, but it does reject obvious non-email addresses. | 75 // subject, but it does reject obvious non-email addresses. |
79 const string16 kEmailPattern = ASCIIToUTF16("^[^@]+@[^@]+\\.[a-z]{2,6}$"); | 76 const string16 kEmailPattern = ASCIIToUTF16("^[^@]+@[^@]+\\.[a-z]{2,6}$"); |
80 return autofill::MatchesPattern(value, kEmailPattern); | 77 return autofill::MatchesPattern(value, kEmailPattern); |
81 } | 78 } |
82 | 79 |
83 // Valid for US zip codes only. | 80 // Valid for US zip codes only. |
84 bool IsValidZip(const string16& value) { | 81 bool IsValidZip(const string16& value) { |
85 // Basic US zip code matching. | 82 // Basic US zip code matching. |
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
930 } | 927 } |
931 | 928 |
932 const AutofillMetrics* PersonalDataManager::metric_logger() const { | 929 const AutofillMetrics* PersonalDataManager::metric_logger() const { |
933 return metric_logger_.get(); | 930 return metric_logger_.get(); |
934 } | 931 } |
935 | 932 |
936 void PersonalDataManager::set_metric_logger( | 933 void PersonalDataManager::set_metric_logger( |
937 const AutofillMetrics* metric_logger) { | 934 const AutofillMetrics* metric_logger) { |
938 metric_logger_.reset(metric_logger); | 935 metric_logger_.reset(metric_logger); |
939 } | 936 } |
OLD | NEW |