autofill-inl.h revision eb525c5499e34cc9c4b825d6d9e75bb07cc06ace
1d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved. 2d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 3d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)// found in the LICENSE file. 4d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 5d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_INL_H_ 6d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_INL_H_ 7c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch 8c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdochnamespace autofill { 9c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch 10c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdochtemplate<typename T> 1103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)class FormGroupMatchesByCompareFunctor { 1203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) public: 1303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) explicit FormGroupMatchesByCompareFunctor(const T& form_group) 1403b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) : form_group_(form_group) { 1503b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) } 1603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) 1703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) bool operator()(const T* form_group) { 1803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) return form_group->Compare(form_group_) == 0; 1903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) } 2003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) 2103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) bool operator()(const T& form_group) { 2203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) return form_group.Compare(form_group_) == 0; 2303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) } 24d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 25d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) private: 260f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) const T& form_group_; 270f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)}; 28d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 290f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)template<typename C, typename T> 30c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdochbool FindByContents(const C& container, const T& form_group) { 31c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch return std::find_if( 320f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) container.begin(), 330f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) container.end(), 34f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) FormGroupMatchesByCompareFunctor<T>(form_group)) != container.end(); 3503b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)} 3603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) 37d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)} // namespace autofill 38d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 39d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_INL_H_ 40d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)