Commit 43e58451 authored by smckay@chromium.org's avatar smckay@chromium.org

Use IntentsQuery as the WDS consumer. By unencumbering WebIntentsRegistry of...

Use IntentsQuery as the WDS consumer. By unencumbering WebIntentsRegistry of this responsibility we'll be able to more easily accommodate new request types.

BUG=137907
TEST=WebIntentsRegistryTest.*


Review URL: https://chromiumcodereview.appspot.com/10827056

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148714 0039d316-1c4b-4281-b951-d872f2087c98
parent b332977a
...@@ -21,9 +21,7 @@ class Extension; ...@@ -21,9 +21,7 @@ class Extension;
// Handles storing and retrieving of web intents services in the web database. // Handles storing and retrieving of web intents services in the web database.
// The registry provides filtering logic to retrieve specific types of services. // The registry provides filtering logic to retrieve specific types of services.
class WebIntentsRegistry class WebIntentsRegistry : public ProfileKeyedService {
: public WebDataServiceConsumer,
public ProfileKeyedService {
public: public:
typedef std::vector<webkit_glue::WebIntentServiceData> IntentServiceList; typedef std::vector<webkit_glue::WebIntentServiceData> IntentServiceList;
...@@ -47,11 +45,11 @@ class WebIntentsRegistry ...@@ -47,11 +45,11 @@ class WebIntentsRegistry
void UnregisterIntentService( void UnregisterIntentService(
const webkit_glue::WebIntentServiceData& service); const webkit_glue::WebIntentServiceData& service);
// Requests all services matching |action| and |mimetype|. // Requests all services matching |action| and |type|.
// |mimetype| can contain wildcards, i.e. "image/*" or "*". // |type| can contain wildcards, i.e. "image/*" or "*".
// |callback| must not be null. // |callback| must not be null.
void GetIntentServices(const string16& action, void GetIntentServices(const string16& action,
const string16& mimetype, const string16& type,
const QueryCallback& callback); const QueryCallback& callback);
// Requests all services. // Requests all services.
...@@ -66,14 +64,14 @@ class WebIntentsRegistry ...@@ -66,14 +64,14 @@ class WebIntentsRegistry
const webkit_glue::WebIntentServiceData& service, const webkit_glue::WebIntentServiceData& service,
const base::Callback<void(bool)>& callback); const base::Callback<void(bool)>& callback);
// Requests all extension services matching |action|, |mimetype| and // Requests all extension services matching |action|, |type| and
// |extension_id|. // |extension_id|.
// |mimetype| must conform to definition as outlined for GetIntentServices. // |type| must conform to definition as outlined for GetIntentServices.
// |callback| must not be null. // |callback| must not be null.
void GetIntentServicesForExtensionFilter(const string16& action, void GetIntentServicesForExtensionFilter(const string16& action,
const string16& mimetype, const string16& type,
const std::string& extension_id, const std::string& extension_id,
const QueryCallback& callback); const QueryCallback& callback);
// Record the given default service entry. // Record the given default service entry.
virtual void RegisterDefaultIntentService( virtual void RegisterDefaultIntentService(
...@@ -88,9 +86,9 @@ class WebIntentsRegistry ...@@ -88,9 +86,9 @@ class WebIntentsRegistry
// parameters. // parameters.
// |callback| must not be null. // |callback| must not be null.
void GetDefaultIntentService(const string16& action, void GetDefaultIntentService(const string16& action,
const string16& type, const string16& type,
const GURL& invoking_url, const GURL& invoking_url,
const DefaultQueryCallback& callback); const DefaultQueryCallback& callback);
protected: protected:
// Make sure that only WebIntentsRegistryFactory can create an instance of // Make sure that only WebIntentsRegistryFactory can create an instance of
...@@ -110,30 +108,34 @@ class WebIntentsRegistry ...@@ -110,30 +108,34 @@ class WebIntentsRegistry
void CollapseIntents(IntentServiceList* services); void CollapseIntents(IntentServiceList* services);
private: private:
const extensions::Extension* ExtensionForURL(const std::string& url); struct IntentsQuery;
typedef std::vector<IntentsQuery*> QueryVector;
struct IntentsQuery; // Handles services loaded
void OnWebIntentsResultReceived(
// Maps web data requests to intents queries. IntentsQuery* query,
// Allows OnWebDataServiceRequestDone to forward to appropriate consumer. const WDTypedResult* result);
typedef base::hash_map<WebDataService::Handle, IntentsQuery*> QueryMap;
// WebDataServiceConsumer implementation.
virtual void OnWebDataServiceRequestDone(
WebDataService::Handle h,
const WDTypedResult* result) OVERRIDE;
// Delegate for defaults requests from OnWebDataServiceRequestDone. // Handles default services loaded
virtual void OnWebDataServiceDefaultsRequestDone( void OnWebIntentsDefaultsResultReceived(
WebDataService::Handle h, IntentsQuery* query,
const WDTypedResult* result); const WDTypedResult* result);
// Implementation of GetIntentServicesForExtensionFilter. // Implementation of GetIntentServicesForExtensionFilter.
void DoGetIntentServicesForExtensionFilter(scoped_ptr<IntentsQuery> query, void DoGetIntentServicesForExtensionFilter(scoped_ptr<IntentsQuery> query,
const std::string& extension_id); const std::string& extension_id);
const extensions::Extension* ExtensionForURL(const std::string& url);
// Adds a query to the list of pending queries.
void TrackQuery(IntentsQuery* query);
// Takes ownership of a query. This removes a query from the list
// of pending queries.
void ReleaseQuery(IntentsQuery* query);
// Map for all in-flight web data requests/intent queries. // Map for all in-flight web data requests/intent queries.
QueryMap queries_; QueryVector pending_queries_;
// Local reference to Web Data Service. // Local reference to Web Data Service.
scoped_refptr<WebDataService> wds_; scoped_refptr<WebDataService> wds_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment