| 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/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 // Handles storing and retrieving of web intents in the web database. | 16 // Handles storing and retrieving of web intents in the web database. |
| 17 // The registry provides filtering logic to retrieve specific types of intents. | 17 // The registry provides filtering logic to retrieve specific types of intents. |
| 18 class WebIntentsRegistry | 18 class WebIntentsRegistry |
| 19 : public WebDataServiceConsumer, | 19 : public WebDataServiceConsumer, |
| 20 public ProfileKeyedService { | 20 public ProfileKeyedService { |
| 21 public: | 21 public: |
| 22 // Unique identifier for intent queries. | 22 // Unique identifier for intent queries. |
| 23 typedef int QueryID; | 23 typedef int QueryID; |
| 24 | 24 |
| 25 typedef std::vector<WebIntentServiceData> IntentList; | 25 typedef std::vector<webkit_glue::WebIntentServiceData> IntentServiceList; |
| 26 | 26 |
| 27 // An interface the WebIntentsRegistry uses to notify its clients when | 27 // An interface the WebIntentsRegistry uses to notify its clients when |
| 28 // it has finished loading intents data from the web database. | 28 // it has finished loading intents data from the web database. |
| 29 class Consumer { | 29 class Consumer { |
| 30 public: | 30 public: |
| 31 // Notifies the observer that the intents request has been completed. | 31 // Notifies the observer that the intents request has been completed. |
| 32 virtual void OnIntentsQueryDone( | 32 virtual void OnIntentsQueryDone( |
| 33 QueryID query_id, | 33 QueryID query_id, |
| 34 const IntentList& intents) = 0; | 34 const IntentServiceList& intents) = 0; |
| 35 | 35 |
| 36 protected: | 36 protected: |
| 37 virtual ~Consumer() {} | 37 virtual ~Consumer() {} |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 // Initializes, binds to a valid WebDataService. | 40 // Initializes, binds to a valid WebDataService. |
| 41 void Initialize(scoped_refptr<WebDataService> wds, | 41 void Initialize(scoped_refptr<WebDataService> wds, |
| 42 ExtensionServiceInterface* extension_service); | 42 ExtensionServiceInterface* extension_service); |
| 43 | 43 |
| 44 // Registers a web intent provider. | 44 // Registers a web intent provider. |
| 45 virtual void RegisterIntentProvider(const WebIntentServiceData& intent); | 45 virtual void RegisterIntentProvider( |
| 46 const webkit_glue::WebIntentServiceData& intent); |
| 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( |
| 50 const webkit_glue::WebIntentServiceData& intent); |
| 49 | 51 |
| 50 // Requests all intent providers matching |action|. | 52 // Requests all intent providers matching |action|. |
| 51 // |consumer| must not be NULL. | 53 // |consumer| must not be NULL. |
| 52 QueryID GetIntentProviders(const string16& action, Consumer* consumer); | 54 QueryID GetIntentProviders(const string16& action, Consumer* consumer); |
| 53 | 55 |
| 54 // Requests all intent providers. |consumer| must not be NULL | 56 // Requests all intent providers. |consumer| must not be NULL |
| 55 QueryID GetAllIntentProviders(Consumer* consumer); | 57 QueryID GetAllIntentProviders(Consumer* consumer); |
| 56 | 58 |
| 57 protected: | 59 protected: |
| 58 // Make sure that only WebIntentsRegistryFactory can create an instance of | 60 // Make sure that only WebIntentsRegistryFactory can create an instance of |
| (...skipping 29 matching lines...) Expand all Loading... |
| 88 // Shutdown/cleanup is handled by ProfileImpl. We are guaranteed that any | 90 // Shutdown/cleanup is handled by ProfileImpl. We are guaranteed that any |
| 89 // ProfileKeyedService will be shut down before data on ProfileImpl is | 91 // ProfileKeyedService will be shut down before data on ProfileImpl is |
| 90 // destroyed (i.e. |extension_service_|), so |extension_service_| is valid | 92 // destroyed (i.e. |extension_service_|), so |extension_service_| is valid |
| 91 // for the lifetime of the WebIntentsRegistry object. | 93 // for the lifetime of the WebIntentsRegistry object. |
| 92 ExtensionServiceInterface* extension_service_; | 94 ExtensionServiceInterface* extension_service_; |
| 93 | 95 |
| 94 DISALLOW_COPY_AND_ASSIGN(WebIntentsRegistry); | 96 DISALLOW_COPY_AND_ASSIGN(WebIntentsRegistry); |
| 95 }; | 97 }; |
| 96 | 98 |
| 97 #endif // CHROME_BROWSER_INTENTS_WEB_INTENTS_REGISTRY_H_ | 99 #endif // CHROME_BROWSER_INTENTS_WEB_INTENTS_REGISTRY_H_ |
| OLD | NEW |