• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/webdata/autofill_entry.h"
6 
7 #include "base/strings/utf_string_conversions.h"
8 
9 namespace autofill {
10 
AutofillKey()11 AutofillKey::AutofillKey() {}
12 
AutofillKey(const base::string16 & name,const base::string16 & value)13 AutofillKey::AutofillKey(const base::string16& name,
14                          const base::string16& value)
15     : name_(name),
16       value_(value) {
17 }
18 
AutofillKey(const char * name,const char * value)19 AutofillKey::AutofillKey(const char* name, const char* value)
20     : name_(base::UTF8ToUTF16(name)),
21       value_(base::UTF8ToUTF16(value)) {
22 }
23 
AutofillKey(const AutofillKey & key)24 AutofillKey::AutofillKey(const AutofillKey& key)
25     : name_(key.name()),
26       value_(key.value()) {
27 }
28 
~AutofillKey()29 AutofillKey::~AutofillKey() {}
30 
operator ==(const AutofillKey & key) const31 bool AutofillKey::operator==(const AutofillKey& key) const {
32   return name_ == key.name() && value_ == key.value();
33 }
34 
operator <(const AutofillKey & key) const35 bool AutofillKey::operator<(const AutofillKey& key) const {
36   int diff = name_.compare(key.name());
37   if (diff < 0)
38     return true;
39 
40   if (diff == 0)
41     return value_.compare(key.value()) < 0;
42 
43   return false;
44 }
45 
AutofillEntry(const AutofillKey & key,const base::Time & date_created,const base::Time & date_last_used)46 AutofillEntry::AutofillEntry(const AutofillKey& key,
47                              const base::Time& date_created,
48                              const base::Time& date_last_used)
49     : key_(key),
50       date_created_(date_created),
51       date_last_used_(date_last_used) {}
52 
~AutofillEntry()53 AutofillEntry::~AutofillEntry() {}
54 
operator ==(const AutofillEntry & entry) const55 bool AutofillEntry::operator==(const AutofillEntry& entry) const {
56   return key() == entry.key() &&
57          date_created() == entry.date_created() &&
58          date_last_used() == entry.date_last_used();
59 }
60 
operator <(const AutofillEntry & entry) const61 bool AutofillEntry::operator<(const AutofillEntry& entry) const {
62   return key_ < entry.key();
63 }
64 
65 }  // namespace autofill
66