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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/callback_forward.h" | 9 #include "base/callback_forward.h" |
10 #include "base/hash_tables.h" | 10 #include "base/hash_tables.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "chrome/browser/extensions/extension_service.h" | 12 #include "chrome/browser/extensions/extension_service.h" |
13 #include "chrome/browser/profiles/profile_keyed_service.h" | 13 #include "chrome/browser/profiles/profile_keyed_service.h" |
14 #include "chrome/browser/webdata/web_data_service.h" | 14 #include "chrome/browser/webdata/web_data_service.h" |
15 #include "webkit/glue/web_intent_service_data.h" | 15 #include "webkit/glue/web_intent_service_data.h" |
16 | 16 |
17 struct DefaultWebIntentService; | 17 struct DefaultWebIntentService; |
18 | 18 |
| 19 namespace extensions { |
| 20 class Extension; |
| 21 } |
| 22 |
19 // Handles storing and retrieving of web intents services in the web database. | 23 // Handles storing and retrieving of web intents services in the web database. |
20 // The registry provides filtering logic to retrieve specific types of services. | 24 // The registry provides filtering logic to retrieve specific types of services. |
21 class WebIntentsRegistry | 25 class WebIntentsRegistry |
22 : public WebDataServiceConsumer, | 26 : public WebDataServiceConsumer, |
23 public ProfileKeyedService { | 27 public ProfileKeyedService { |
24 public: | 28 public: |
25 typedef std::vector<webkit_glue::WebIntentServiceData> IntentServiceList; | 29 typedef std::vector<webkit_glue::WebIntentServiceData> IntentServiceList; |
26 | 30 |
27 // Callback used by WebIntentsRegistry to return results of data fetch. | 31 // Callback used by WebIntentsRegistry to return results of data fetch. |
28 typedef base::Callback<void(const IntentServiceList&)> | 32 typedef base::Callback<void(const IntentServiceList&)> |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 WebIntentsRegistry(); | 104 WebIntentsRegistry(); |
101 virtual ~WebIntentsRegistry(); | 105 virtual ~WebIntentsRegistry(); |
102 | 106 |
103 // Collapses a list of IntentServices by joining intents that have identical | 107 // Collapses a list of IntentServices by joining intents that have identical |
104 // service URLs, actions, and mime types. | 108 // service URLs, actions, and mime types. |
105 // |services| is the list of intent services to be collapsed when passed in | 109 // |services| is the list of intent services to be collapsed when passed in |
106 // and will be modified with the new list in-place. | 110 // and will be modified with the new list in-place. |
107 void CollapseIntents(IntentServiceList* services); | 111 void CollapseIntents(IntentServiceList* services); |
108 | 112 |
109 private: | 113 private: |
110 const Extension* ExtensionForURL(const std::string& url); | 114 const extensions::Extension* ExtensionForURL(const std::string& url); |
111 | 115 |
112 struct IntentsQuery; | 116 struct IntentsQuery; |
113 | 117 |
114 // Maps web data requests to intents queries. | 118 // Maps web data requests to intents queries. |
115 // Allows OnWebDataServiceRequestDone to forward to appropriate consumer. | 119 // Allows OnWebDataServiceRequestDone to forward to appropriate consumer. |
116 typedef base::hash_map<WebDataService::Handle, IntentsQuery*> QueryMap; | 120 typedef base::hash_map<WebDataService::Handle, IntentsQuery*> QueryMap; |
117 | 121 |
118 // WebDataServiceConsumer implementation. | 122 // WebDataServiceConsumer implementation. |
119 virtual void OnWebDataServiceRequestDone( | 123 virtual void OnWebDataServiceRequestDone( |
120 WebDataService::Handle h, | 124 WebDataService::Handle h, |
(...skipping 18 matching lines...) Expand all Loading... |
139 // Shutdown/cleanup is handled by ProfileImpl. We are guaranteed that any | 143 // Shutdown/cleanup is handled by ProfileImpl. We are guaranteed that any |
140 // ProfileKeyedService will be shut down before data on ProfileImpl is | 144 // ProfileKeyedService will be shut down before data on ProfileImpl is |
141 // destroyed (i.e. |extension_service_|), so |extension_service_| is valid | 145 // destroyed (i.e. |extension_service_|), so |extension_service_| is valid |
142 // for the lifetime of the WebIntentsRegistry object. | 146 // for the lifetime of the WebIntentsRegistry object. |
143 ExtensionServiceInterface* extension_service_; | 147 ExtensionServiceInterface* extension_service_; |
144 | 148 |
145 DISALLOW_COPY_AND_ASSIGN(WebIntentsRegistry); | 149 DISALLOW_COPY_AND_ASSIGN(WebIntentsRegistry); |
146 }; | 150 }; |
147 | 151 |
148 #endif // CHROME_BROWSER_INTENTS_WEB_INTENTS_REGISTRY_H_ | 152 #endif // CHROME_BROWSER_INTENTS_WEB_INTENTS_REGISTRY_H_ |
OLD | NEW |