diff options
author | gbillock@chromium.org <gbillock@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-09 00:14:53 +0000 |
---|---|---|
committer | gbillock@chromium.org <gbillock@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-09 00:14:53 +0000 |
commit | 0574acb8af2e1cb78cc5797a90e92a0f7bbb2e7a (patch) | |
tree | 3df60f37d223befa3e0f7753b5b994a68bd4d259 | |
parent | bf3bcfa2487db04c74e3eea5e54a6b591c7b9ae1 (diff) | |
download | chromium_src-0574acb8af2e1cb78cc5797a90e92a0f7bbb2e7a.zip chromium_src-0574acb8af2e1cb78cc5797a90e92a0f7bbb2e7a.tar.gz chromium_src-0574acb8af2e1cb78cc5797a90e92a0f7bbb2e7a.tar.bz2 |
[Web Intents] Change the webdata API to reference "Services" for
web intents services.
R=groby@chromium.org
BUG=None
TEST=None
Review URL: http://codereview.chromium.org/8501019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109140 0039d316-1c4b-4281-b951-d872f2087c98
9 files changed, 77 insertions, 68 deletions
diff --git a/chrome/browser/intents/web_intents_registry.cc b/chrome/browser/intents/web_intents_registry.cc index 7049c3d..648c1e1 100644 --- a/chrome/browser/intents/web_intents_registry.cc +++ b/chrome/browser/intents/web_intents_registry.cc @@ -117,7 +117,7 @@ WebIntentsRegistry::QueryID WebIntentsRegistry::GetIntentProviders( query->consumer_ = consumer; query->action_ = action; query->type_ = mimetype; - query->pending_query_ = wds_->GetWebIntents(action, this); + query->pending_query_ = wds_->GetWebIntentServices(action, this); queries_[query->pending_query_] = query; return query->query_id_; @@ -132,7 +132,7 @@ WebIntentsRegistry::QueryID WebIntentsRegistry::GetAllIntentProviders( query->query_id_ = next_query_id_++; query->consumer_ = consumer; query->type_ = ASCIIToUTF16("*"); - query->pending_query_ = wds_->GetAllWebIntents(this); + query->pending_query_ = wds_->GetAllWebIntentServices(this); queries_[query->pending_query_] = query; return query->query_id_; @@ -141,11 +141,11 @@ WebIntentsRegistry::QueryID WebIntentsRegistry::GetAllIntentProviders( void WebIntentsRegistry::RegisterIntentProvider( const WebIntentServiceData& service) { DCHECK(wds_.get()); - wds_->AddWebIntent(service); + wds_->AddWebIntentService(service); } void WebIntentsRegistry::UnregisterIntentProvider( const WebIntentServiceData& service) { DCHECK(wds_.get()); - wds_->RemoveWebIntent(service); + wds_->RemoveWebIntentService(service); } diff --git a/chrome/browser/ui/intents/web_intent_picker_controller_browsertest.cc b/chrome/browser/ui/intents/web_intent_picker_controller_browsertest.cc index 86b3051..b7d11cf 100644 --- a/chrome/browser/ui/intents/web_intent_picker_controller_browsertest.cc +++ b/chrome/browser/ui/intents/web_intent_picker_controller_browsertest.cc @@ -69,7 +69,7 @@ class WebIntentPickerControllerBrowserTest : public InProcessBrowserTest { service.action = action; service.type = kType; service.service_url = service_url; - web_data_service_->AddWebIntent(service); + web_data_service_->AddWebIntentService(service); } void SetPickerExpectations(int expected_service_count, diff --git a/chrome/browser/ui/intents/web_intent_picker_controller_unittest.cc b/chrome/browser/ui/intents/web_intent_picker_controller_unittest.cc index 967991c..3ea5215 100644 --- a/chrome/browser/ui/intents/web_intent_picker_controller_unittest.cc +++ b/chrome/browser/ui/intents/web_intent_picker_controller_unittest.cc @@ -160,7 +160,7 @@ class WebIntentPickerControllerTest : public TabContentsWrapperTestHarness { service.action = action; service.type = kType; service.service_url = service_url; - web_data_service_->AddWebIntent(service); + web_data_service_->AddWebIntentService(service); } void AddFaviconForURL(const GURL& url) { diff --git a/chrome/browser/webdata/web_data_service.cc b/chrome/browser/webdata/web_data_service.cc index d451fca..8549a34 100644 --- a/chrome/browser/webdata/web_data_service.cc +++ b/chrome/browser/webdata/web_data_service.cc @@ -248,39 +248,45 @@ WebDataService::Handle WebDataService::GetWebAppImages( // ////////////////////////////////////////////////////////////////////////////// -void WebDataService::AddWebIntent(const WebIntentServiceData& service) { +void WebDataService::AddWebIntentService(const WebIntentServiceData& service) { GenericRequest<WebIntentServiceData>* request = new GenericRequest<WebIntentServiceData>( this, GetNextRequestHandle(), NULL, service); RegisterRequest(request); - ScheduleTask(Bind(&WebDataService::AddWebIntentImpl, this, request)); + ScheduleTask(Bind(&WebDataService::AddWebIntentServiceImpl, this, request)); } -void WebDataService::RemoveWebIntent(const WebIntentServiceData& service) { +void WebDataService::RemoveWebIntentService( + const WebIntentServiceData& service) { GenericRequest<WebIntentServiceData>* request = new GenericRequest<WebIntentServiceData>( this, GetNextRequestHandle(), NULL, service); RegisterRequest(request); - ScheduleTask(Bind(&WebDataService::RemoveWebIntentImpl, this, request)); + ScheduleTask(Bind(&WebDataService::RemoveWebIntentServiceImpl, + this, + request)); } -WebDataService::Handle WebDataService::GetWebIntents(const string16& action, - WebDataServiceConsumer* consumer) { +WebDataService::Handle WebDataService::GetWebIntentServices( + const string16& action, + WebDataServiceConsumer* consumer) { DCHECK(consumer); GenericRequest<string16>* request = new GenericRequest<string16>( this, GetNextRequestHandle(), consumer, action); RegisterRequest(request); - ScheduleTask(Bind(&WebDataService::GetWebIntentsImpl, this, request)); + ScheduleTask(Bind(&WebDataService::GetWebIntentServicesImpl, this, request)); return request->GetHandle(); } -WebDataService::Handle WebDataService::GetAllWebIntents( +WebDataService::Handle WebDataService::GetAllWebIntentServices( WebDataServiceConsumer* consumer) { DCHECK(consumer); GenericRequest<std::string>* request = new GenericRequest<std::string>( this, GetNextRequestHandle(), consumer, std::string()); RegisterRequest(request); - ScheduleTask(Bind(&WebDataService::GetAllWebIntentsImpl, this, request)); + ScheduleTask(Bind(&WebDataService::GetAllWebIntentServicesImpl, + this, + request)); return request->GetHandle(); } @@ -849,34 +855,35 @@ void WebDataService::GetWebAppImagesImpl(GenericRequest<GURL>* request) { // //////////////////////////////////////////////////////////////////////////////// -void WebDataService::RemoveWebIntentImpl( +void WebDataService::RemoveWebIntentServiceImpl( GenericRequest<WebIntentServiceData>* request) { InitializeDatabaseIfNecessary(); if (db_ && !request->IsCancelled(NULL)) { const WebIntentServiceData& service = request->arg(); - db_->GetWebIntentsTable()->RemoveWebIntent(service); + db_->GetWebIntentsTable()->RemoveWebIntentService(service); ScheduleCommit(); } request->RequestComplete(); } -void WebDataService::AddWebIntentImpl( +void WebDataService::AddWebIntentServiceImpl( GenericRequest<WebIntentServiceData>* request) { InitializeDatabaseIfNecessary(); if (db_ && !request->IsCancelled(NULL)) { const WebIntentServiceData& service = request->arg(); - db_->GetWebIntentsTable()->SetWebIntent(service); + db_->GetWebIntentsTable()->SetWebIntentService(service); ScheduleCommit(); } request->RequestComplete(); } -void WebDataService::GetWebIntentsImpl(GenericRequest<string16>* request) { +void WebDataService::GetWebIntentServicesImpl( + GenericRequest<string16>* request) { InitializeDatabaseIfNecessary(); if (db_ && !request->IsCancelled(NULL)) { std::vector<WebIntentServiceData> result; - db_->GetWebIntentsTable()->GetWebIntents(request->arg(), &result); + db_->GetWebIntentsTable()->GetWebIntentServices(request->arg(), &result); request->SetResult( new WDResult<std::vector<WebIntentServiceData> >( WEB_INTENTS_RESULT, result)); @@ -884,12 +891,12 @@ void WebDataService::GetWebIntentsImpl(GenericRequest<string16>* request) { request->RequestComplete(); } -void WebDataService::GetAllWebIntentsImpl( +void WebDataService::GetAllWebIntentServicesImpl( GenericRequest<std::string>* request) { InitializeDatabaseIfNecessary(); if (db_ && !request->IsCancelled(NULL)) { std::vector<WebIntentServiceData> result; - db_->GetWebIntentsTable()->GetAllWebIntents(&result); + db_->GetWebIntentsTable()->GetAllWebIntentServices(&result); request->SetResult( new WDResult<std::vector<WebIntentServiceData> >( WEB_INTENTS_RESULT, result)); diff --git a/chrome/browser/webdata/web_data_service.h b/chrome/browser/webdata/web_data_service.h index e93047c..4565295 100644 --- a/chrome/browser/webdata/web_data_service.h +++ b/chrome/browser/webdata/web_data_service.h @@ -364,19 +364,19 @@ class WebDataService // ////////////////////////////////////////////////////////////////////////////// - // Adds a web intent provider registration. - void AddWebIntent(const webkit_glue::WebIntentServiceData& service); + // Adds a web intent service registration. + void AddWebIntentService(const webkit_glue::WebIntentServiceData& service); - // Removes a web intent provider registration. - void RemoveWebIntent(const webkit_glue::WebIntentServiceData& service); + // Removes a web intent service registration. + void RemoveWebIntentService(const webkit_glue::WebIntentServiceData& service); - // Get all web intent providers registered for the specified |action|. + // Get all web intent services registered for the specified |action|. // |consumer| must not be NULL. - Handle GetWebIntents(const string16& action, - WebDataServiceConsumer* consumer); + Handle GetWebIntentServices(const string16& action, + WebDataServiceConsumer* consumer); - // Get all web intent providers registered. |consumer| must not be NULL. - Handle GetAllWebIntents(WebDataServiceConsumer* consumer); + // Get all web intent services registered. |consumer| must not be NULL. + Handle GetAllWebIntentServices(WebDataServiceConsumer* consumer); ////////////////////////////////////////////////////////////////////////////// // @@ -622,12 +622,12 @@ class WebDataService // Web Intents. // ////////////////////////////////////////////////////////////////////////////// - void AddWebIntentImpl( + void AddWebIntentServiceImpl( GenericRequest<webkit_glue::WebIntentServiceData>* request); - void RemoveWebIntentImpl( + void RemoveWebIntentServiceImpl( GenericRequest<webkit_glue::WebIntentServiceData>* request); - void GetWebIntentsImpl(GenericRequest<string16>* request); - void GetAllWebIntentsImpl(GenericRequest<std::string>* request); + void GetWebIntentServicesImpl(GenericRequest<string16>* request); + void GetAllWebIntentServicesImpl(GenericRequest<std::string>* request); ////////////////////////////////////////////////////////////////////////////// // diff --git a/chrome/browser/webdata/web_data_service_unittest.cc b/chrome/browser/webdata/web_data_service_unittest.cc index 60c1b71..db70f3b 100644 --- a/chrome/browser/webdata/web_data_service_unittest.cc +++ b/chrome/browser/webdata/web_data_service_unittest.cc @@ -634,7 +634,7 @@ TEST_F(WebDataServiceAutofillTest, AutofillRemoveModifiedBetween) { TEST_F(WebDataServiceTest, WebIntents) { WebIntentsConsumer consumer; - wds_->GetWebIntents(ASCIIToUTF16("share"), &consumer); + wds_->GetWebIntentServices(ASCIIToUTF16("share"), &consumer); WebIntentsConsumer::WaitUntilCalled(); EXPECT_EQ(0U, consumer.services_.size()); @@ -642,12 +642,12 @@ TEST_F(WebDataServiceTest, WebIntents) { service.service_url = GURL("http://google.com"); service.action = ASCIIToUTF16("share"); service.type = ASCIIToUTF16("image/*"); - wds_->AddWebIntent(service); + wds_->AddWebIntentService(service); service.type = ASCIIToUTF16("video/*"); - wds_->AddWebIntent(service); + wds_->AddWebIntentService(service); - wds_->GetWebIntents(ASCIIToUTF16("share"), &consumer); + wds_->GetWebIntentServices(ASCIIToUTF16("share"), &consumer); WebIntentsConsumer::WaitUntilCalled(); ASSERT_EQ(2U, consumer.services_.size()); @@ -662,9 +662,9 @@ TEST_F(WebDataServiceTest, WebIntents) { EXPECT_EQ(service.type, consumer.services_[1].type); service.type = ASCIIToUTF16("image/*"); - wds_->RemoveWebIntent(service); + wds_->RemoveWebIntentService(service); - wds_->GetWebIntents(ASCIIToUTF16("share"), &consumer); + wds_->GetWebIntentServices(ASCIIToUTF16("share"), &consumer); WebIntentsConsumer::WaitUntilCalled(); ASSERT_EQ(1U, consumer.services_.size()); @@ -681,12 +681,12 @@ TEST_F(WebDataServiceTest, WebIntentsGetAll) { service.service_url = GURL("http://google.com"); service.action = ASCIIToUTF16("share"); service.type = ASCIIToUTF16("image/*"); - wds_->AddWebIntent(service); + wds_->AddWebIntentService(service); service.action = ASCIIToUTF16("edit"); - wds_->AddWebIntent(service); + wds_->AddWebIntentService(service); - wds_->GetAllWebIntents(&consumer); + wds_->GetAllWebIntentServices(&consumer); WebIntentsConsumer::WaitUntilCalled(); ASSERT_EQ(2U, consumer.services_.size()); diff --git a/chrome/browser/webdata/web_intents_table.cc b/chrome/browser/webdata/web_intents_table.cc index 819bc6d..2ad180b 100644 --- a/chrome/browser/webdata/web_intents_table.cc +++ b/chrome/browser/webdata/web_intents_table.cc @@ -69,7 +69,7 @@ bool WebIntentsTable::IsSyncable() { return false; } -bool WebIntentsTable::GetWebIntents( +bool WebIntentsTable::GetWebIntentServices( const string16& action, std::vector<WebIntentServiceData>* services) { DCHECK(services); @@ -83,7 +83,7 @@ bool WebIntentsTable::GetWebIntents( return ExtractIntents(&s, services); } -bool WebIntentsTable::GetAllWebIntents( +bool WebIntentsTable::GetAllWebIntentServices( std::vector<WebIntentServiceData>* services) { DCHECK(services); sql::Statement s(db_->GetUniqueStatement( @@ -94,7 +94,7 @@ bool WebIntentsTable::GetAllWebIntents( return ExtractIntents(&s, services); } -bool WebIntentsTable::SetWebIntent(const WebIntentServiceData& service) { +bool WebIntentsTable::SetWebIntentService(const WebIntentServiceData& service) { sql::Statement s(db_->GetUniqueStatement( "INSERT OR REPLACE INTO web_intents " "(service_url, type, action, title, disposition) " @@ -117,7 +117,8 @@ bool WebIntentsTable::SetWebIntent(const WebIntentServiceData& service) { // TODO(jhawkins): Investigate the need to remove rows matching only // |service.service_url|. It's unlikely the user will be given the ability to // remove at the granularity of actions or types. -bool WebIntentsTable::RemoveWebIntent(const WebIntentServiceData& service) { +bool WebIntentsTable::RemoveWebIntentService( + const WebIntentServiceData& service) { sql::Statement s(db_->GetUniqueStatement( "DELETE FROM web_intents " "WHERE service_url = ? AND action = ? AND type = ?")); diff --git a/chrome/browser/webdata/web_intents_table.h b/chrome/browser/webdata/web_intents_table.h index e455e7a..318e22d 100644 --- a/chrome/browser/webdata/web_intents_table.h +++ b/chrome/browser/webdata/web_intents_table.h @@ -40,19 +40,20 @@ class WebIntentsTable : public WebDatabaseTable { // Adds a web intent service to the WebIntents table. // If |service| already exists, replaces it. - bool SetWebIntent(const webkit_glue::WebIntentServiceData& service); + bool SetWebIntentService(const webkit_glue::WebIntentServiceData& service); // Retrieve all |services| from WebIntents table that match |action|. - bool GetWebIntents(const string16& action, - std::vector<webkit_glue::WebIntentServiceData>* services); + bool GetWebIntentServices( + const string16& action, + std::vector<webkit_glue::WebIntentServiceData>* services); // Retrieve all |services| from WebIntents table. - bool GetAllWebIntents( + bool GetAllWebIntentServices( std::vector<webkit_glue::WebIntentServiceData>* services); // Removes |service| from WebIntents table - must match all parameters // exactly. - bool RemoveWebIntent(const webkit_glue::WebIntentServiceData& service); + bool RemoveWebIntentService(const webkit_glue::WebIntentServiceData& service); private: DISALLOW_COPY_AND_ASSIGN(WebIntentsTable); diff --git a/chrome/browser/webdata/web_intents_table_unittest.cc b/chrome/browser/webdata/web_intents_table_unittest.cc index 88529eb..7a1859f 100644 --- a/chrome/browser/webdata/web_intents_table_unittest.cc +++ b/chrome/browser/webdata/web_intents_table_unittest.cc @@ -61,25 +61,25 @@ TEST_F(WebIntentsTableTest, SetGetDeleteIntent) { std::vector<WebIntentServiceData> services; // By default, no intent services exist. - EXPECT_TRUE(IntentsTable()->GetWebIntents(test_action, &services)); + EXPECT_TRUE(IntentsTable()->GetWebIntentServices(test_action, &services)); EXPECT_EQ(0U, services.size()); // Now adding one. WebIntentServiceData service = MakeIntentService(test_url, test_action, mime_image, test_title); - EXPECT_TRUE(IntentsTable()->SetWebIntent(service)); + EXPECT_TRUE(IntentsTable()->SetWebIntentService(service)); // Make sure that service can now be fetched - EXPECT_TRUE(IntentsTable()->GetWebIntents(test_action, &services)); + EXPECT_TRUE(IntentsTable()->GetWebIntentServices(test_action, &services)); ASSERT_EQ(1U, services.size()); EXPECT_EQ(service, services[0]); // Remove the service. - EXPECT_TRUE(IntentsTable()->RemoveWebIntent(service)); + EXPECT_TRUE(IntentsTable()->RemoveWebIntentService(service)); // Should now be gone. services.clear(); - EXPECT_TRUE(IntentsTable()->GetWebIntents(test_action, &services)); + EXPECT_TRUE(IntentsTable()->GetWebIntentServices(test_action, &services)); EXPECT_EQ(0U, services.size()); } @@ -89,14 +89,14 @@ TEST_F(WebIntentsTableTest, SetMultipleIntents) { WebIntentServiceData service = MakeIntentService(test_url, test_action, mime_image, test_title); - EXPECT_TRUE(IntentsTable()->SetWebIntent(service)); + EXPECT_TRUE(IntentsTable()->SetWebIntentService(service)); service.type = mime_video; service.title = test_title_2; - EXPECT_TRUE(IntentsTable()->SetWebIntent(service)); + EXPECT_TRUE(IntentsTable()->SetWebIntentService(service)); // Recover stored intent services from DB. - EXPECT_TRUE(IntentsTable()->GetWebIntents(test_action, &services)); + EXPECT_TRUE(IntentsTable()->GetWebIntentServices(test_action, &services)); ASSERT_EQ(2U, services.size()); // WebIntentsTable does not guarantee order, so ensure order here. @@ -116,14 +116,14 @@ TEST_F(WebIntentsTableTest, GetAllIntents) { WebIntentServiceData service = MakeIntentService(test_url, test_action, mime_image, test_title); - EXPECT_TRUE(IntentsTable()->SetWebIntent(service)); + EXPECT_TRUE(IntentsTable()->SetWebIntentService(service)); service.action = test_action_2; service.title = test_title_2; - EXPECT_TRUE(IntentsTable()->SetWebIntent(service)); + EXPECT_TRUE(IntentsTable()->SetWebIntentService(service)); // Recover stored services from DB. - EXPECT_TRUE(IntentsTable()->GetAllWebIntents(&services)); + EXPECT_TRUE(IntentsTable()->GetAllWebIntentServices(&services)); ASSERT_EQ(2U, services.size()); // WebIntentsTable does not guarantee order, so ensure order here. @@ -141,14 +141,14 @@ TEST_F(WebIntentsTableTest, DispositionToStringMapping) { WebIntentServiceData service = MakeIntentService(test_url, test_action, mime_image, test_title); service.disposition = WebIntentServiceData::DISPOSITION_WINDOW; - EXPECT_TRUE(IntentsTable()->SetWebIntent(service)); + EXPECT_TRUE(IntentsTable()->SetWebIntentService(service)); service = MakeIntentService(test_url, test_action, mime_video, test_title); service.disposition = WebIntentServiceData::DISPOSITION_INLINE; - EXPECT_TRUE(IntentsTable()->SetWebIntent(service)); + EXPECT_TRUE(IntentsTable()->SetWebIntentService(service)); std::vector<WebIntentServiceData> services; - EXPECT_TRUE(IntentsTable()->GetAllWebIntents(&services)); + EXPECT_TRUE(IntentsTable()->GetAllWebIntentServices(&services)); ASSERT_EQ(2U, services.size()); if (services[0].disposition == WebIntentServiceData::DISPOSITION_WINDOW) |