OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/webdata/web_data_service.h" | 5 #include "chrome/browser/webdata/web_data_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 const DefaultWebIntentService& service) { | 327 const DefaultWebIntentService& service) { |
328 GenericRequest<DefaultWebIntentService>* request = | 328 GenericRequest<DefaultWebIntentService>* request = |
329 new GenericRequest<DefaultWebIntentService>( | 329 new GenericRequest<DefaultWebIntentService>( |
330 this, GetNextRequestHandle(), NULL, service); | 330 this, GetNextRequestHandle(), NULL, service); |
331 RegisterRequest(request); | 331 RegisterRequest(request); |
332 ScheduleTask(FROM_HERE, | 332 ScheduleTask(FROM_HERE, |
333 Bind(&WebDataService::RemoveDefaultWebIntentServiceImpl, this, | 333 Bind(&WebDataService::RemoveDefaultWebIntentServiceImpl, this, |
334 request)); | 334 request)); |
335 } | 335 } |
336 | 336 |
| 337 void WebDataService::RemoveWebIntentServiceDefaults( |
| 338 const GURL& service_url) { |
| 339 GenericRequest<GURL>* request = |
| 340 new GenericRequest<GURL>( |
| 341 this, GetNextRequestHandle(), NULL, service_url); |
| 342 RegisterRequest(request); |
| 343 ScheduleTask( |
| 344 FROM_HERE, |
| 345 Bind(&WebDataService::RemoveWebIntentServiceDefaultsImpl, this, request)); |
| 346 } |
| 347 |
337 WebDataService::Handle WebDataService::GetDefaultWebIntentServicesForAction( | 348 WebDataService::Handle WebDataService::GetDefaultWebIntentServicesForAction( |
338 const string16& action, | 349 const string16& action, |
339 WebDataServiceConsumer* consumer) { | 350 WebDataServiceConsumer* consumer) { |
340 DCHECK(consumer); | 351 DCHECK(consumer); |
341 GenericRequest<string16>* request = new GenericRequest<string16>( | 352 GenericRequest<string16>* request = new GenericRequest<string16>( |
342 this, GetNextRequestHandle(), consumer, action); | 353 this, GetNextRequestHandle(), consumer, action); |
343 RegisterRequest(request); | 354 RegisterRequest(request); |
344 ScheduleTask(FROM_HERE, | 355 ScheduleTask(FROM_HERE, |
345 Bind(&WebDataService::GetDefaultWebIntentServicesForActionImpl, | 356 Bind(&WebDataService::GetDefaultWebIntentServicesForActionImpl, |
346 this, request)); | 357 this, request)); |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 GenericRequest<DefaultWebIntentService>* request) { | 969 GenericRequest<DefaultWebIntentService>* request) { |
959 InitializeDatabaseIfNecessary(); | 970 InitializeDatabaseIfNecessary(); |
960 if (db_ && !request->IsCancelled(NULL)) { | 971 if (db_ && !request->IsCancelled(NULL)) { |
961 const DefaultWebIntentService& service = request->arg(); | 972 const DefaultWebIntentService& service = request->arg(); |
962 db_->GetWebIntentsTable()->RemoveDefaultService(service); | 973 db_->GetWebIntentsTable()->RemoveDefaultService(service); |
963 ScheduleCommit(); | 974 ScheduleCommit(); |
964 } | 975 } |
965 request->RequestComplete(); | 976 request->RequestComplete(); |
966 } | 977 } |
967 | 978 |
| 979 void WebDataService::RemoveWebIntentServiceDefaultsImpl( |
| 980 GenericRequest<GURL>* request) { |
| 981 InitializeDatabaseIfNecessary(); |
| 982 if (db_ && !request->IsCancelled(NULL)) { |
| 983 const GURL& service_url = request->arg(); |
| 984 db_->GetWebIntentsTable()->RemoveServiceDefaults(service_url); |
| 985 ScheduleCommit(); |
| 986 } |
| 987 request->RequestComplete(); |
| 988 } |
| 989 |
968 void WebDataService::GetDefaultWebIntentServicesForActionImpl( | 990 void WebDataService::GetDefaultWebIntentServicesForActionImpl( |
969 GenericRequest<string16>* request) { | 991 GenericRequest<string16>* request) { |
970 InitializeDatabaseIfNecessary(); | 992 InitializeDatabaseIfNecessary(); |
971 if (db_ && !request->IsCancelled(NULL)) { | 993 if (db_ && !request->IsCancelled(NULL)) { |
972 std::vector<DefaultWebIntentService> result; | 994 std::vector<DefaultWebIntentService> result; |
973 db_->GetWebIntentsTable()->GetDefaultServices( | 995 db_->GetWebIntentsTable()->GetDefaultServices( |
974 request->arg(), &result); | 996 request->arg(), &result); |
975 request->SetResult( | 997 request->SetResult( |
976 new WDResult<std::vector<DefaultWebIntentService> >( | 998 new WDResult<std::vector<DefaultWebIntentService> >( |
977 WEB_INTENTS_DEFAULTS_RESULT, result)); | 999 WEB_INTENTS_DEFAULTS_RESULT, result)); |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1490 } | 1512 } |
1491 | 1513 |
1492 const WDTypedResult* WebDataService::WebDataRequest::GetResult() const { | 1514 const WDTypedResult* WebDataService::WebDataRequest::GetResult() const { |
1493 return result_; | 1515 return result_; |
1494 } | 1516 } |
1495 | 1517 |
1496 void WebDataService::WebDataRequest::RequestComplete() { | 1518 void WebDataService::WebDataRequest::RequestComplete() { |
1497 message_loop_->PostTask(FROM_HERE, Bind(&WebDataService::RequestCompleted, | 1519 message_loop_->PostTask(FROM_HERE, Bind(&WebDataService::RequestCompleted, |
1498 service_.get(), handle_)); | 1520 service_.get(), handle_)); |
1499 } | 1521 } |
OLD | NEW |