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

Unified Diff: chrome/browser/intents/web_intents_registry.cc

Issue 8144013: Add a check to the registry before the intent infobar is shown. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix provider to service in comments. Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/intents/web_intents_registry.h ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/intents/web_intents_registry.cc
diff --git a/chrome/browser/intents/web_intents_registry.cc b/chrome/browser/intents/web_intents_registry.cc
index 648c1e1998fb68cca4ebb8bee9a668f05b5720f1..4e35219d7a48c727866020caa0d10db634bf7e7e 100644
--- a/chrome/browser/intents/web_intents_registry.cc
+++ b/chrome/browser/intents/web_intents_registry.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/intents/web_intents_registry.h"
+#include "base/callback.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/webdata/web_data_service.h"
#include "net/base/mime_util.h"
@@ -138,6 +139,53 @@ WebIntentsRegistry::QueryID WebIntentsRegistry::GetAllIntentProviders(
return query->query_id_;
}
+// Trampoline consumer for calls to IntentProviderExists. Forwards existence
+// of the provided |service| to the provided |callback|.
+class ProviderCheckConsumer : public WebIntentsRegistry::Consumer {
+ public:
+ ProviderCheckConsumer(const WebIntentServiceData& service,
+ const base::Callback<void(bool)>& callback)
+ : callback_(callback),
+ service_(service) {}
+ virtual ~ProviderCheckConsumer() {}
+
+ // Gets the list of all providers for a particular action. Check them all
+ // to see if |provider_| is already registered.
+ virtual void OnIntentsQueryDone(
+ WebIntentsRegistry::QueryID id,
+ const WebIntentsRegistry::IntentServiceList& list) OVERRIDE {
+ scoped_ptr<ProviderCheckConsumer> self_deleter(this);
+
+ for (WebIntentsRegistry::IntentServiceList::const_iterator i = list.begin();
+ i != list.end(); ++i) {
+ if (*i == service_) {
+ callback_.Run(true);
+ return;
+ }
+ }
+
+ callback_.Run(false);
+ }
+
+ private:
+ base::Callback<void(bool)> callback_;
+ WebIntentServiceData service_;
+};
+
+WebIntentsRegistry::QueryID WebIntentsRegistry::IntentProviderExists(
+ const WebIntentServiceData& provider,
+ const base::Callback<void(bool)>& callback) {
+ IntentsQuery* query = new IntentsQuery;
+ query->query_id_ = next_query_id_++;
+ query->type_ = ASCIIToUTF16("*");
+ query->consumer_ = new ProviderCheckConsumer(provider, callback);
+ query->pending_query_ = wds_->GetWebIntentServicesForURL(
+ UTF8ToUTF16(provider.service_url.spec()), this);
+ queries_[query->pending_query_] = query;
+
+ return query->query_id_;
+}
+
void WebIntentsRegistry::RegisterIntentProvider(
const WebIntentServiceData& service) {
DCHECK(wds_.get());
« no previous file with comments | « chrome/browser/intents/web_intents_registry.h ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698