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_INTENTS_WEB_INTENTS_REGISTRY_H_ | 5 #ifndef CHROME_BROWSER_INTENTS_WEB_INTENTS_REGISTRY_H_ |
6 #define CHROME_BROWSER_INTENTS_WEB_INTENTS_REGISTRY_H_ | 6 #define CHROME_BROWSER_INTENTS_WEB_INTENTS_REGISTRY_H_ |
7 | 7 |
8 #include "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
9 #include "base/hash_tables.h" | 9 #include "base/hash_tables.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "chrome/browser/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
12 #include "chrome/browser/profiles/profile_keyed_service.h" | 12 #include "chrome/browser/profiles/profile_keyed_service.h" |
13 #include "chrome/browser/webdata/web_data_service.h" | 13 #include "chrome/browser/webdata/web_data_service.h" |
14 #include "webkit/glue/web_intent_service_data.h" | 14 #include "webkit/glue/web_intent_service_data.h" |
15 | 15 |
16 struct DefaultWebIntentService; | 16 struct DefaultWebIntentService; |
17 | 17 |
18 namespace extensions { | 18 namespace extensions { |
19 class Extension; | 19 class Extension; |
20 } | 20 } |
21 | 21 |
22 // Handles storing and retrieving of web intents services in the web database. | 22 // Handles storing and retrieving of web intents services in the web database. |
23 // The registry provides filtering logic to retrieve specific types of services. | 23 // The registry provides filtering logic to retrieve specific types of services. |
24 class WebIntentsRegistry : public ProfileKeyedService { | 24 class WebIntentsRegistry : public ProfileKeyedService { |
25 public: | 25 public: |
26 typedef std::vector<webkit_glue::WebIntentServiceData> IntentServiceList; | 26 typedef std::vector<webkit_glue::WebIntentServiceData> IntentServiceList; |
| 27 typedef std::vector<DefaultWebIntentService> DefaultIntentServiceList; |
27 | 28 |
28 // Callback used by WebIntentsRegistry to return results of data fetch. | 29 // Callback used by callers to accept results of a query for |
| 30 // a list of |WebIntentServiceData|. |
29 typedef base::Callback<void(const IntentServiceList&)> | 31 typedef base::Callback<void(const IntentServiceList&)> |
30 QueryCallback; | 32 QueryCallback; |
31 | 33 |
32 // Callback to return results of a defaults query. | 34 // Callback used by callers to accept results of a query for |
| 35 // a list of |DefaultWebIntentService|. |
| 36 typedef base::Callback<void(const DefaultIntentServiceList&)> |
| 37 DefaultIntentServicesCallback; |
| 38 |
| 39 // Callback used by callers to accept results of a query for |
| 40 // a |DefaultWebIntentService|. |
33 typedef base::Callback<void(const DefaultWebIntentService&)> | 41 typedef base::Callback<void(const DefaultWebIntentService&)> |
34 DefaultQueryCallback; | 42 DefaultQueryCallback; |
35 | 43 |
36 // Initializes, binds to a valid WebDataService. | 44 // Initializes, binds to a valid WebDataService. |
37 void Initialize(scoped_refptr<WebDataService> wds, | 45 void Initialize(scoped_refptr<WebDataService> wds, |
38 ExtensionServiceInterface* extension_service); | 46 ExtensionServiceInterface* extension_service); |
39 | 47 |
40 // Registers a service. | 48 // Registers a service. |
41 virtual void RegisterIntentService( | 49 virtual void RegisterIntentService( |
42 const webkit_glue::WebIntentServiceData& service); | 50 const webkit_glue::WebIntentServiceData& service); |
43 | 51 |
44 // Removes a service from the registry. | 52 // Removes a service from the registry. |
45 void UnregisterIntentService( | 53 void UnregisterIntentService( |
46 const webkit_glue::WebIntentServiceData& service); | 54 const webkit_glue::WebIntentServiceData& service); |
47 | 55 |
48 // Requests all services matching |action| and |type|. | 56 // Requests all services matching |action| and |type|. |
49 // |type| can contain wildcards, i.e. "image/*" or "*". | 57 // |type| can contain wildcards, i.e. "image/*" or "*". |
50 // |callback| must not be null. | 58 // |callback| must not be null. |
51 void GetIntentServices(const string16& action, | 59 void GetIntentServices(const string16& action, |
52 const string16& type, | 60 const string16& type, |
53 const QueryCallback& callback); | 61 const QueryCallback& callback); |
54 | 62 |
55 // Requests all services. | 63 // Requests all services. |
56 // |callback| must not be null. | 64 // |callback| must not be null. |
57 void GetAllIntentServices(const QueryCallback& callback); | 65 void GetAllIntentServices(const QueryCallback& callback); |
58 | 66 |
| 67 // Requests all default services. |
| 68 // |callback| must not be null. |
| 69 void GetAllDefaultIntentServices( |
| 70 const DefaultIntentServicesCallback& callback); |
| 71 |
59 // Tests for the existence of the given |service|. Calls the | 72 // Tests for the existence of the given |service|. Calls the |
60 // provided |callback| with true if it exists, false if it does not. | 73 // provided |callback| with true if it exists, false if it does not. |
61 // Checks for |service| equality with ==. | 74 // Checks for |service| equality with ==. |
62 // |callback| must not be null. | 75 // |callback| must not be null. |
63 void IntentServiceExists( | 76 void IntentServiceExists( |
64 const webkit_glue::WebIntentServiceData& service, | 77 const webkit_glue::WebIntentServiceData& service, |
65 const base::Callback<void(bool)>& callback); | 78 const base::Callback<void(bool)>& callback); |
66 | 79 |
67 // Requests all extension services matching |action|, |type| and | 80 // Requests all extension services matching |action|, |type| and |
68 // |extension_id|. | 81 // |extension_id|. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 struct QueryParams; | 124 struct QueryParams; |
112 class QueryAdapter; | 125 class QueryAdapter; |
113 typedef std::vector<QueryAdapter*> QueryVector; | 126 typedef std::vector<QueryAdapter*> QueryVector; |
114 | 127 |
115 // Handles services loaded | 128 // Handles services loaded |
116 void OnWebIntentsResultReceived( | 129 void OnWebIntentsResultReceived( |
117 const QueryParams& params, | 130 const QueryParams& params, |
118 const QueryCallback& callback, | 131 const QueryCallback& callback, |
119 const WDTypedResult* result); | 132 const WDTypedResult* result); |
120 | 133 |
| 134 // Handles default services loaded, supplying an unfiltered list |
| 135 // to the callback. |
| 136 void OnAllDefaultIntentServicesReceived( |
| 137 const DefaultIntentServicesCallback& callback, |
| 138 const WDTypedResult* result); |
| 139 |
121 // Handles default services loaded | 140 // Handles default services loaded |
122 void OnWebIntentsDefaultsResultReceived( | 141 void OnWebIntentsDefaultsResultReceived( |
123 const QueryParams& params, | 142 const QueryParams& params, |
124 const DefaultQueryCallback& callback, | 143 const DefaultQueryCallback& callback, |
125 const WDTypedResult* result); | 144 const WDTypedResult* result); |
126 | 145 |
127 // Implementation of GetIntentServicesForExtensionFilter. | 146 // Implementation of GetIntentServicesForExtensionFilter. |
128 void DoGetIntentServicesForExtensionFilter( | 147 void DoGetIntentServicesForExtensionFilter( |
129 const QueryParams& params, | 148 const QueryParams& params, |
130 const std::string& extension_id, | 149 const std::string& extension_id, |
(...skipping 18 matching lines...) Expand all Loading... |
149 // Shutdown/cleanup is handled by ProfileImpl. We are guaranteed that any | 168 // Shutdown/cleanup is handled by ProfileImpl. We are guaranteed that any |
150 // ProfileKeyedService will be shut down before data on ProfileImpl is | 169 // ProfileKeyedService will be shut down before data on ProfileImpl is |
151 // destroyed (i.e. |extension_service_|), so |extension_service_| is valid | 170 // destroyed (i.e. |extension_service_|), so |extension_service_| is valid |
152 // for the lifetime of the WebIntentsRegistry object. | 171 // for the lifetime of the WebIntentsRegistry object. |
153 ExtensionServiceInterface* extension_service_; | 172 ExtensionServiceInterface* extension_service_; |
154 | 173 |
155 DISALLOW_COPY_AND_ASSIGN(WebIntentsRegistry); | 174 DISALLOW_COPY_AND_ASSIGN(WebIntentsRegistry); |
156 }; | 175 }; |
157 | 176 |
158 #endif // CHROME_BROWSER_INTENTS_WEB_INTENTS_REGISTRY_H_ | 177 #endif // CHROME_BROWSER_INTENTS_WEB_INTENTS_REGISTRY_H_ |
OLD | NEW |