summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autofill/autofill-inl.h
blob: 420ccd236a9d4c2a7aba7a3632d9ecf3ee52ec2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_AUTOFILL_AUTOFILL_INL_H_
#define CHROME_BROWSER_AUTOFILL_AUTOFILL_INL_H_

template<typename T>
class FormGroupMatchesByCompareFunctor {
 public:
  explicit FormGroupMatchesByCompareFunctor(const T& form_group)
      : form_group_(form_group) {
  }

  bool operator()(const T* form_group) {
    return form_group->Compare(form_group_) == 0;
  }

  bool operator()(const T& form_group) {
    return form_group.Compare(form_group_) == 0;
  }

 private:
  const T& form_group_;
};

template<typename C, typename T>
bool FindByContents(const C& container, const T& form_group) {
  return std::find_if(
      container.begin(),
      container.end(),
      FormGroupMatchesByCompareFunctor<T>(form_group)) != container.end();
}

#endif  // CHROME_BROWSER_AUTOFILL_AUTOFILL_INL_H_