[safe-browsing] Database full hash matches like prefix match.
[chromium-blink-merge.git] / chrome / browser / webdata / logins_table.cc
blobff14bcba8a6bef11099b52fea44b063ef1ea8ca1
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 #include "chrome/browser/webdata/logins_table.h"
7 #include <limits>
9 #include "base/logging.h"
10 #include "components/webdata/common/web_database.h"
11 #include "sql/statement.h"
13 namespace {
15 WebDatabaseTable::TypeKey GetKey() {
16 // We just need a unique constant. Use the address of a static that
17 // COMDAT folding won't touch in an optimizing linker.
18 static int table_key = 0;
19 return reinterpret_cast<void*>(&table_key);
22 } // namespace
24 LoginsTable* LoginsTable::FromWebDatabase(WebDatabase* db) {
25 return static_cast<LoginsTable*>(db->GetTable(GetKey()));
28 WebDatabaseTable::TypeKey LoginsTable::GetTypeKey() const {
29 return GetKey();
32 bool LoginsTable::CreateTablesIfNecessary() {
33 if (db_->DoesTableExist("logins")) {
34 // We don't check for success. It doesn't matter that much.
35 // If we fail we'll just try again later anyway.
36 ignore_result(db_->Execute("DROP TABLE logins"));
39 #if defined(OS_WIN)
40 if (!db_->DoesTableExist("ie7_logins")) {
41 if (!db_->Execute("CREATE TABLE ie7_logins ("
42 "url_hash VARCHAR NOT NULL, "
43 "password_value BLOB, "
44 "date_created INTEGER NOT NULL,"
45 "UNIQUE "
46 "(url_hash))")) {
47 NOTREACHED();
48 return false;
50 if (!db_->Execute("CREATE INDEX ie7_logins_hash ON "
51 "ie7_logins (url_hash)")) {
52 NOTREACHED();
53 return false;
56 #endif
58 return true;
61 bool LoginsTable::IsSyncable() {
62 return true;
65 bool LoginsTable::MigrateToVersion(int version,
66 bool* update_compatible_version) {
67 return true;