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/intents/web_intent_data.h" | 11 #include "chrome/browser/intents/web_intent_service_data.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 | 14 |
15 // Handles storing and retrieving of web intents in the web database. | 15 // Handles storing and retrieving of web intents in the web database. |
16 // The registry provides filtering logic to retrieve specific types of intents. | 16 // The registry provides filtering logic to retrieve specific types of intents. |
17 class WebIntentsRegistry | 17 class WebIntentsRegistry |
18 : public WebDataServiceConsumer, | 18 : public WebDataServiceConsumer, |
19 public ProfileKeyedService { | 19 public ProfileKeyedService { |
20 public: | 20 public: |
21 // Unique identifier for intent queries. | 21 // Unique identifier for intent queries. |
22 typedef int QueryID; | 22 typedef int QueryID; |
23 | 23 |
24 // An interface the WebIntentsRegistry uses to notify its clients when | 24 // An interface the WebIntentsRegistry uses to notify its clients when |
25 // it has finished loading intents data from the web database. | 25 // it has finished loading intents data from the web database. |
26 class Consumer { | 26 class Consumer { |
27 public: | 27 public: |
28 // Notifies the observer that the intents request has been completed. | 28 // Notifies the observer that the intents request has been completed. |
29 virtual void OnIntentsQueryDone( | 29 virtual void OnIntentsQueryDone( |
30 QueryID query_id, | 30 QueryID query_id, |
31 const std::vector<WebIntentData>& intents) = 0; | 31 const std::vector<WebIntentServiceData>& intents) = 0; |
32 | 32 |
33 protected: | 33 protected: |
34 virtual ~Consumer() {} | 34 virtual ~Consumer() {} |
35 }; | 35 }; |
36 | 36 |
37 // Initializes, binds to a valid WebDataService. | 37 // Initializes, binds to a valid WebDataService. |
38 void Initialize(scoped_refptr<WebDataService> wds); | 38 void Initialize(scoped_refptr<WebDataService> wds); |
39 | 39 |
40 // Registers a web intent provider. | 40 // Registers a web intent provider. |
41 virtual void RegisterIntentProvider(const WebIntentData& intent); | 41 virtual void RegisterIntentProvider(const WebIntentServiceData& intent); |
42 | 42 |
43 // Removes a web intent provider from the registry. | 43 // Removes a web intent provider from the registry. |
44 void UnregisterIntentProvider(const WebIntentData& intent); | 44 void UnregisterIntentProvider(const WebIntentServiceData& intent); |
45 | 45 |
46 // Requests all intent providers matching |action|. | 46 // Requests all intent providers matching |action|. |
47 // |consumer| must not be NULL. | 47 // |consumer| must not be NULL. |
48 QueryID GetIntentProviders(const string16& action, Consumer* consumer); | 48 QueryID GetIntentProviders(const string16& action, Consumer* consumer); |
49 | 49 |
50 // Requests all intent providers. |consumer| must not be NULL | 50 // Requests all intent providers. |consumer| must not be NULL |
51 QueryID GetAllIntentProviders(Consumer* consumer); | 51 QueryID GetAllIntentProviders(Consumer* consumer); |
52 | 52 |
53 protected: | 53 protected: |
54 // Make sure that only WebIntentsRegistryFactory can create an instance of | 54 // Make sure that only WebIntentsRegistryFactory can create an instance of |
(...skipping 22 matching lines...) Expand all Loading... |
77 // Unique identifier for next intent query. | 77 // Unique identifier for next intent query. |
78 QueryID next_query_id_; | 78 QueryID next_query_id_; |
79 | 79 |
80 // Local reference to Web Data Service. | 80 // Local reference to Web Data Service. |
81 scoped_refptr<WebDataService> wds_; | 81 scoped_refptr<WebDataService> wds_; |
82 | 82 |
83 DISALLOW_COPY_AND_ASSIGN(WebIntentsRegistry); | 83 DISALLOW_COPY_AND_ASSIGN(WebIntentsRegistry); |
84 }; | 84 }; |
85 | 85 |
86 #endif // CHROME_BROWSER_INTENTS_WEB_INTENTS_REGISTRY_H_ | 86 #endif // CHROME_BROWSER_INTENTS_WEB_INTENTS_REGISTRY_H_ |
OLD | NEW |