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