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/history/shortcuts_database.h" | 5 #include "chrome/browser/history/shortcuts_database.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/guid.h" | 9 #include "base/guid.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "components/omnibox/autocomplete_match_type.h" | 13 #include "components/omnibox/autocomplete_match_type.h" |
14 #include "content/public/common/page_transition_types.h" | |
15 #include "sql/meta_table.h" | 14 #include "sql/meta_table.h" |
16 #include "sql/statement.h" | 15 #include "sql/statement.h" |
17 #include "sql/transaction.h" | 16 #include "sql/transaction.h" |
| 17 #include "ui/base/page_transition_types.h" |
18 | 18 |
19 | 19 |
20 // Helpers -------------------------------------------------------------------- | 20 // Helpers -------------------------------------------------------------------- |
21 | 21 |
22 namespace { | 22 namespace { |
23 | 23 |
24 // Current version number. We write databases at the "current" version number, | 24 // Current version number. We write databases at the "current" version number, |
25 // but any previous version that can read the "compatible" one can make do with | 25 // but any previous version that can read the "compatible" one can make do with |
26 // our database without *too* many bad effects. | 26 // our database without *too* many bad effects. |
27 const int kCurrentVersionNumber = 1; | 27 const int kCurrentVersionNumber = 1; |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 // incompletely. | 236 // incompletely. |
237 sql::Transaction transaction(&db_); | 237 sql::Transaction transaction(&db_); |
238 if (!(transaction.Begin() && | 238 if (!(transaction.Begin() && |
239 db_.Execute("ALTER TABLE omni_box_shortcuts " | 239 db_.Execute("ALTER TABLE omni_box_shortcuts " |
240 "ADD COLUMN fill_into_edit VARCHAR") && | 240 "ADD COLUMN fill_into_edit VARCHAR") && |
241 db_.Execute("UPDATE omni_box_shortcuts SET fill_into_edit = url") && | 241 db_.Execute("UPDATE omni_box_shortcuts SET fill_into_edit = url") && |
242 db_.Execute("ALTER TABLE omni_box_shortcuts " | 242 db_.Execute("ALTER TABLE omni_box_shortcuts " |
243 "ADD COLUMN transition INTEGER") && | 243 "ADD COLUMN transition INTEGER") && |
244 db_.Execute(base::StringPrintf( | 244 db_.Execute(base::StringPrintf( |
245 "UPDATE omni_box_shortcuts SET transition = %d", | 245 "UPDATE omni_box_shortcuts SET transition = %d", |
246 static_cast<int>(content::PAGE_TRANSITION_TYPED)).c_str()) && | 246 static_cast<int>(ui::PAGE_TRANSITION_TYPED)).c_str()) && |
247 db_.Execute("ALTER TABLE omni_box_shortcuts ADD COLUMN type INTEGER") && | 247 db_.Execute("ALTER TABLE omni_box_shortcuts ADD COLUMN type INTEGER") && |
248 db_.Execute(base::StringPrintf( | 248 db_.Execute(base::StringPrintf( |
249 "UPDATE omni_box_shortcuts SET type = %d", | 249 "UPDATE omni_box_shortcuts SET type = %d", |
250 static_cast<int>(AutocompleteMatchType::HISTORY_TITLE)).c_str()) && | 250 static_cast<int>(AutocompleteMatchType::HISTORY_TITLE)).c_str()) && |
251 db_.Execute("ALTER TABLE omni_box_shortcuts " | 251 db_.Execute("ALTER TABLE omni_box_shortcuts " |
252 "ADD COLUMN keyword VARCHAR") && | 252 "ADD COLUMN keyword VARCHAR") && |
253 transaction.Commit())) { | 253 transaction.Commit())) { |
254 return false; | 254 return false; |
255 } | 255 } |
256 } | 256 } |
(...skipping 15 matching lines...) Expand all Loading... |
272 db_.Execute(base::StringPrintf("UPDATE omni_box_shortcuts " | 272 db_.Execute(base::StringPrintf("UPDATE omni_box_shortcuts " |
273 "SET type = 16 WHERE type = 12").c_str()) && | 273 "SET type = 16 WHERE type = 12").c_str()) && |
274 transaction.Commit())) { | 274 transaction.Commit())) { |
275 return false; | 275 return false; |
276 } | 276 } |
277 } | 277 } |
278 return true; | 278 return true; |
279 } | 279 } |
280 | 280 |
281 } // namespace history | 281 } // namespace history |
OLD | NEW |