Chromium Code Reviews| Index: chrome/browser/history/shortcuts_database.cc |
| diff --git a/chrome/browser/history/shortcuts_database.cc b/chrome/browser/history/shortcuts_database.cc |
| index 51d6f09293fbffe58da621bfab05911739d5a9d8..a9851d73744940075a1dc50803bcb08e4eade199 100644 |
| --- a/chrome/browser/history/shortcuts_database.cc |
| +++ b/chrome/browser/history/shortcuts_database.cc |
| @@ -196,6 +196,60 @@ bool ShortcutsDatabase::EnsureTable() { |
| transaction.Commit(); |
| } |
| + // With new suggestion types being added, following values have changed: |
|
Peter Kasting
2014/02/05 21:59:39
We really should do migration passes based on vers
Anuj
2014/02/10 22:17:30
There is no meta-table in Shortcuts DB. So just co
|
| + // SEARCH_OTHER_ENGINE -> SEARCH_SUGGEST_ENTITY |
| + // EXTENSION_APP -> SEARCH_SUGGEST_INFINITE |
| + // CONTACT -> SEARCH_SUGGEST_PERSONALIZED |
| + // BOOKMARK_TITLE -> SEARCH_SUGGEST_PROFILE |
| + sql::Transaction transaction(&db_); |
| + transaction.Begin(); |
| + // Migrate old SEARCH_OTHER_ENGINE values to the new type value. |
| + // The ENTITY suggestion values always have a description and always have a |
| + // https google search url with gs_ssp parameter. The old SEARCH_OTHER_ENGINE |
| + // entries will definitely fail the url check, but empty description test is |
| + // also sufficient and faster. |
|
Peter Kasting
2014/02/05 21:59:39
Is it actually necessary to do such sophisticated
Anuj
2014/02/10 22:17:30
I am not sure. I feel if we are bothering to make
Peter Kasting
2014/02/10 22:29:46
I'd probably write the "dumbest" possible code tha
Anuj
2014/02/11 07:20:04
Done.
|
| + db_.Execute(base::StringPrintf("UPDATE omni_box_shortcuts " |
| + "SET type = %d " |
| + "where type = %d AND " |
| + "(description = '' OR " |
| + "url NOT REGEXP '^https://www\\.google\\..*/search\\?.*&?gs_ssp=.*')", |
| + static_cast<int>(AutocompleteMatchType::SEARCH_OTHER_ENGINE), |
|
Peter Kasting
2014/02/05 21:59:39
For both old and new type values, hardcode the num
Anuj
2014/02/10 22:17:30
Done.
|
| + static_cast<int>(AutocompleteMatchType::SEARCH_SUGGEST_ENTITY)) |
| + .c_str()) && |
|
Peter Kasting
2014/02/05 21:59:39
Nit: If you're going to chain statements with &&,
Anuj
2014/02/10 22:17:30
They are not indented in the block above - lines
Peter Kasting
2014/02/10 22:29:46
They are, in fact, indented. They're part of the
Anuj
2014/02/11 07:20:04
Done.
|
| + // Migrate old EXTENSION_APP values to the new type value. |
| + // The INFINITE suggestions are not launched. So it is safe to update all of |
| + // them to EXTENSION_APP type wherever the url is not a google search. |
| + db_.Execute(base::StringPrintf("UPDATE omni_box_shortcuts " |
| + "SET type = %d " |
| + "where type = %d AND " |
| + "url NOT REGEXP '^https://www\\.google\\..*/search\\?.*')", |
| + static_cast<int>(AutocompleteMatchType::EXTENSION_APP), |
| + static_cast<int>(AutocompleteMatchType::SEARCH_SUGGEST_INFINITE)) |
| + .c_str()) && |
| + // Migrate old CONTACT values to the new type value. |
| + // The PERSONALIZED suggestions are not launched. So it is safe to update all |
| + // of them to CONTACT type wherever the url is not a google search. |
| + db_.Execute(base::StringPrintf("UPDATE omni_box_shortcuts " |
| + "SET type = %d " |
| + "where type = %d AND " |
| + "url NOT REGEXP '^https://www\\.google\\..*/search\\?.*')", |
| + static_cast<int>(AutocompleteMatchType::CONTACT), |
| + static_cast<int>(AutocompleteMatchType::SEARCH_SUGGEST_PERSONALIZED)) |
| + .c_str()) && |
| + // Migrate old BOOKMARK_TITLE values to the new type value. |
| + // The PROFILE suggestion values always have a description and always have a |
| + // https google search url with tbs parameter. The old BOOKMARK_TITLE entries |
| + // will definitely fail the url check, but empty description test is also |
| + // sufficient and faster. |
| + db_.Execute(base::StringPrintf("UPDATE omni_box_shortcuts " |
| + "SET type = %d " |
| + "where type = %d AND " |
| + "(description = '' OR " |
| + "url NOT REGEXP '^https://www\\.google\\..*/search\\?.*&?tbs=.*')", |
| + static_cast<int>(AutocompleteMatchType::BOOKMARK_TITLE), |
| + static_cast<int>(AutocompleteMatchType::SEARCH_SUGGEST_PROFILE)) |
| + .c_str()) && |
| + transaction.Commit(); |
| return true; |
|
Peter Kasting
2014/02/05 21:59:39
Seems like here we should be returning the result
Anuj
2014/02/10 22:17:30
But we are okay about failing to do this modificat
Peter Kasting
2014/02/10 22:29:46
If you fail to execute one of these statements, so
Anuj
2014/02/11 07:20:04
Done.
|
| } |