OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/webdata/logins_table.h" | 5 #include "chrome/browser/webdata/logins_table.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "chrome/browser/webdata/web_database.h" |
10 #include "sql/statement.h" | 11 #include "sql/statement.h" |
11 | 12 |
12 bool LoginsTable::Init() { | 13 namespace { |
| 14 |
| 15 int table_key = 0; |
| 16 |
| 17 WebDatabaseTable::TypeKey GetKey() { |
| 18 return reinterpret_cast<void*>(&table_key); |
| 19 } |
| 20 |
| 21 } // namespace |
| 22 |
| 23 LoginsTable* LoginsTable::FromWebDatabase(WebDatabase* db) { |
| 24 return static_cast<LoginsTable*>(db->GetTable(GetKey())); |
| 25 } |
| 26 |
| 27 WebDatabaseTable::TypeKey LoginsTable::GetTypeKey() const { |
| 28 return GetKey(); |
| 29 } |
| 30 |
| 31 bool LoginsTable::Init(sql::Connection* db, sql::MetaTable* meta_table) { |
| 32 WebDatabaseTable::Init(db, meta_table); |
| 33 |
13 if (db_->DoesTableExist("logins")) { | 34 if (db_->DoesTableExist("logins")) { |
14 // We don't check for success. It doesn't matter that much. | 35 // We don't check for success. It doesn't matter that much. |
15 // If we fail we'll just try again later anyway. | 36 // If we fail we'll just try again later anyway. |
16 ignore_result(db_->Execute("DROP TABLE logins")); | 37 ignore_result(db_->Execute("DROP TABLE logins")); |
17 } | 38 } |
18 | 39 |
19 #if defined(OS_WIN) | 40 #if defined(OS_WIN) |
20 if (!db_->DoesTableExist("ie7_logins")) { | 41 if (!db_->DoesTableExist("ie7_logins")) { |
21 if (!db_->Execute("CREATE TABLE ie7_logins (" | 42 if (!db_->Execute("CREATE TABLE ie7_logins (" |
22 "url_hash VARCHAR NOT NULL, " | 43 "url_hash VARCHAR NOT NULL, " |
(...skipping 17 matching lines...) Expand all Loading... |
40 | 61 |
41 bool LoginsTable::IsSyncable() { | 62 bool LoginsTable::IsSyncable() { |
42 return true; | 63 return true; |
43 } | 64 } |
44 | 65 |
45 bool LoginsTable::MigrateToVersion(int version, | 66 bool LoginsTable::MigrateToVersion(int version, |
46 const std::string& app_locale, | 67 const std::string& app_locale, |
47 bool* update_compatible_version) { | 68 bool* update_compatible_version) { |
48 return true; | 69 return true; |
49 } | 70 } |
OLD | NEW |