OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.h" |
9 #include "base/hash_tables.h" | 10 #include "base/hash_tables.h" |
10 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
11 #include "chrome/browser/extensions/extension_service.h" | 12 #include "chrome/browser/extensions/extension_service.h" |
12 #include "chrome/browser/profiles/profile_keyed_service.h" | 13 #include "chrome/browser/profiles/profile_keyed_service.h" |
13 #include "chrome/browser/webdata/web_data_service.h" | 14 #include "chrome/browser/webdata/web_data_service.h" |
14 #include "webkit/glue/web_intent_service_data.h" | 15 #include "webkit/glue/web_intent_service_data.h" |
15 | 16 |
16 // Handles storing and retrieving of web intents in the web database. | 17 // Handles storing and retrieving of web intents in the web database. |
17 // The registry provides filtering logic to retrieve specific types of intents. | 18 // The registry provides filtering logic to retrieve specific types of intents. |
18 class WebIntentsRegistry | 19 class WebIntentsRegistry |
(...skipping 16 matching lines...) Expand all Loading... |
35 | 36 |
36 protected: | 37 protected: |
37 virtual ~Consumer() {} | 38 virtual ~Consumer() {} |
38 }; | 39 }; |
39 | 40 |
40 // Initializes, binds to a valid WebDataService. | 41 // Initializes, binds to a valid WebDataService. |
41 void Initialize(scoped_refptr<WebDataService> wds, | 42 void Initialize(scoped_refptr<WebDataService> wds, |
42 ExtensionServiceInterface* extension_service); | 43 ExtensionServiceInterface* extension_service); |
43 | 44 |
44 // Registers a web intent provider. | 45 // Registers a web intent provider. |
45 virtual void RegisterIntentProvider(const WebIntentServiceData& intent); | 46 virtual void RegisterIntentProvider(const WebIntentServiceData& provider); |
46 | 47 |
47 // Removes a web intent provider from the registry. | 48 // Removes a web intent provider from the registry. |
48 void UnregisterIntentProvider(const WebIntentServiceData& intent); | 49 void UnregisterIntentProvider(const WebIntentServiceData& provider); |
49 | 50 |
50 // Requests all intent providers matching |action|. | 51 // Requests all intent providers matching |action|. |
51 // |consumer| must not be NULL. | 52 // |consumer| must not be NULL. |
52 QueryID GetIntentProviders(const string16& action, Consumer* consumer); | 53 QueryID GetIntentProviders(const string16& action, Consumer* consumer); |
53 | 54 |
54 // Requests all intent providers. |consumer| must not be NULL | 55 // Requests all intent providers. |consumer| must not be NULL |
55 QueryID GetAllIntentProviders(Consumer* consumer); | 56 QueryID GetAllIntentProviders(Consumer* consumer); |
56 | 57 |
| 58 // Tests for the existence of the given intent |provider|. Calls the |
| 59 // provided |callback| with true if it exists, false if it does not. |
| 60 // Checks for |provider| equality with ==. |
| 61 QueryID IntentProviderExists(const WebIntentServiceData& provider, |
| 62 const base::Callback<void(bool)>& callback); |
| 63 |
57 protected: | 64 protected: |
58 // Make sure that only WebIntentsRegistryFactory can create an instance of | 65 // Make sure that only WebIntentsRegistryFactory can create an instance of |
59 // WebIntentsRegistry. | 66 // WebIntentsRegistry. |
60 friend class WebIntentsRegistryFactory; | 67 friend class WebIntentsRegistryFactory; |
61 friend class WebIntentsRegistryTest; | 68 friend class WebIntentsRegistryTest; |
62 friend class WebIntentsModelTest; | 69 friend class WebIntentsModelTest; |
63 | 70 |
64 WebIntentsRegistry(); | 71 WebIntentsRegistry(); |
65 virtual ~WebIntentsRegistry(); | 72 virtual ~WebIntentsRegistry(); |
66 | 73 |
(...skipping 21 matching lines...) Expand all Loading... |
88 // Shutdown/cleanup is handled by ProfileImpl. We are guaranteed that any | 95 // Shutdown/cleanup is handled by ProfileImpl. We are guaranteed that any |
89 // ProfileKeyedService will be shut down before data on ProfileImpl is | 96 // ProfileKeyedService will be shut down before data on ProfileImpl is |
90 // destroyed (i.e. |extension_service_|), so |extension_service_| is valid | 97 // destroyed (i.e. |extension_service_|), so |extension_service_| is valid |
91 // for the lifetime of the WebIntentsRegistry object. | 98 // for the lifetime of the WebIntentsRegistry object. |
92 ExtensionServiceInterface* extension_service_; | 99 ExtensionServiceInterface* extension_service_; |
93 | 100 |
94 DISALLOW_COPY_AND_ASSIGN(WebIntentsRegistry); | 101 DISALLOW_COPY_AND_ASSIGN(WebIntentsRegistry); |
95 }; | 102 }; |
96 | 103 |
97 #endif // CHROME_BROWSER_INTENTS_WEB_INTENTS_REGISTRY_H_ | 104 #endif // CHROME_BROWSER_INTENTS_WEB_INTENTS_REGISTRY_H_ |
OLD | NEW |