Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(311)

Side by Side Diff: chrome/browser/webdata/keyword_table.h

Issue 10908226: Introduces a search term extraction mechanism working for arbitrary search providers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Indent fix. Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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 25 matching lines...) Expand all
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 // Table migration functions. 134 // Table migration functions.
135 bool MigrateToVersion21AutoGenerateKeywordColumn(); 135 bool MigrateToVersion21AutoGenerateKeywordColumn();
136 bool MigrateToVersion25AddLogoIDColumn(); 136 bool MigrateToVersion25AddLogoIDColumn();
137 bool MigrateToVersion26AddCreatedByPolicyColumn(); 137 bool MigrateToVersion26AddCreatedByPolicyColumn();
138 bool MigrateToVersion28SupportsInstantColumn(); 138 bool MigrateToVersion28SupportsInstantColumn();
139 bool MigrateToVersion29InstantUrlToSupportsInstant(); 139 bool MigrateToVersion29InstantURLToSupportsInstant();
140 bool MigrateToVersion38AddLastModifiedColumn(); 140 bool MigrateToVersion38AddLastModifiedColumn();
141 bool MigrateToVersion39AddSyncGUIDColumn(); 141 bool MigrateToVersion39AddSyncGUIDColumn();
142 bool MigrateToVersion44AddDefaultSearchProviderBackup(); 142 bool MigrateToVersion44AddDefaultSearchProviderBackup();
143 bool MigrateToVersion45RemoveLogoIDAndAutogenerateColumns(); 143 bool MigrateToVersion45RemoveLogoIDAndAutogenerateColumns();
144 bool MigrateToVersion47AddAlternateURLsColumn();
144 145
145 private: 146 private:
146 FRIEND_TEST_ALL_PREFIXES(KeywordTableTest, DefaultSearchProviderBackup); 147 FRIEND_TEST_ALL_PREFIXES(KeywordTableTest, DefaultSearchProviderBackup);
147 FRIEND_TEST_ALL_PREFIXES(KeywordTableTest, GetTableContents); 148 FRIEND_TEST_ALL_PREFIXES(KeywordTableTest, GetTableContents);
148 FRIEND_TEST_ALL_PREFIXES(KeywordTableTest, GetTableContentsOrdering); 149 FRIEND_TEST_ALL_PREFIXES(KeywordTableTest, GetTableContentsOrdering);
149 FRIEND_TEST_ALL_PREFIXES(KeywordTableTest, SanitizeURLs); 150 FRIEND_TEST_ALL_PREFIXES(KeywordTableTest, SanitizeURLs);
151 FRIEND_TEST_ALL_PREFIXES(WebDatabaseMigrationTest, MigrateVersion27ToCurrent);
152 FRIEND_TEST_ALL_PREFIXES(WebDatabaseMigrationTest, MigrateVersion42ToCurrent);
150 FRIEND_TEST_ALL_PREFIXES(WebDatabaseMigrationTest, MigrateVersion44ToCurrent); 153 FRIEND_TEST_ALL_PREFIXES(WebDatabaseMigrationTest, MigrateVersion44ToCurrent);
151 154
155 // Returns a comma-separated list of the keyword columns for the current
156 // version of the table.
Peter Kasting 2012/10/04 19:32:43 Nit: I'd be OK with making this public if it allow
beaudoin 2012/10/04 23:10:45 Done.
157 static std::string GetKeywordColumns();
158
152 // NOTE: Since the table columns have changed in different versions, many 159 // NOTE: Since the table columns have changed in different versions, many
153 // functions below take a |table_version| argument which dictates which 160 // functions below take a |table_version| argument which dictates which
154 // version number's column set to use. 161 // version number's column set to use.
155 162
156 // Fills |data| with the data in |s|. Returns false if we couldn't fill 163 // Fills |data| with the data in |s|. Returns false if we couldn't fill
157 // |data| for some reason, e.g. |s| tried to set one of the fields to an 164 // |data| for some reason, e.g. |s| tried to set one of the fields to an
158 // illegal value. 165 // illegal value.
159 static bool GetKeywordDataFromStatement(const sql::Statement& s, 166 static bool GetKeywordDataFromStatement(const sql::Statement& s,
160 TemplateURLData* data); 167 TemplateURLData* data);
161 168
(...skipping 25 matching lines...) Expand all
187 // keyword. Returns true on success, false otherwise. 194 // keyword. Returns true on success, false otherwise.
188 bool GetKeywordAsString(TemplateURLID id, 195 bool GetKeywordAsString(TemplateURLID id,
189 const std::string& table_name, 196 const std::string& table_name,
190 std::string* result); 197 std::string* result);
191 198
192 // Updates default search provider id backup in |meta| table. Returns 199 // Updates default search provider id backup in |meta| table. Returns
193 // true on success. The id is returned back via |id| parameter. 200 // true on success. The id is returned back via |id| parameter.
194 bool UpdateDefaultSearchProviderIDBackup(TemplateURLID* id); 201 bool UpdateDefaultSearchProviderIDBackup(TemplateURLID* id);
195 202
196 // Migrates table |name| (which should be either "keywords" or 203 // Migrates table |name| (which should be either "keywords" or
197 // "keywords_backup" from version 44 to version 45. 204 // "keywords_backup") from version 44 to version 45.
198 bool MigrateKeywordsTableForVersion45(const std::string& name); 205 bool MigrateKeywordsTableForVersion45(const std::string& name);
199 206
200 // Whether the backup was overwritten during migration. 207 // Whether the backup was overwritten during migration.
201 bool backup_overwritten_; 208 bool backup_overwritten_;
202 209
203 DISALLOW_COPY_AND_ASSIGN(KeywordTable); 210 DISALLOW_COPY_AND_ASSIGN(KeywordTable);
204 }; 211 };
205 212
206 #endif // CHROME_BROWSER_WEBDATA_KEYWORD_TABLE_H_ 213 #endif // CHROME_BROWSER_WEBDATA_KEYWORD_TABLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698