- add sources.
[platform/framework/web/crosswalk.git] / src / components / autofill / core / browser / form_group.cc
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
3 // found in the LICENSE file.
4
5 #include "components/autofill/core/browser/form_group.h"
6
7 #include "components/autofill/core/browser/autofill_type.h"
8
9 namespace autofill {
10
11 void FormGroup::GetMatchingTypes(const base::string16& text,
12                                  const std::string& app_locale,
13                                  ServerFieldTypeSet* matching_types) const {
14   if (text.empty()) {
15     matching_types->insert(EMPTY_TYPE);
16     return;
17   }
18
19   ServerFieldTypeSet types;
20   GetSupportedTypes(&types);
21   for (ServerFieldTypeSet::const_iterator type = types.begin();
22        type != types.end(); ++type) {
23     if (GetInfo(AutofillType(*type), app_locale) == text)
24       matching_types->insert(*type);
25   }
26 }
27
28 void FormGroup::GetNonEmptyTypes(const std::string& app_locale,
29                                  ServerFieldTypeSet* non_empty_types) const {
30   ServerFieldTypeSet types;
31   GetSupportedTypes(&types);
32   for (ServerFieldTypeSet::const_iterator type = types.begin();
33        type != types.end(); ++type) {
34     if (!GetInfo(AutofillType(*type), app_locale).empty())
35       non_empty_types->insert(*type);
36   }
37 }
38
39 base::string16 FormGroup::GetInfo(const AutofillType& type,
40                                   const std::string& app_locale) const {
41   return GetRawInfo(type.GetStorableType());
42 }
43
44 bool FormGroup::SetInfo(const AutofillType& type,
45                         const base::string16& value,
46                         const std::string& app_locale) {
47   SetRawInfo(type.GetStorableType(), value);
48   return true;
49 }
50
51 }  // namespace autofill