summaryrefslogtreecommitdiffstats
path: root/chrome/browser/intents
diff options
context:
space:
mode:
authorgroby@chromium.org <groby@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-13 03:48:42 +0000
committergroby@chromium.org <groby@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-13 03:48:42 +0000
commita3340f3d323f769460a1b269eb8198faf071e2a2 (patch)
tree8609985fe10a87e25ec2f0e004255dee97a65bfa /chrome/browser/intents
parentd6d70a49322b7848322d715068e29fa722e8fcd5 (diff)
downloadchromium_src-a3340f3d323f769460a1b269eb8198faf071e2a2.zip
chromium_src-a3340f3d323f769460a1b269eb8198faf071e2a2.tar.gz
chromium_src-a3340f3d323f769460a1b269eb8198faf071e2a2.tar.bz2
Added WebIntents GetAll support
R=jhawkins@chromium.org BUG=none TEST=WebIntentsTableTest.GetAllIntents,WebDataServiceTest.WebIntents.GetAll,WebIntentsRegistryTest.GetAllIntents, Review URL: http://codereview.chromium.org/7633011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96673 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/intents')
-rw-r--r--chrome/browser/intents/web_intents_registry.cc14
-rw-r--r--chrome/browser/intents/web_intents_registry.h3
-rw-r--r--chrome/browser/intents/web_intents_registry_unittest.cc26
3 files changed, 43 insertions, 0 deletions
diff --git a/chrome/browser/intents/web_intents_registry.cc b/chrome/browser/intents/web_intents_registry.cc
index fb51579..0e59ebf 100644
--- a/chrome/browser/intents/web_intents_registry.cc
+++ b/chrome/browser/intents/web_intents_registry.cc
@@ -70,6 +70,20 @@ WebIntentsRegistry::QueryID WebIntentsRegistry::GetIntentProviders(
return query->query_id_;
}
+WebIntentsRegistry::QueryID WebIntentsRegistry::GetAllIntentProviders(
+ Consumer* consumer) {
+ DCHECK(consumer);
+ DCHECK(wds_.get());
+
+ IntentsQuery* query = new IntentsQuery;
+ query->query_id_ = next_query_id_++;
+ query->consumer_ = consumer;
+ query->pending_query_ = wds_->GetAllWebIntents(this);
+ queries_[query->pending_query_] = query;
+
+ return query->query_id_;
+}
+
void WebIntentsRegistry::RegisterIntentProvider(const WebIntentData& intent) {
DCHECK(wds_.get());
wds_->AddWebIntent(intent);
diff --git a/chrome/browser/intents/web_intents_registry.h b/chrome/browser/intents/web_intents_registry.h
index 02ab4fd..f5d724a 100644
--- a/chrome/browser/intents/web_intents_registry.h
+++ b/chrome/browser/intents/web_intents_registry.h
@@ -47,6 +47,9 @@ class WebIntentsRegistry
// |consumer| must not be NULL.
QueryID GetIntentProviders(const string16& action, Consumer* consumer);
+ // Requests all intent providers. |consumer| must not be NULL
+ QueryID GetAllIntentProviders(Consumer* consumer);
+
protected:
// Make sure that only WebIntentsRegistryFactory can create an instance of
// WebIntentsRegistry.
diff --git a/chrome/browser/intents/web_intents_registry_unittest.cc b/chrome/browser/intents/web_intents_registry_unittest.cc
index 5a5e6f6..72460f7 100644
--- a/chrome/browser/intents/web_intents_registry_unittest.cc
+++ b/chrome/browser/intents/web_intents_registry_unittest.cc
@@ -102,3 +102,29 @@ TEST_F(WebIntentsRegistryTest, BasicTests) {
consumer.WaitForData();
EXPECT_EQ(1U, consumer.intents_.size());
}
+
+TEST_F(WebIntentsRegistryTest, GetAllIntents) {
+ WebIntentData intent;
+ intent.service_url = GURL("http://google.com");
+ intent.action = ASCIIToUTF16("share");
+ intent.type = ASCIIToUTF16("image/*");
+ intent.title = ASCIIToUTF16("Google's Sharing Service");
+ registry_.RegisterIntentProvider(intent);
+
+ intent.action = ASCIIToUTF16("search");
+ registry_.RegisterIntentProvider(intent);
+
+ TestConsumer consumer;
+ consumer.expected_id_ = registry_.GetAllIntentProviders(&consumer);
+ consumer.WaitForData();
+ ASSERT_EQ(2U, consumer.intents_.size());
+
+ if (consumer.intents_[0].action != ASCIIToUTF16("share"))
+ std::swap(consumer.intents_[0],consumer.intents_[1]);
+
+ intent.action = ASCIIToUTF16("share");
+ EXPECT_EQ(intent, consumer.intents_[0]);
+
+ intent.action = ASCIIToUTF16("search");
+ EXPECT_EQ(intent, consumer.intents_[1]);
+}