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

Side by Side Diff: chrome/browser/webdata/web_data_service.cc

Issue 12225076: Delete most web intents code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 10 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "chrome/browser/autofill/autofill_country.h" 11 #include "chrome/browser/autofill/autofill_country.h"
12 #include "chrome/browser/autofill/autofill_profile.h" 12 #include "chrome/browser/autofill/autofill_profile.h"
13 #include "chrome/browser/autofill/credit_card.h" 13 #include "chrome/browser/autofill/credit_card.h"
14 #include "chrome/browser/intents/default_web_intent_service.h"
15 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/search_engines/template_url.h" 15 #include "chrome/browser/search_engines/template_url.h"
17 #include "chrome/browser/ui/profile_error_dialog.h" 16 #include "chrome/browser/ui/profile_error_dialog.h"
18 #include "chrome/browser/webdata/autocomplete_syncable_service.h" 17 #include "chrome/browser/webdata/autocomplete_syncable_service.h"
19 #include "chrome/browser/webdata/autofill_change.h" 18 #include "chrome/browser/webdata/autofill_change.h"
20 #include "chrome/browser/webdata/autofill_entry.h" 19 #include "chrome/browser/webdata/autofill_entry.h"
21 #include "chrome/browser/webdata/autofill_profile_syncable_service.h" 20 #include "chrome/browser/webdata/autofill_profile_syncable_service.h"
22 #include "chrome/browser/webdata/autofill_table.h" 21 #include "chrome/browser/webdata/autofill_table.h"
23 #include "chrome/browser/webdata/keyword_table.h" 22 #include "chrome/browser/webdata/keyword_table.h"
24 #include "chrome/browser/webdata/logins_table.h" 23 #include "chrome/browser/webdata/logins_table.h"
(...skipping 16 matching lines...) Expand all
41 40
42 //////////////////////////////////////////////////////////////////////////////// 41 ////////////////////////////////////////////////////////////////////////////////
43 // 42 //
44 // WebDataService implementation. 43 // WebDataService implementation.
45 // 44 //
46 //////////////////////////////////////////////////////////////////////////////// 45 ////////////////////////////////////////////////////////////////////////////////
47 46
48 using base::Bind; 47 using base::Bind;
49 using base::Time; 48 using base::Time;
50 using content::BrowserThread; 49 using content::BrowserThread;
51 using webkit_glue::WebIntentServiceData;
52 50
53 namespace { 51 namespace {
54 52
55 // A task used by WebDataService (for Sync mainly) to inform the 53 // A task used by WebDataService (for Sync mainly) to inform the
56 // PersonalDataManager living on the UI thread that it needs to refresh. 54 // PersonalDataManager living on the UI thread that it needs to refresh.
57 void NotifyOfMultipleAutofillChangesTask( 55 void NotifyOfMultipleAutofillChangesTask(
58 const scoped_refptr<WebDataService>& web_data_service) { 56 const scoped_refptr<WebDataService>& web_data_service) {
59 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
60 58
61 content::NotificationService::current()->Notify( 59 content::NotificationService::current()->Notify(
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 Bind(&WebDataService::RemoveWebAppImpl, this, app_url)); 204 Bind(&WebDataService::RemoveWebAppImpl, this, app_url));
207 } 205 }
208 206
209 WebDataService::Handle WebDataService::GetWebAppImages( 207 WebDataService::Handle WebDataService::GetWebAppImages(
210 const GURL& app_url, 208 const GURL& app_url,
211 WebDataServiceConsumer* consumer) { 209 WebDataServiceConsumer* consumer) {
212 return ScheduleDBTaskWithResult(FROM_HERE, 210 return ScheduleDBTaskWithResult(FROM_HERE,
213 Bind(&WebDataService::GetWebAppImagesImpl, this, app_url), consumer); 211 Bind(&WebDataService::GetWebAppImagesImpl, this, app_url), consumer);
214 } 212 }
215 213
216 #if (ENABLE_WEB_INTENTS)
217 //////////////////////////////////////////////////////////////////////////////
218 //
219 // Web Intents.
220 //
221 //////////////////////////////////////////////////////////////////////////////
222
223 void WebDataService::AddWebIntentService(const WebIntentServiceData& service) {
224 ScheduleDBTask(FROM_HERE,
225 Bind(&WebDataService::AddWebIntentServiceImpl, this, service));
226 }
227
228 void WebDataService::RemoveWebIntentService(
229 const WebIntentServiceData& service) {
230 ScheduleDBTask(FROM_HERE, Bind(&WebDataService::RemoveWebIntentServiceImpl,
231 this, service));
232 }
233
234 WebDataService::Handle WebDataService::GetWebIntentServicesForAction(
235 const string16& action,
236 WebDataServiceConsumer* consumer) {
237 return ScheduleDBTaskWithResult(FROM_HERE,
238 Bind(&WebDataService::GetWebIntentServicesImpl, this, action), consumer);
239 }
240
241 WebDataService::Handle WebDataService::GetWebIntentServicesForURL(
242 const string16& service_url,
243 WebDataServiceConsumer* consumer) {
244 return ScheduleDBTaskWithResult(FROM_HERE,
245 Bind(&WebDataService::GetWebIntentServicesForURLImpl, this, service_url),
246 consumer);
247 }
248
249
250 WebDataService::Handle WebDataService::GetAllWebIntentServices(
251 WebDataServiceConsumer* consumer) {
252 return ScheduleDBTaskWithResult(FROM_HERE,
253 Bind(&WebDataService::GetAllWebIntentServicesImpl, this), consumer);
254 }
255
256 void WebDataService::AddDefaultWebIntentService(
257 const DefaultWebIntentService& service) {
258 ScheduleDBTask(FROM_HERE,
259 Bind(&WebDataService::AddDefaultWebIntentServiceImpl, this, service));
260 }
261
262 void WebDataService::RemoveDefaultWebIntentService(
263 const DefaultWebIntentService& service) {
264 ScheduleDBTask(FROM_HERE,
265 Bind(&WebDataService::RemoveDefaultWebIntentServiceImpl, this, service));
266 }
267
268 void WebDataService::RemoveWebIntentServiceDefaults(
269 const GURL& service_url) {
270 ScheduleDBTask(FROM_HERE,
271 Bind(&WebDataService::RemoveWebIntentServiceDefaultsImpl, this,
272 service_url));
273 }
274
275 WebDataService::Handle WebDataService::GetDefaultWebIntentServicesForAction(
276 const string16& action,
277 WebDataServiceConsumer* consumer) {
278 return ScheduleDBTaskWithResult(FROM_HERE,
279 Bind(&WebDataService::GetDefaultWebIntentServicesForActionImpl, this,
280 action),
281 consumer);
282 }
283
284 WebDataService::Handle WebDataService::GetAllDefaultWebIntentServices(
285 WebDataServiceConsumer* consumer) {
286 return ScheduleDBTaskWithResult(FROM_HERE,
287 Bind(&WebDataService::GetAllDefaultWebIntentServicesImpl, this),
288 consumer);
289 }
290 #endif
291
292 //////////////////////////////////////////////////////////////////////////////// 214 ////////////////////////////////////////////////////////////////////////////////
293 // 215 //
294 // Token Service 216 // Token Service
295 // 217 //
296 //////////////////////////////////////////////////////////////////////////////// 218 ////////////////////////////////////////////////////////////////////////////////
297 219
298 void WebDataService::SetTokenForService(const std::string& service, 220 void WebDataService::SetTokenForService(const std::string& service,
299 const std::string& token) { 221 const std::string& token) {
300 ScheduleDBTask(FROM_HERE, 222 ScheduleDBTask(FROM_HERE,
301 Bind(&WebDataService::SetTokenForServiceImpl, this, service, token)); 223 Bind(&WebDataService::SetTokenForServiceImpl, this, service, token));
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 scoped_ptr<WDTypedResult> WebDataService::GetWebAppImagesImpl( 579 scoped_ptr<WDTypedResult> WebDataService::GetWebAppImagesImpl(
658 const GURL& app_url) { 580 const GURL& app_url) {
659 WDAppImagesResult result; 581 WDAppImagesResult result;
660 result.has_all_images = 582 result.has_all_images =
661 db_->GetWebAppsTable()->GetWebAppHasAllImages(app_url); 583 db_->GetWebAppsTable()->GetWebAppHasAllImages(app_url);
662 db_->GetWebAppsTable()->GetWebAppImages(app_url, &result.images); 584 db_->GetWebAppsTable()->GetWebAppImages(app_url, &result.images);
663 return scoped_ptr<WDTypedResult>( 585 return scoped_ptr<WDTypedResult>(
664 new WDResult<WDAppImagesResult>(WEB_APP_IMAGES, result)); 586 new WDResult<WDAppImagesResult>(WEB_APP_IMAGES, result));
665 } 587 }
666 588
667 #if defined(ENABLE_WEB_INTENTS)
668 ////////////////////////////////////////////////////////////////////////////////
669 //
670 // Web Intents implementation.
671 //
672 ////////////////////////////////////////////////////////////////////////////////
673
674 void WebDataService::RemoveWebIntentServiceImpl(
675 const webkit_glue::WebIntentServiceData& service) {
676 db_->GetWebIntentsTable()->RemoveWebIntentService(service);
677 ScheduleCommit();
678 }
679
680 void WebDataService::AddWebIntentServiceImpl(
681 const webkit_glue::WebIntentServiceData& service) {
682 db_->GetWebIntentsTable()->SetWebIntentService(service);
683 ScheduleCommit();
684 }
685
686
687 scoped_ptr<WDTypedResult> WebDataService::GetWebIntentServicesImpl(
688 const string16& action) {
689 std::vector<WebIntentServiceData> result;
690 db_->GetWebIntentsTable()->GetWebIntentServicesForAction(action, &result);
691 return scoped_ptr<WDTypedResult>(
692 new WDResult<std::vector<WebIntentServiceData> >(
693 WEB_INTENTS_RESULT, result));
694 }
695
696 scoped_ptr<WDTypedResult> WebDataService::GetWebIntentServicesForURLImpl(
697 const string16& service_url) {
698 std::vector<WebIntentServiceData> result;
699 db_->GetWebIntentsTable()->GetWebIntentServicesForURL(service_url, &result);
700 return scoped_ptr<WDTypedResult>(
701 new WDResult<std::vector<WebIntentServiceData> >(
702 WEB_INTENTS_RESULT, result));
703 }
704
705 scoped_ptr<WDTypedResult> WebDataService::GetAllWebIntentServicesImpl() {
706 std::vector<WebIntentServiceData> result;
707 db_->GetWebIntentsTable()->GetAllWebIntentServices(&result);
708 return scoped_ptr<WDTypedResult>(
709 new WDResult<std::vector<WebIntentServiceData> >(
710 WEB_INTENTS_RESULT, result));
711 }
712
713 void WebDataService::AddDefaultWebIntentServiceImpl(
714 const DefaultWebIntentService& service) {
715 db_->GetWebIntentsTable()->SetDefaultService(service);
716 ScheduleCommit();
717 }
718
719 void WebDataService::RemoveDefaultWebIntentServiceImpl(
720 const DefaultWebIntentService& service) {
721 db_->GetWebIntentsTable()->RemoveDefaultService(service);
722 ScheduleCommit();
723 }
724
725 void WebDataService::RemoveWebIntentServiceDefaultsImpl(
726 const GURL& service_url) {
727 db_->GetWebIntentsTable()->RemoveServiceDefaults(service_url);
728 ScheduleCommit();
729 }
730
731 scoped_ptr<WDTypedResult>
732 WebDataService::GetDefaultWebIntentServicesForActionImpl(
733 const string16& action) {
734 std::vector<DefaultWebIntentService> result;
735 db_->GetWebIntentsTable()->GetDefaultServices(action, &result);
736 return scoped_ptr<WDTypedResult>(
737 new WDResult<std::vector<DefaultWebIntentService> >(
738 WEB_INTENTS_DEFAULTS_RESULT, result));
739 }
740
741 scoped_ptr<WDTypedResult> WebDataService::GetAllDefaultWebIntentServicesImpl() {
742 std::vector<DefaultWebIntentService> result;
743 db_->GetWebIntentsTable()->GetAllDefaultServices(&result);
744 return scoped_ptr<WDTypedResult>(
745 new WDResult<std::vector<DefaultWebIntentService> >(
746 WEB_INTENTS_DEFAULTS_RESULT, result));
747 }
748 #endif
749
750 //////////////////////////////////////////////////////////////////////////////// 589 ////////////////////////////////////////////////////////////////////////////////
751 // 590 //
752 // Token Service implementation. 591 // Token Service implementation.
753 // 592 //
754 //////////////////////////////////////////////////////////////////////////////// 593 ////////////////////////////////////////////////////////////////////////////////
755 594
756 void WebDataService::RemoveAllTokensImpl() { 595 void WebDataService::RemoveAllTokensImpl() {
757 if (db_->GetTokenServiceTable()->RemoveAllTokens()) { 596 if (db_->GetTokenServiceTable()->RemoveAllTokens()) {
758 ScheduleCommit(); 597 ScheduleCommit();
759 } 598 }
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 946
1108 void WebDataService::DestroyAutofillCreditCardResult( 947 void WebDataService::DestroyAutofillCreditCardResult(
1109 const WDTypedResult* result) { 948 const WDTypedResult* result) {
1110 DCHECK(result->GetType() == AUTOFILL_CREDITCARDS_RESULT); 949 DCHECK(result->GetType() == AUTOFILL_CREDITCARDS_RESULT);
1111 const WDResult<std::vector<CreditCard*> >* r = 950 const WDResult<std::vector<CreditCard*> >* r =
1112 static_cast<const WDResult<std::vector<CreditCard*> >*>(result); 951 static_cast<const WDResult<std::vector<CreditCard*> >*>(result);
1113 952
1114 std::vector<CreditCard*> credit_cards = r->GetValue(); 953 std::vector<CreditCard*> credit_cards = r->GetValue();
1115 STLDeleteElements(&credit_cards); 954 STLDeleteElements(&credit_cards);
1116 } 955 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/content_settings_handler.cc ('k') | chrome/browser/webdata/web_database.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698