Add removing all bookmarks to ChromeBrowserProvider api.
[chromium-blink-merge.git] / chrome / browser / webdata / autofill_entry.h
bloba9a5375ee829e95073e2b500c754fbdeefcab9a0
1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_WEBDATA_AUTOFILL_ENTRY_H__
6 #define CHROME_BROWSER_WEBDATA_AUTOFILL_ENTRY_H__
8 #include <stddef.h>
9 #include <vector>
11 #include "base/gtest_prod_util.h"
12 #include "base/string16.h"
13 #include "base/time.h"
15 class AutofillKey {
16 public:
17 AutofillKey();
18 AutofillKey(const string16& name, const string16& value);
19 AutofillKey(const char* name, const char* value);
20 AutofillKey(const AutofillKey& key);
21 virtual ~AutofillKey();
23 const string16& name() const { return name_; }
24 const string16& value() const { return value_; }
26 bool operator==(const AutofillKey& key) const;
27 bool operator<(const AutofillKey& key) const;
29 private:
30 string16 name_;
31 string16 value_;
34 class AutofillEntry {
35 public:
36 AutofillEntry(const AutofillKey& key,
37 const std::vector<base::Time>& timestamps);
38 ~AutofillEntry();
40 const AutofillKey& key() const { return key_; }
41 const std::vector<base::Time>& timestamps() const { return timestamps_; }
43 bool operator==(const AutofillEntry& entry) const;
44 bool operator<(const AutofillEntry& entry) const;
46 bool timestamps_culled() const { return timestamps_culled_; }
48 // Checks if last of the timestamps are older than ExpirationTime().
49 bool IsExpired() const;
51 // The entries last accessed before this time should expire.
52 static base::Time ExpirationTime();
54 private:
55 FRIEND_TEST_ALL_PREFIXES(AutofillEntryTest, NoCulling);
56 FRIEND_TEST_ALL_PREFIXES(AutofillEntryTest, Culling);
57 FRIEND_TEST_ALL_PREFIXES(AutofillEntryTest, CullByTime);
59 // Culls the list of timestamps to 2 - the oldest and most recent. This is a
60 // precursor to getting rid of the timestamps db altogether.
61 // See http://crbug.com/118696.
62 // |source| is expected to be sorted from oldest to newest.
63 static bool CullTimeStamps(const std::vector<base::Time>& source,
64 std::vector<base::Time>* result);
66 AutofillKey key_;
67 std::vector<base::Time> timestamps_;
68 bool timestamps_culled_;
71 #endif // CHROME_BROWSER_WEBDATA_AUTOFILL_ENTRY_H__