| 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 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
| 13 #include "base/string16.h" | 13 #include "base/string16.h" |
| 14 #include "chrome/browser/webdata/web_database_table.h" | 14 #include "chrome/browser/webdata/web_database_table.h" |
| 15 #include "chrome/browser/search_engines/template_url_id.h" | 15 #include "chrome/browser/search_engines/template_url_id.h" |
| 16 | 16 |
| 17 struct TemplateURLData; | 17 struct TemplateURLData; |
| 18 class WebDatabase; |
| 18 | 19 |
| 19 namespace sql { | 20 namespace sql { |
| 20 class Statement; | 21 class Statement; |
| 21 } // namespace sql | 22 } // namespace sql |
| 22 | 23 |
| 23 // This class manages the |keywords| MetaTable within the SQLite database | 24 // This class manages the |keywords| MetaTable within the SQLite database |
| 24 // passed to the constructor. It expects the following schema: | 25 // passed to the constructor. It expects the following schema: |
| 25 // | 26 // |
| 26 // Note: The database stores time in seconds, UTC. | 27 // Note: The database stores time in seconds, UTC. |
| 27 // | 28 // |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 // Builtin Keyword Version The version of builtin keywords data. | 65 // Builtin Keyword Version The version of builtin keywords data. |
| 65 // | 66 // |
| 66 class KeywordTable : public WebDatabaseTable { | 67 class KeywordTable : public WebDatabaseTable { |
| 67 public: | 68 public: |
| 68 typedef std::vector<TemplateURLData> Keywords; | 69 typedef std::vector<TemplateURLData> Keywords; |
| 69 | 70 |
| 70 // Constants exposed for the benefit of test code: | 71 // Constants exposed for the benefit of test code: |
| 71 | 72 |
| 72 static const char kDefaultSearchProviderKey[]; | 73 static const char kDefaultSearchProviderKey[]; |
| 73 | 74 |
| 74 KeywordTable(sql::Connection* db, sql::MetaTable* meta_table); | 75 KeywordTable(); |
| 75 virtual ~KeywordTable(); | 76 virtual ~KeywordTable(); |
| 76 virtual bool Init() OVERRIDE; | 77 |
| 78 // Retrieves the KeywordTable* owned by |database|. |
| 79 static KeywordTable* FromWebDatabase(WebDatabase* db); |
| 80 |
| 81 virtual WebDatabaseTable::TypeKey GetTypeKey() const OVERRIDE; |
| 82 virtual bool Init(sql::Connection* db, sql::MetaTable* meta_table) OVERRIDE; |
| 77 virtual bool IsSyncable() OVERRIDE; | 83 virtual bool IsSyncable() OVERRIDE; |
| 78 virtual bool MigrateToVersion(int version, | 84 virtual bool MigrateToVersion(int version, |
| 79 const std::string& app_locale, | 85 const std::string& app_locale, |
| 80 bool* update_compatible_version) OVERRIDE; | 86 bool* update_compatible_version) OVERRIDE; |
| 81 | 87 |
| 82 // Adds a new keyword, updating the id field on success. | 88 // Adds a new keyword, updating the id field on success. |
| 83 // Returns true if successful. | 89 // Returns true if successful. |
| 84 bool AddKeyword(const TemplateURLData& data); | 90 bool AddKeyword(const TemplateURLData& data); |
| 85 | 91 |
| 86 // Removes the specified keyword. | 92 // Removes the specified keyword. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 std::string* result); | 158 std::string* result); |
| 153 | 159 |
| 154 // Migrates table |name| (which should be either "keywords" or | 160 // Migrates table |name| (which should be either "keywords" or |
| 155 // "keywords_backup") from version 44 to version 45. | 161 // "keywords_backup") from version 44 to version 45. |
| 156 bool MigrateKeywordsTableForVersion45(const std::string& name); | 162 bool MigrateKeywordsTableForVersion45(const std::string& name); |
| 157 | 163 |
| 158 DISALLOW_COPY_AND_ASSIGN(KeywordTable); | 164 DISALLOW_COPY_AND_ASSIGN(KeywordTable); |
| 159 }; | 165 }; |
| 160 | 166 |
| 161 #endif // CHROME_BROWSER_WEBDATA_KEYWORD_TABLE_H_ | 167 #endif // CHROME_BROWSER_WEBDATA_KEYWORD_TABLE_H_ |
| OLD | NEW |