OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_INTENTS_WEB_INTENTS_REGISTRY_H_ | |
6 #define CHROME_BROWSER_INTENTS_WEB_INTENTS_REGISTRY_H_ | |
7 #pragma once | |
8 | |
9 #include "base/hash_tables.h" | |
10 #include "base/memory/ref_counted.h" | |
11 #include "chrome/browser/intents/web_intent_data.h" | |
12 #include "chrome/browser/webdata/web_data_service.h" | |
13 | |
14 // Handles storing and retrieving of web intents in the web database. | |
15 // The registry provides filtering logic to retrieve specific types of intents. | |
16 class WebIntentsRegistry: public WebDataServiceConsumer { | |
James Hawkins
2011/08/05 20:47:12
Space before colon.
groby-ooo-7-16
2011/08/05 20:54:11
Done.
| |
17 public: | |
18 typedef int QueryID; // unique identifier for intent queries. | |
James Hawkins
2011/08/05 20:47:12
Capitalize comment, move to the line above the typ
groby-ooo-7-16
2011/08/05 20:54:11
Done.
| |
19 | |
20 // An interface the WebIntentsRegistry uses to notify its clients when | |
21 // it has finished loading intents data from the web database. | |
22 class Consumer { | |
23 public: | |
24 // Notifies the observer that the intents request has been completed. | |
25 virtual void OnIntentsQueryDone( | |
26 QueryID query_id, | |
27 const std::vector<WebIntentData>& intents) = 0; | |
28 | |
29 protected: | |
30 virtual ~Consumer() {} | |
31 }; | |
32 | |
33 WebIntentsRegistry(); | |
34 virtual ~WebIntentsRegistry(); | |
35 | |
36 // Initializes, binds to a valid WebDataService. | |
37 void Initialize(scoped_refptr<WebDataService> wds); | |
38 | |
39 // Registers a web intent provider. | |
40 void RegisterIntentProvider(const WebIntentData& intent); | |
41 | |
42 // Removes a web intent provider from the registry. | |
43 void UnregisterIntentProvider(const WebIntentData& intent); | |
44 | |
45 // Requests all intent providers matching |action|. | |
46 // |consumer| must not be NULL. | |
47 QueryID GetIntentProviders(const string16& action, Consumer* consumer); | |
48 | |
49 private: | |
50 struct IntentsQuery; | |
51 | |
52 // Map web data requests to intents queries. | |
James Hawkins
2011/08/05 20:47:12
Maps
groby-ooo-7-16
2011/08/05 20:54:11
Done.
| |
53 // Allows OnWebDataServiceRequestDone to forward to appropiate consumer. | |
54 typedef base::hash_map<WebDataService::Handle, IntentsQuery*> QueryMap; | |
James Hawkins
2011/08/05 20:47:12
2 space indentation.
groby-ooo-7-16
2011/08/05 20:54:11
Done.
| |
55 | |
56 // WebDataServiceConsumer implementation. | |
57 virtual void OnWebDataServiceRequestDone(WebDataService::Handle h, | |
58 const WDTypedResult* result); | |
59 | |
60 QueryMap queries; // Map for all in-flight web data requests/intent queries. | |
James Hawkins
2011/08/05 20:47:12
In general, defining comments should be on the lin
groby-ooo-7-16
2011/08/05 20:54:11
Done.
| |
61 QueryID next_query_id_; // Unique identifier for next intent query. | |
62 scoped_refptr<WebDataService> wds_; // Local reference to Web Data Service. | |
63 | |
64 DISALLOW_COPY_AND_ASSIGN(WebIntentsRegistry); | |
65 }; | |
66 | |
67 #endif // CHROME_BROWSER_INTENTS_WEB_INTENTS_REGISTRY_H_ | |
OLD | NEW |