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_WEB_INTENTS_TABLE_H_ | 5 #ifndef CHROME_BROWSER_WEBDATA_WEB_INTENTS_TABLE_H_ |
6 #define CHROME_BROWSER_WEBDATA_WEB_INTENTS_TABLE_H_ | 6 #define CHROME_BROWSER_WEBDATA_WEB_INTENTS_TABLE_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/string16.h" | 12 #include "base/string16.h" |
13 #include "chrome/browser/webdata/web_database_table.h" | 13 #include "chrome/browser/webdata/web_database_table.h" |
14 #include "webkit/glue/web_intent_service_data.h" | |
15 | 14 |
16 namespace sql { | 15 namespace sql { |
17 class Connection; | 16 class Connection; |
18 class MetaTable; | 17 class MetaTable; |
19 } | 18 } |
20 | 19 |
21 struct DefaultWebIntentService; | 20 struct DefaultWebIntentService; |
22 | 21 |
| 22 // TODO(thakis): Delete this class once there's a migration that drops the |
| 23 // table backing it. |
| 24 |
23 // This class manages the WebIntents table within the SQLite database passed | 25 // This class manages the WebIntents table within the SQLite database passed |
24 // to the constructor. It expects the following schema: | 26 // to the constructor. It expects the following schema: |
25 // | 27 // |
26 // web_intents | 28 // web_intents |
27 // service_url URL for service invocation. | 29 // service_url URL for service invocation. |
28 // action Name of action provided by the service. | 30 // action Name of action provided by the service. |
29 // type MIME type of data accepted by the service. | 31 // type MIME type of data accepted by the service. |
30 // title Title for the service page | 32 // title Title for the service page |
31 // disposition Either 'window' or 'inline' disposition. | 33 // disposition Either 'window' or 'inline' disposition. |
32 // | 34 // |
(...skipping 18 matching lines...) Expand all Loading... |
51 WebIntentsTable(sql::Connection* db, sql::MetaTable* meta_table); | 53 WebIntentsTable(sql::Connection* db, sql::MetaTable* meta_table); |
52 virtual ~WebIntentsTable(); | 54 virtual ~WebIntentsTable(); |
53 | 55 |
54 // WebDatabaseTable implementation. | 56 // WebDatabaseTable implementation. |
55 virtual bool Init() OVERRIDE; | 57 virtual bool Init() OVERRIDE; |
56 virtual bool IsSyncable() OVERRIDE; | 58 virtual bool IsSyncable() OVERRIDE; |
57 | 59 |
58 // Adds "scheme" column to the web_intents and web_intents_defaults tables. | 60 // Adds "scheme" column to the web_intents and web_intents_defaults tables. |
59 bool MigrateToVersion46AddSchemeColumn(); | 61 bool MigrateToVersion46AddSchemeColumn(); |
60 | 62 |
61 #if (ENABLE_WEB_INTENTS) | |
62 // Adds a web intent service to the WebIntents table. | |
63 // If |service| already exists, replaces it. | |
64 bool SetWebIntentService(const webkit_glue::WebIntentServiceData& service); | |
65 | |
66 // Retrieve all |services| from WebIntents table that match |action|. | |
67 bool GetWebIntentServicesForAction( | |
68 const string16& action, | |
69 std::vector<webkit_glue::WebIntentServiceData>* services); | |
70 | |
71 // Retrieve all |services| from WebIntents table that match |scheme|. | |
72 bool GetWebIntentServicesForScheme( | |
73 const string16& scheme, | |
74 std::vector<webkit_glue::WebIntentServiceData>* services); | |
75 | |
76 // Retrieves all |services| from WebIntents table that match |service_url|. | |
77 bool GetWebIntentServicesForURL( | |
78 const string16& service_url, | |
79 std::vector<webkit_glue::WebIntentServiceData>* services); | |
80 | |
81 // Retrieve all |services| from WebIntents table. | |
82 bool GetAllWebIntentServices( | |
83 std::vector<webkit_glue::WebIntentServiceData>* services); | |
84 | |
85 // Removes |service| from WebIntents table - must match all parameters | |
86 // exactly. | |
87 bool RemoveWebIntentService(const webkit_glue::WebIntentServiceData& service); | |
88 | |
89 // Get the default service to be used for the given intent invocation. | |
90 // If any overlapping defaults are found, they're placed in | |
91 // |default_services|, otherwise, it is untouched. | |
92 // Returns true if the method runs successfully, false on database error. | |
93 bool GetDefaultServices( | |
94 const string16& action, | |
95 std::vector<DefaultWebIntentService>* default_services); | |
96 | |
97 // Get a list of all installed default services. | |
98 bool GetAllDefaultServices( | |
99 std::vector<DefaultWebIntentService>* default_services); | |
100 | |
101 // Set a default service to be used on given intent invocations. | |
102 bool SetDefaultService(const DefaultWebIntentService& default_service); | |
103 | |
104 // Removes a default |service| from table - must match the action, type, | |
105 // and url_pattern parameters exactly. | |
106 bool RemoveDefaultService(const DefaultWebIntentService& default_service); | |
107 | |
108 // Removes all default services associated with |service_url|. | |
109 bool RemoveServiceDefaults(const GURL& service_url); | |
110 #endif | |
111 | |
112 private: | 63 private: |
113 DISALLOW_COPY_AND_ASSIGN(WebIntentsTable); | 64 DISALLOW_COPY_AND_ASSIGN(WebIntentsTable); |
114 }; | 65 }; |
115 | 66 |
116 #endif // CHROME_BROWSER_WEBDATA_WEB_INTENTS_TABLE_H_ | 67 #endif // CHROME_BROWSER_WEBDATA_WEB_INTENTS_TABLE_H_ |
OLD | NEW |