| 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 #ifndef CHROME_BROWSER_WEBDATA_KEYWORD_TABLE_H_ | 5 #ifndef CHROME_BROWSER_WEBDATA_KEYWORD_TABLE_H_ |
| 6 #define CHROME_BROWSER_WEBDATA_KEYWORD_TABLE_H_ | 6 #define CHROME_BROWSER_WEBDATA_KEYWORD_TABLE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 // suggest_url | 44 // suggest_url |
| 45 // prepopulate_id See TemplateURLData::prepopulate_id. | 45 // prepopulate_id See TemplateURLData::prepopulate_id. |
| 46 // created_by_policy See TemplateURLData::created_by_policy. This was | 46 // created_by_policy See TemplateURLData::created_by_policy. This was |
| 47 // added in version 26. | 47 // added in version 26. |
| 48 // instant_url See TemplateURLData::instant_url. This was added in | 48 // instant_url See TemplateURLData::instant_url. This was added in |
| 49 // version 29. | 49 // version 29. |
| 50 // last_modified See TemplateURLData::last_modified. This was added | 50 // last_modified See TemplateURLData::last_modified. This was added |
| 51 // in version 38. | 51 // in version 38. |
| 52 // sync_guid See TemplateURLData::sync_guid. This was added in | 52 // sync_guid See TemplateURLData::sync_guid. This was added in |
| 53 // version 39. | 53 // version 39. |
| 54 // alternate_urls See TemplateURLData::alternate_urls. This was added |
| 55 // in version 47. |
| 54 // | 56 // |
| 55 // keywords_backup The full copy of the |keywords| table. Added in | 57 // keywords_backup The full copy of the |keywords| table. Added in |
| 56 // version 43. Must be in sync with |keywords| | 58 // version 43. Must be in sync with |keywords| |
| 57 // table otherwise verification of default search | 59 // table otherwise verification of default search |
| 58 // provider settings will fail. | 60 // provider settings will fail. |
| 59 // | 61 // |
| 60 // This class also manages some fields in the |meta| table: | 62 // This class also manages some fields in the |meta| table: |
| 61 // | 63 // |
| 62 // Default Search Provider ID The id of the default search provider. | 64 // Default Search Provider ID The id of the default search provider. |
| 63 // Default Search Provider ID Backup | 65 // Default Search Provider ID Backup |
| (...skipping 18 matching lines...) Expand all Loading... |
| 82 | 84 |
| 83 // Constants exposed for the benefit of test code: | 85 // Constants exposed for the benefit of test code: |
| 84 | 86 |
| 85 static const char kDefaultSearchProviderKey[]; | 87 static const char kDefaultSearchProviderKey[]; |
| 86 // Meta table key to store backup value for the default search provider id. | 88 // Meta table key to store backup value for the default search provider id. |
| 87 static const char kDefaultSearchIDBackupKey[]; | 89 static const char kDefaultSearchIDBackupKey[]; |
| 88 // Meta table key to store backup value signature for the default search | 90 // Meta table key to store backup value signature for the default search |
| 89 // provider. The default search provider ID and the |keywords_backup| table | 91 // provider. The default search provider ID and the |keywords_backup| table |
| 90 // are signed. | 92 // are signed. |
| 91 static const char kBackupSignatureKey[]; | 93 static const char kBackupSignatureKey[]; |
| 92 // Comma-separated list of keyword table column names, in order. | |
| 93 static const char kKeywordColumns[]; | |
| 94 | 94 |
| 95 KeywordTable(sql::Connection* db, sql::MetaTable* meta_table); | 95 KeywordTable(sql::Connection* db, sql::MetaTable* meta_table); |
| 96 virtual ~KeywordTable(); | 96 virtual ~KeywordTable(); |
| 97 virtual bool Init() OVERRIDE; | 97 virtual bool Init() OVERRIDE; |
| 98 virtual bool IsSyncable() OVERRIDE; | 98 virtual bool IsSyncable() OVERRIDE; |
| 99 | 99 |
| 100 // Adds a new keyword, updating the id field on success. | 100 // Adds a new keyword, updating the id field on success. |
| 101 // Returns true if successful. | 101 // Returns true if successful. |
| 102 bool AddKeyword(const TemplateURLData& data); | 102 bool AddKeyword(const TemplateURLData& data); |
| 103 | 103 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 124 | 124 |
| 125 // Returns true if the default search provider has been changed out from under | 125 // Returns true if the default search provider has been changed out from under |
| 126 // us. This can happen if another process modifies our database or the file | 126 // us. This can happen if another process modifies our database or the file |
| 127 // was corrupted. | 127 // was corrupted. |
| 128 bool DidDefaultSearchProviderChange(); | 128 bool DidDefaultSearchProviderChange(); |
| 129 | 129 |
| 130 // Version of the built-in keywords. | 130 // Version of the built-in keywords. |
| 131 bool SetBuiltinKeywordVersion(int version); | 131 bool SetBuiltinKeywordVersion(int version); |
| 132 int GetBuiltinKeywordVersion(); | 132 int GetBuiltinKeywordVersion(); |
| 133 | 133 |
| 134 // Returns a comma-separated list of the keyword columns for the current |
| 135 // version of the table. |
| 136 static std::string GetKeywordColumns(); |
| 137 |
| 134 // Table migration functions. | 138 // Table migration functions. |
| 135 bool MigrateToVersion21AutoGenerateKeywordColumn(); | 139 bool MigrateToVersion21AutoGenerateKeywordColumn(); |
| 136 bool MigrateToVersion25AddLogoIDColumn(); | 140 bool MigrateToVersion25AddLogoIDColumn(); |
| 137 bool MigrateToVersion26AddCreatedByPolicyColumn(); | 141 bool MigrateToVersion26AddCreatedByPolicyColumn(); |
| 138 bool MigrateToVersion28SupportsInstantColumn(); | 142 bool MigrateToVersion28SupportsInstantColumn(); |
| 139 bool MigrateToVersion29InstantUrlToSupportsInstant(); | 143 bool MigrateToVersion29InstantURLToSupportsInstant(); |
| 140 bool MigrateToVersion38AddLastModifiedColumn(); | 144 bool MigrateToVersion38AddLastModifiedColumn(); |
| 141 bool MigrateToVersion39AddSyncGUIDColumn(); | 145 bool MigrateToVersion39AddSyncGUIDColumn(); |
| 142 bool MigrateToVersion44AddDefaultSearchProviderBackup(); | 146 bool MigrateToVersion44AddDefaultSearchProviderBackup(); |
| 143 bool MigrateToVersion45RemoveLogoIDAndAutogenerateColumns(); | 147 bool MigrateToVersion45RemoveLogoIDAndAutogenerateColumns(); |
| 148 bool MigrateToVersion47AddAlternateURLsColumn(); |
| 144 | 149 |
| 145 private: | 150 private: |
| 146 FRIEND_TEST_ALL_PREFIXES(KeywordTableTest, DefaultSearchProviderBackup); | 151 FRIEND_TEST_ALL_PREFIXES(KeywordTableTest, DefaultSearchProviderBackup); |
| 147 FRIEND_TEST_ALL_PREFIXES(KeywordTableTest, GetTableContents); | 152 FRIEND_TEST_ALL_PREFIXES(KeywordTableTest, GetTableContents); |
| 148 FRIEND_TEST_ALL_PREFIXES(KeywordTableTest, GetTableContentsOrdering); | 153 FRIEND_TEST_ALL_PREFIXES(KeywordTableTest, GetTableContentsOrdering); |
| 149 FRIEND_TEST_ALL_PREFIXES(KeywordTableTest, SanitizeURLs); | 154 FRIEND_TEST_ALL_PREFIXES(KeywordTableTest, SanitizeURLs); |
| 150 FRIEND_TEST_ALL_PREFIXES(WebDatabaseMigrationTest, MigrateVersion44ToCurrent); | 155 FRIEND_TEST_ALL_PREFIXES(WebDatabaseMigrationTest, MigrateVersion44ToCurrent); |
| 151 | 156 |
| 152 // NOTE: Since the table columns have changed in different versions, many | 157 // NOTE: Since the table columns have changed in different versions, many |
| 153 // functions below take a |table_version| argument which dictates which | 158 // functions below take a |table_version| argument which dictates which |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 // keyword. Returns true on success, false otherwise. | 192 // keyword. Returns true on success, false otherwise. |
| 188 bool GetKeywordAsString(TemplateURLID id, | 193 bool GetKeywordAsString(TemplateURLID id, |
| 189 const std::string& table_name, | 194 const std::string& table_name, |
| 190 std::string* result); | 195 std::string* result); |
| 191 | 196 |
| 192 // Updates default search provider id backup in |meta| table. Returns | 197 // Updates default search provider id backup in |meta| table. Returns |
| 193 // true on success. The id is returned back via |id| parameter. | 198 // true on success. The id is returned back via |id| parameter. |
| 194 bool UpdateDefaultSearchProviderIDBackup(TemplateURLID* id); | 199 bool UpdateDefaultSearchProviderIDBackup(TemplateURLID* id); |
| 195 | 200 |
| 196 // Migrates table |name| (which should be either "keywords" or | 201 // Migrates table |name| (which should be either "keywords" or |
| 197 // "keywords_backup" from version 44 to version 45. | 202 // "keywords_backup") from version 44 to version 45. |
| 198 bool MigrateKeywordsTableForVersion45(const std::string& name); | 203 bool MigrateKeywordsTableForVersion45(const std::string& name); |
| 199 | 204 |
| 200 // Whether the backup was overwritten during migration. | 205 // Whether the backup was overwritten during migration. |
| 201 bool backup_overwritten_; | 206 bool backup_overwritten_; |
| 202 | 207 |
| 203 DISALLOW_COPY_AND_ASSIGN(KeywordTable); | 208 DISALLOW_COPY_AND_ASSIGN(KeywordTable); |
| 204 }; | 209 }; |
| 205 | 210 |
| 206 #endif // CHROME_BROWSER_WEBDATA_KEYWORD_TABLE_H_ | 211 #endif // CHROME_BROWSER_WEBDATA_KEYWORD_TABLE_H_ |
| OLD | NEW |