| OLD | NEW |
| 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.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 "webkit/glue/web_intent_service_data.h" | 15 #include "webkit/glue/web_intent_service_data.h" |
| 16 | 16 |
| 17 namespace sql { | 17 namespace sql { |
| 18 class Connection; | 18 class Connection; |
| 19 class MetaTable; | 19 class MetaTable; |
| 20 } | 20 } |
| 21 | 21 |
| 22 struct DefaultWebIntentService; |
| 23 |
| 22 // This class manages the WebIntents table within the SQLite database passed | 24 // This class manages the WebIntents table within the SQLite database passed |
| 23 // to the constructor. It expects the following schema: | 25 // to the constructor. It expects the following schema: |
| 24 // | 26 // |
| 25 // web_intents | 27 // web_intents |
| 26 // service_url URL for service invocation. | 28 // service_url URL for service invocation. |
| 27 // action Name of action provided by the service. | 29 // action Name of action provided by the service. |
| 28 // type MIME type of data accepted by the service. | 30 // type MIME type of data accepted by the service. |
| 31 // title Title for the service page |
| 32 // disposition Either 'window' or 'inline' disposition. |
| 29 // | 33 // |
| 30 // Intents are uniquely identified by the <service_url,action,type> tuple. | 34 // Web Intent Services are uniquely identified by the <service_url,action,type> |
| 35 // tuple. |
| 36 // |
| 37 // Also manages the defaults table: |
| 38 // |
| 39 // web_intents_defaults |
| 40 // action Intent action for this default. |
| 41 // type Intent type for this default. |
| 42 // url_prefix URL prefix for which the default is invoked. |
| 43 // user_date Epoch time when the user made this default. |
| 44 // suppression Set if the default is (temporarily) suppressed. |
| 45 // service_url The URL of a service in the web_intents table. |
| 46 // extension_url The URL for an extension handling intents. |
| 47 // |
| 48 // The defaults are scoped by action, then type, then url prefix. |
| 49 // |
| 31 class WebIntentsTable : public WebDatabaseTable { | 50 class WebIntentsTable : public WebDatabaseTable { |
| 32 public: | 51 public: |
| 33 WebIntentsTable(sql::Connection* db, sql::MetaTable* meta_table); | 52 WebIntentsTable(sql::Connection* db, sql::MetaTable* meta_table); |
| 34 virtual ~WebIntentsTable(); | 53 virtual ~WebIntentsTable(); |
| 35 | 54 |
| 36 // WebDatabaseTable implementation. | 55 // WebDatabaseTable implementation. |
| 37 virtual bool Init() OVERRIDE; | 56 virtual bool Init() OVERRIDE; |
| 38 virtual bool IsSyncable() OVERRIDE; | 57 virtual bool IsSyncable() OVERRIDE; |
| 39 | 58 |
| 40 // Adds a web intent service to the WebIntents table. | 59 // Adds a web intent service to the WebIntents table. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 52 std::vector<webkit_glue::WebIntentServiceData>* services); | 71 std::vector<webkit_glue::WebIntentServiceData>* services); |
| 53 | 72 |
| 54 // Retrieve all |services| from WebIntents table. | 73 // Retrieve all |services| from WebIntents table. |
| 55 bool GetAllWebIntentServices( | 74 bool GetAllWebIntentServices( |
| 56 std::vector<webkit_glue::WebIntentServiceData>* services); | 75 std::vector<webkit_glue::WebIntentServiceData>* services); |
| 57 | 76 |
| 58 // Removes |service| from WebIntents table - must match all parameters | 77 // Removes |service| from WebIntents table - must match all parameters |
| 59 // exactly. | 78 // exactly. |
| 60 bool RemoveWebIntentService(const webkit_glue::WebIntentServiceData& service); | 79 bool RemoveWebIntentService(const webkit_glue::WebIntentServiceData& service); |
| 61 | 80 |
| 81 // Get the default service to be used for the given intent invocation. |
| 82 // If any overlapping defaults are found, they're placed in |
| 83 // |default_services|, otherwise, it is untouched. |
| 84 // Returns true if the method runs successfully, false on database error. |
| 85 bool GetDefaultServices( |
| 86 const string16& action, |
| 87 std::vector<DefaultWebIntentService>* default_services); |
| 88 |
| 89 // Get a list of all installed default services. |
| 90 bool GetAllDefaultServices( |
| 91 std::vector<DefaultWebIntentService>* default_services); |
| 92 |
| 93 // Set a default service to be used on given intent invocations. |
| 94 bool SetDefaultService(const DefaultWebIntentService& default_service); |
| 95 |
| 96 // Removes a default |service| from table - must match the action, type, |
| 97 // and url_prefix parameters exactly. |
| 98 bool RemoveDefaultService(const DefaultWebIntentService& default_service); |
| 99 |
| 62 private: | 100 private: |
| 63 DISALLOW_COPY_AND_ASSIGN(WebIntentsTable); | 101 DISALLOW_COPY_AND_ASSIGN(WebIntentsTable); |
| 64 }; | 102 }; |
| 65 | 103 |
| 66 #endif // CHROME_BROWSER_WEBDATA_WEB_INTENTS_TABLE_H_ | 104 #endif // CHROME_BROWSER_WEBDATA_WEB_INTENTS_TABLE_H_ |
| OLD | NEW |