Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(223)

Side by Side Diff: chrome/browser/intents/web_intents_registry.h

Issue 7601013: Web Intents: Hook up the register intent InfoBar with the WebIntentsRegistry. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Missing files. Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_data.h"
12 #include "chrome/browser/profiles/profile_keyed_service.h"
12 #include "chrome/browser/webdata/web_data_service.h" 13 #include "chrome/browser/webdata/web_data_service.h"
13 14
14 // Handles storing and retrieving of web intents in the web database. 15 // Handles storing and retrieving of web intents in the web database.
15 // The registry provides filtering logic to retrieve specific types of intents. 16 // The registry provides filtering logic to retrieve specific types of intents.
16 class WebIntentsRegistry : public WebDataServiceConsumer { 17 class WebIntentsRegistry
18 : public WebDataServiceConsumer,
19 public ProfileKeyedService {
17 public: 20 public:
18 // Unique identifier for intent queries. 21 // Unique identifier for intent queries.
19 typedef int QueryID; 22 typedef int QueryID;
20 23
21 // An interface the WebIntentsRegistry uses to notify its clients when 24 // An interface the WebIntentsRegistry uses to notify its clients when
22 // it has finished loading intents data from the web database. 25 // it has finished loading intents data from the web database.
23 class Consumer { 26 class Consumer {
24 public: 27 public:
25 // Notifies the observer that the intents request has been completed. 28 // Notifies the observer that the intents request has been completed.
26 virtual void OnIntentsQueryDone( 29 virtual void OnIntentsQueryDone(
27 QueryID query_id, 30 QueryID query_id,
28 const std::vector<WebIntentData>& intents) = 0; 31 const std::vector<WebIntentData>& intents) = 0;
29 32
30 protected: 33 protected:
31 virtual ~Consumer() {} 34 virtual ~Consumer() {}
32 }; 35 };
33 36
34 WebIntentsRegistry();
35 virtual ~WebIntentsRegistry();
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 void RegisterIntentProvider(const WebIntentData& intent); 41 virtual void RegisterIntentProvider(const WebIntentData& 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 WebIntentData& 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 protected:
51 // Make sure that only WebIntentsRegistryFactory can create an instance of
52 // WebIntentsRegistry.
53 friend class WebIntentsRegistryFactory;
54 friend class WebIntentsRegistryTest;
55
56 WebIntentsRegistry();
57 virtual ~WebIntentsRegistry();
58
50 private: 59 private:
51 struct IntentsQuery; 60 struct IntentsQuery;
52 61
53 // Maps web data requests to intents queries. 62 // Maps web data requests to intents queries.
54 // Allows OnWebDataServiceRequestDone to forward to appropiate consumer. 63 // Allows OnWebDataServiceRequestDone to forward to appropriate consumer.
55 typedef base::hash_map<WebDataService::Handle, IntentsQuery*> QueryMap; 64 typedef base::hash_map<WebDataService::Handle, IntentsQuery*> QueryMap;
56 65
57 // WebDataServiceConsumer implementation. 66 // WebDataServiceConsumer implementation.
58 virtual void OnWebDataServiceRequestDone(WebDataService::Handle h, 67 virtual void OnWebDataServiceRequestDone(WebDataService::Handle h,
59 const WDTypedResult* result); 68 const WDTypedResult* result);
60 69
61 // Map for all in-flight web data requests/intent queries. 70 // Map for all in-flight web data requests/intent queries.
62 QueryMap queries_; 71 QueryMap queries_;
63 72
64 // Unique identifier for next intent query. 73 // Unique identifier for next intent query.
65 QueryID next_query_id_; 74 QueryID next_query_id_;
66 75
67 // Local reference to Web Data Service. 76 // Local reference to Web Data Service.
68 scoped_refptr<WebDataService> wds_; 77 scoped_refptr<WebDataService> wds_;
69 78
70 DISALLOW_COPY_AND_ASSIGN(WebIntentsRegistry); 79 DISALLOW_COPY_AND_ASSIGN(WebIntentsRegistry);
71 }; 80 };
72 81
73 #endif // CHROME_BROWSER_INTENTS_WEB_INTENTS_REGISTRY_H_ 82 #endif // CHROME_BROWSER_INTENTS_WEB_INTENTS_REGISTRY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698