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 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_INL_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_INL_H_ |
6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_INL_H_ | 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_INL_H_ |
7 | 7 |
8 namespace autofill { | 8 namespace autofill { |
9 | 9 |
10 template<typename T> | 10 template<typename T> |
11 class FormGroupMatchesByCompareFunctor { | 11 class FormGroupMatchesByCompareFunctor { |
12 public: | 12 public: |
13 explicit FormGroupMatchesByCompareFunctor(const T& form_group) | 13 explicit FormGroupMatchesByCompareFunctor(const T& form_group) |
14 : form_group_(form_group) { | 14 : form_group_(form_group) { |
15 } | 15 } |
16 | 16 |
17 bool operator()(const T* form_group) { | 17 bool operator()(const T* form_group) { |
18 return form_group->Compare(form_group_) == 0; | 18 return form_group->Compare(form_group_) == 0; |
19 } | 19 } |
20 | 20 |
21 bool operator()(const T& form_group) { | 21 bool operator()(const T& form_group) { |
22 return form_group.Compare(form_group_) == 0; | 22 return form_group.Compare(form_group_) == 0; |
23 } | 23 } |
24 | 24 |
| 25 bool operator()(const std::unique_ptr<T>& form_group) { |
| 26 return form_group->Compare(form_group_) == 0; |
| 27 } |
| 28 |
25 private: | 29 private: |
26 const T& form_group_; | 30 const T& form_group_; |
27 }; | 31 }; |
28 | 32 |
29 template<typename C, typename T> | 33 template<typename C, typename T> |
30 bool FindByContents(const C& container, const T& form_group) { | 34 bool FindByContents(const C& container, const T& form_group) { |
31 return std::find_if( | 35 return std::find_if( |
32 container.begin(), | 36 container.begin(), |
33 container.end(), | 37 container.end(), |
34 FormGroupMatchesByCompareFunctor<T>(form_group)) != container.end(); | 38 FormGroupMatchesByCompareFunctor<T>(form_group)) != container.end(); |
35 } | 39 } |
36 | 40 |
37 } // namespace autofill | 41 } // namespace autofill |
38 | 42 |
39 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_INL_H_ | 43 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_INL_H_ |
OLD | NEW |