Index: chrome/browser/intents/web_intents_registry.h |
diff --git a/chrome/browser/intents/web_intents_registry.h b/chrome/browser/intents/web_intents_registry.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ccc486b7d965c76a1805eac02c4cec543ebb5377 |
--- /dev/null |
+++ b/chrome/browser/intents/web_intents_registry.h |
@@ -0,0 +1,67 @@ |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_INTENTS_WEB_INTENTS_REGISTRY_H_ |
+#define CHROME_BROWSER_INTENTS_WEB_INTENTS_REGISTRY_H_ |
+#pragma once |
+ |
+#include "base/hash_tables.h" |
+#include "base/memory/ref_counted.h" |
+#include "chrome/browser/intents/web_intent_data.h" |
+#include "chrome/browser/webdata/web_data_service.h" |
+ |
+// Handles storing and retrieving of web intents in the web database. |
+// The registry provides filtering logic to retrieve specific types of intents. |
+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.
|
+ public: |
+ 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.
|
+ |
+ // An interface the WebIntentsRegistry uses to notify its clients when |
+ // it has finished loading intents data from the web database. |
+ class Consumer { |
+ public: |
+ // Notifies the observer that the intents request has been completed. |
+ virtual void OnIntentsQueryDone( |
+ QueryID query_id, |
+ const std::vector<WebIntentData>& intents) = 0; |
+ |
+ protected: |
+ virtual ~Consumer() {} |
+ }; |
+ |
+ WebIntentsRegistry(); |
+ virtual ~WebIntentsRegistry(); |
+ |
+ // Initializes, binds to a valid WebDataService. |
+ void Initialize(scoped_refptr<WebDataService> wds); |
+ |
+ // Registers a web intent provider. |
+ void RegisterIntentProvider(const WebIntentData& intent); |
+ |
+ // Removes a web intent provider from the registry. |
+ void UnregisterIntentProvider(const WebIntentData& intent); |
+ |
+ // Requests all intent providers matching |action|. |
+ // |consumer| must not be NULL. |
+ QueryID GetIntentProviders(const string16& action, Consumer* consumer); |
+ |
+ private: |
+ struct IntentsQuery; |
+ |
+ // 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.
|
+ // Allows OnWebDataServiceRequestDone to forward to appropiate consumer. |
+ 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.
|
+ |
+ // WebDataServiceConsumer implementation. |
+ virtual void OnWebDataServiceRequestDone(WebDataService::Handle h, |
+ const WDTypedResult* result); |
+ |
+ 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.
|
+ QueryID next_query_id_; // Unique identifier for next intent query. |
+ scoped_refptr<WebDataService> wds_; // Local reference to Web Data Service. |
+ |
+ DISALLOW_COPY_AND_ASSIGN(WebIntentsRegistry); |
+}; |
+ |
+#endif // CHROME_BROWSER_INTENTS_WEB_INTENTS_REGISTRY_H_ |