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/keyword_table.h" | 5 #include "chrome/browser/webdata/keyword_table.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 KeywordTable::~KeywordTable() {} | 149 KeywordTable::~KeywordTable() {} |
150 | 150 |
151 KeywordTable* KeywordTable::FromWebDatabase(WebDatabase* db) { | 151 KeywordTable* KeywordTable::FromWebDatabase(WebDatabase* db) { |
152 return static_cast<KeywordTable*>(db->GetTable(GetKey())); | 152 return static_cast<KeywordTable*>(db->GetTable(GetKey())); |
153 } | 153 } |
154 | 154 |
155 WebDatabaseTable::TypeKey KeywordTable::GetTypeKey() const { | 155 WebDatabaseTable::TypeKey KeywordTable::GetTypeKey() const { |
156 return GetKey(); | 156 return GetKey(); |
157 } | 157 } |
158 | 158 |
159 bool KeywordTable::Init(sql::Connection* db, sql::MetaTable* meta_table) { | 159 bool KeywordTable::CreateTablesIfNecessary() { |
160 WebDatabaseTable::Init(db, meta_table); | |
161 return db_->DoesTableExist("keywords") || | 160 return db_->DoesTableExist("keywords") || |
162 db_->Execute("CREATE TABLE keywords (" | 161 db_->Execute("CREATE TABLE keywords (" |
163 "id INTEGER PRIMARY KEY," | 162 "id INTEGER PRIMARY KEY," |
164 "short_name VARCHAR NOT NULL," | 163 "short_name VARCHAR NOT NULL," |
165 "keyword VARCHAR NOT NULL," | 164 "keyword VARCHAR NOT NULL," |
166 "favicon_url VARCHAR NOT NULL," | 165 "favicon_url VARCHAR NOT NULL," |
167 "url VARCHAR NOT NULL," | 166 "url VARCHAR NOT NULL," |
168 "safe_for_autoreplace INTEGER," | 167 "safe_for_autoreplace INTEGER," |
169 "originating_url VARCHAR," | 168 "originating_url VARCHAR," |
170 "date_created INTEGER DEFAULT 0," | 169 "date_created INTEGER DEFAULT 0," |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 } | 674 } |
676 } | 675 } |
677 | 676 |
678 // Replace the old table with the new one. | 677 // Replace the old table with the new one. |
679 sql = "DROP TABLE " + name; | 678 sql = "DROP TABLE " + name; |
680 if (!db_->Execute(sql.c_str())) | 679 if (!db_->Execute(sql.c_str())) |
681 return false; | 680 return false; |
682 sql = "ALTER TABLE keywords_temp RENAME TO " + name; | 681 sql = "ALTER TABLE keywords_temp RENAME TO " + name; |
683 return db_->Execute(sql.c_str()); | 682 return db_->Execute(sql.c_str()); |
684 } | 683 } |
OLD | NEW |