Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / components / autofill / core / browser / webdata / autofill_entry.cc
blobbca50c5d861073ebe53e0fd9a0dd08cfc6e709aa
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.
5 #include "components/autofill/core/browser/webdata/autofill_entry.h"
7 #include "base/strings/utf_string_conversions.h"
9 namespace autofill {
11 AutofillKey::AutofillKey() {}
13 AutofillKey::AutofillKey(const base::string16& name,
14 const base::string16& value)
15 : name_(name),
16 value_(value) {
19 AutofillKey::AutofillKey(const char* name, const char* value)
20 : name_(base::UTF8ToUTF16(name)),
21 value_(base::UTF8ToUTF16(value)) {
24 AutofillKey::AutofillKey(const AutofillKey& key)
25 : name_(key.name()),
26 value_(key.value()) {
29 AutofillKey::~AutofillKey() {}
31 bool AutofillKey::operator==(const AutofillKey& key) const {
32 return name_ == key.name() && value_ == key.value();
35 bool AutofillKey::operator<(const AutofillKey& key) const {
36 int diff = name_.compare(key.name());
37 if (diff < 0)
38 return true;
40 if (diff == 0)
41 return value_.compare(key.value()) < 0;
43 return false;
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) {}
53 AutofillEntry::~AutofillEntry() {}
55 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();
61 bool AutofillEntry::operator<(const AutofillEntry& entry) const {
62 return key_ < entry.key();
65 } // namespace autofill