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 WebIntentsRegistry to return results of data fetch. |
29 typedef base::Callback<void(const IntentServiceList&)> | 30 typedef base::Callback<void(const IntentServiceList&)> |
30 QueryCallback; | 31 QueryCallback; |
31 | 32 |
33 // Callback used by WebIntentsRegistry to return results of data fetch. | |
Greg Billock
2012/07/31 21:43:36
Put what kind of data here and in :29 to different
Steve McKay
2012/07/31 22:09:59
Done. Revised docs.
| |
34 typedef base::Callback<void(const DefaultIntentServiceList&)> | |
35 DefaultIntentServicesCallback; | |
36 | |
32 // Callback to return results of a defaults query. | 37 // Callback to return results of a defaults query. |
33 typedef base::Callback<void(const DefaultWebIntentService&)> | 38 typedef base::Callback<void(const DefaultWebIntentService&)> |
34 DefaultQueryCallback; | 39 DefaultQueryCallback; |
35 | 40 |
36 // Initializes, binds to a valid WebDataService. | 41 // Initializes, binds to a valid WebDataService. |
37 void Initialize(scoped_refptr<WebDataService> wds, | 42 void Initialize(scoped_refptr<WebDataService> wds, |
38 ExtensionServiceInterface* extension_service); | 43 ExtensionServiceInterface* extension_service); |
39 | 44 |
40 // Registers a service. | 45 // Registers a service. |
41 virtual void RegisterIntentService( | 46 virtual void RegisterIntentService( |
42 const webkit_glue::WebIntentServiceData& service); | 47 const webkit_glue::WebIntentServiceData& service); |
43 | 48 |
44 // Removes a service from the registry. | 49 // Removes a service from the registry. |
45 void UnregisterIntentService( | 50 void UnregisterIntentService( |
46 const webkit_glue::WebIntentServiceData& service); | 51 const webkit_glue::WebIntentServiceData& service); |
47 | 52 |
48 // Requests all services matching |action| and |type|. | 53 // Requests all services matching |action| and |type|. |
49 // |type| can contain wildcards, i.e. "image/*" or "*". | 54 // |type| can contain wildcards, i.e. "image/*" or "*". |
50 // |callback| must not be null. | 55 // |callback| must not be null. |
51 void GetIntentServices(const string16& action, | 56 void GetIntentServices(const string16& action, |
52 const string16& type, | 57 const string16& type, |
53 const QueryCallback& callback); | 58 const QueryCallback& callback); |
54 | 59 |
55 // Requests all services. | 60 // Requests all services. |
56 // |callback| must not be null. | 61 // |callback| must not be null. |
57 void GetAllIntentServices(const QueryCallback& callback); | 62 void GetAllIntentServices(const QueryCallback& callback); |
58 | 63 |
64 // Requests all default services. | |
65 // |callback| must not be null. | |
66 void GetAllDefaultIntentServices( | |
67 const DefaultIntentServicesCallback& callback); | |
68 | |
59 // Tests for the existence of the given |service|. Calls the | 69 // Tests for the existence of the given |service|. Calls the |
60 // provided |callback| with true if it exists, false if it does not. | 70 // provided |callback| with true if it exists, false if it does not. |
61 // Checks for |service| equality with ==. | 71 // Checks for |service| equality with ==. |
62 // |callback| must not be null. | 72 // |callback| must not be null. |
63 void IntentServiceExists( | 73 void IntentServiceExists( |
64 const webkit_glue::WebIntentServiceData& service, | 74 const webkit_glue::WebIntentServiceData& service, |
65 const base::Callback<void(bool)>& callback); | 75 const base::Callback<void(bool)>& callback); |
66 | 76 |
67 // Requests all extension services matching |action|, |type| and | 77 // Requests all extension services matching |action|, |type| and |
68 // |extension_id|. | 78 // |extension_id|. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
111 struct QueryParams; | 121 struct QueryParams; |
112 class QueryAdapter; | 122 class QueryAdapter; |
113 typedef std::vector<QueryAdapter*> QueryVector; | 123 typedef std::vector<QueryAdapter*> QueryVector; |
114 | 124 |
115 // Handles services loaded | 125 // Handles services loaded |
116 void OnWebIntentsResultReceived( | 126 void OnWebIntentsResultReceived( |
117 const QueryParams& params, | 127 const QueryParams& params, |
118 const QueryCallback& callback, | 128 const QueryCallback& callback, |
119 const WDTypedResult* result); | 129 const WDTypedResult* result); |
120 | 130 |
131 // Handles derfault services loaded, supplying an unfiltered list | |
Greg Billock
2012/07/31 21:43:36
default
Steve McKay
2012/07/31 22:09:59
Done.
| |
132 // to the callback. | |
133 void OnAllDefaultIntentServicesReceived( | |
134 const DefaultIntentServicesCallback& callback, | |
135 const WDTypedResult* result); | |
136 | |
121 // Handles default services loaded | 137 // Handles default services loaded |
122 void OnWebIntentsDefaultsResultReceived( | 138 void OnWebIntentsDefaultsResultReceived( |
123 const QueryParams& params, | 139 const QueryParams& params, |
124 const DefaultQueryCallback& callback, | 140 const DefaultQueryCallback& callback, |
125 const WDTypedResult* result); | 141 const WDTypedResult* result); |
126 | 142 |
127 // Implementation of GetIntentServicesForExtensionFilter. | 143 // Implementation of GetIntentServicesForExtensionFilter. |
128 void DoGetIntentServicesForExtensionFilter( | 144 void DoGetIntentServicesForExtensionFilter( |
129 const QueryParams& params, | 145 const QueryParams& params, |
130 const std::string& extension_id, | 146 const std::string& extension_id, |
(...skipping 18 matching lines...) Expand all Loading... | |
149 // Shutdown/cleanup is handled by ProfileImpl. We are guaranteed that any | 165 // Shutdown/cleanup is handled by ProfileImpl. We are guaranteed that any |
150 // ProfileKeyedService will be shut down before data on ProfileImpl is | 166 // ProfileKeyedService will be shut down before data on ProfileImpl is |
151 // destroyed (i.e. |extension_service_|), so |extension_service_| is valid | 167 // destroyed (i.e. |extension_service_|), so |extension_service_| is valid |
152 // for the lifetime of the WebIntentsRegistry object. | 168 // for the lifetime of the WebIntentsRegistry object. |
153 ExtensionServiceInterface* extension_service_; | 169 ExtensionServiceInterface* extension_service_; |
154 | 170 |
155 DISALLOW_COPY_AND_ASSIGN(WebIntentsRegistry); | 171 DISALLOW_COPY_AND_ASSIGN(WebIntentsRegistry); |
156 }; | 172 }; |
157 | 173 |
158 #endif // CHROME_BROWSER_INTENTS_WEB_INTENTS_REGISTRY_H_ | 174 #endif // CHROME_BROWSER_INTENTS_WEB_INTENTS_REGISTRY_H_ |
OLD | NEW |