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

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

Issue 10227014: Remove the very old code that migrated password data from the WebDataService to PasswordStore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 8 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"
(...skipping 17 matching lines...) Expand all
28 #include "chrome/browser/webdata/web_intents_table.h" 28 #include "chrome/browser/webdata/web_intents_table.h"
29 #include "chrome/common/chrome_constants.h" 29 #include "chrome/common/chrome_constants.h"
30 #include "chrome/common/chrome_notification_types.h" 30 #include "chrome/common/chrome_notification_types.h"
31 #include "content/public/browser/notification_details.h" 31 #include "content/public/browser/notification_details.h"
32 #include "content/public/browser/notification_service.h" 32 #include "content/public/browser/notification_service.h"
33 #include "content/public/browser/notification_source.h" 33 #include "content/public/browser/notification_source.h"
34 #include "grit/chromium_strings.h" 34 #include "grit/chromium_strings.h"
35 #include "grit/generated_resources.h" 35 #include "grit/generated_resources.h"
36 #include "third_party/skia/include/core/SkBitmap.h" 36 #include "third_party/skia/include/core/SkBitmap.h"
37 #include "webkit/forms/form_field.h" 37 #include "webkit/forms/form_field.h"
38 #include "webkit/forms/password_form.h"
39 38
40 //////////////////////////////////////////////////////////////////////////////// 39 ////////////////////////////////////////////////////////////////////////////////
41 // 40 //
42 // WebDataService implementation. 41 // WebDataService implementation.
43 // 42 //
44 //////////////////////////////////////////////////////////////////////////////// 43 ////////////////////////////////////////////////////////////////////////////////
45 44
46 using base::Bind; 45 using base::Bind;
47 using base::Time; 46 using base::Time;
48 using content::BrowserThread; 47 using content::BrowserThread;
49 using webkit::forms::FormField; 48 using webkit::forms::FormField;
50 using webkit::forms::PasswordForm;
51 using webkit_glue::WebIntentServiceData; 49 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
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 new GenericRequest<std::string>( 388 new GenericRequest<std::string>(
391 this, GetNextRequestHandle(), consumer, std::string()); 389 this, GetNextRequestHandle(), consumer, std::string());
392 RegisterRequest(request); 390 RegisterRequest(request);
393 ScheduleTask(FROM_HERE, 391 ScheduleTask(FROM_HERE,
394 Bind(&WebDataService::GetAllTokensImpl, this, request)); 392 Bind(&WebDataService::GetAllTokensImpl, this, request));
395 return request->GetHandle(); 393 return request->GetHandle();
396 } 394 }
397 395
398 //////////////////////////////////////////////////////////////////////////////// 396 ////////////////////////////////////////////////////////////////////////////////
399 // 397 //
400 // Password manager.
401 //
402 ////////////////////////////////////////////////////////////////////////////////
403
404 void WebDataService::AddLogin(const PasswordForm& form) {
405 GenericRequest<PasswordForm>* request =
406 new GenericRequest<PasswordForm>(this, GetNextRequestHandle(), NULL,
407 form);
408 RegisterRequest(request);
409 ScheduleTask(FROM_HERE, Bind(&WebDataService::AddLoginImpl, this, request));
410 }
411
412 void WebDataService::UpdateLogin(const PasswordForm& form) {
413 GenericRequest<PasswordForm>* request =
414 new GenericRequest<PasswordForm>(this, GetNextRequestHandle(),
415 NULL, form);
416 RegisterRequest(request);
417 ScheduleTask(FROM_HERE,
418 Bind(&WebDataService::UpdateLoginImpl, this, request));
419 }
420
421 void WebDataService::RemoveLogin(const PasswordForm& form) {
422 GenericRequest<PasswordForm>* request =
423 new GenericRequest<PasswordForm>(this, GetNextRequestHandle(), NULL,
424 form);
425 RegisterRequest(request);
426 ScheduleTask(FROM_HERE,
427 Bind(&WebDataService::RemoveLoginImpl, this, request));
428 }
429
430 void WebDataService::RemoveLoginsCreatedBetween(const Time& delete_begin,
431 const Time& delete_end) {
432 GenericRequest2<Time, Time>* request =
433 new GenericRequest2<Time, Time>(this,
434 GetNextRequestHandle(),
435 NULL,
436 delete_begin,
437 delete_end);
438 RegisterRequest(request);
439 ScheduleTask(FROM_HERE, Bind(&WebDataService::RemoveLoginsCreatedBetweenImpl,
440 this, request));
441 }
442
443 void WebDataService::RemoveLoginsCreatedAfter(const Time& delete_begin) {
444 RemoveLoginsCreatedBetween(delete_begin, Time());
445 }
446
447 WebDataService::Handle WebDataService::GetLogins(
448 const PasswordForm& form,
449 WebDataServiceConsumer* consumer) {
450 GenericRequest<PasswordForm>* request =
451 new GenericRequest<PasswordForm>(this, GetNextRequestHandle(),
452 consumer, form);
453 RegisterRequest(request);
454 ScheduleTask(FROM_HERE, Bind(&WebDataService::GetLoginsImpl, this, request));
455 return request->GetHandle();
456 }
457
458 WebDataService::Handle WebDataService::GetAutofillableLogins(
459 WebDataServiceConsumer* consumer) {
460 WebDataRequest* request =
461 new WebDataRequest(this, GetNextRequestHandle(), consumer);
462 RegisterRequest(request);
463 ScheduleTask(FROM_HERE,
464 Bind(&WebDataService::GetAutofillableLoginsImpl, this, request));
465 return request->GetHandle();
466 }
467
468 WebDataService::Handle WebDataService::GetBlacklistLogins(
469 WebDataServiceConsumer* consumer) {
470 WebDataRequest* request =
471 new WebDataRequest(this, GetNextRequestHandle(), consumer);
472 RegisterRequest(request);
473 ScheduleTask(FROM_HERE,
474 Bind(&WebDataService::GetBlacklistLoginsImpl, this, request));
475 return request->GetHandle();
476 }
477
478 ////////////////////////////////////////////////////////////////////////////////
479 //
480 // Autofill. 398 // Autofill.
481 // 399 //
482 //////////////////////////////////////////////////////////////////////////////// 400 ////////////////////////////////////////////////////////////////////////////////
483 401
484 void WebDataService::AddFormFields( 402 void WebDataService::AddFormFields(
485 const std::vector<FormField>& fields) { 403 const std::vector<FormField>& fields) {
486 GenericRequest<std::vector<FormField> >* request = 404 GenericRequest<std::vector<FormField> >* request =
487 new GenericRequest<std::vector<FormField> >( 405 new GenericRequest<std::vector<FormField> >(
488 this, GetNextRequestHandle(), NULL, fields); 406 this, GetNextRequestHandle(), NULL, fields);
489 RegisterRequest(request); 407 RegisterRequest(request);
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
1104 std::map<std::string, std::string> map; 1022 std::map<std::string, std::string> map;
1105 db_->GetTokenServiceTable()->GetAllTokens(&map); 1023 db_->GetTokenServiceTable()->GetAllTokens(&map);
1106 request->SetResult( 1024 request->SetResult(
1107 new WDResult<std::map<std::string, std::string> >(TOKEN_RESULT, map)); 1025 new WDResult<std::map<std::string, std::string> >(TOKEN_RESULT, map));
1108 } 1026 }
1109 request->RequestComplete(); 1027 request->RequestComplete();
1110 } 1028 }
1111 1029
1112 //////////////////////////////////////////////////////////////////////////////// 1030 ////////////////////////////////////////////////////////////////////////////////
1113 // 1031 //
1114 // Password manager implementation.
1115 //
1116 ////////////////////////////////////////////////////////////////////////////////
1117
1118 void WebDataService::AddLoginImpl(GenericRequest<PasswordForm>* request) {
1119 InitializeDatabaseIfNecessary();
1120 if (db_ && !request->IsCancelled(NULL)) {
1121 if (db_->GetLoginsTable()->AddLogin(request->arg()))
1122 ScheduleCommit();
1123 }
1124 request->RequestComplete();
1125 }
1126
1127 void WebDataService::UpdateLoginImpl(GenericRequest<PasswordForm>* request) {
1128 InitializeDatabaseIfNecessary();
1129 if (db_ && !request->IsCancelled(NULL)) {
1130 if (db_->GetLoginsTable()->UpdateLogin(request->arg()))
1131 ScheduleCommit();
1132 }
1133 request->RequestComplete();
1134 }
1135
1136 void WebDataService::RemoveLoginImpl(GenericRequest<PasswordForm>* request) {
1137 InitializeDatabaseIfNecessary();
1138 if (db_ && !request->IsCancelled(NULL)) {
1139 if (db_->GetLoginsTable()->RemoveLogin(request->arg()))
1140 ScheduleCommit();
1141 }
1142 request->RequestComplete();
1143 }
1144
1145 void WebDataService::RemoveLoginsCreatedBetweenImpl(
1146 GenericRequest2<Time, Time>* request) {
1147 InitializeDatabaseIfNecessary();
1148 if (db_ && !request->IsCancelled(NULL)) {
1149 if (db_->GetLoginsTable()->RemoveLoginsCreatedBetween(
1150 request->arg1(), request->arg2())) {
1151 ScheduleCommit();
1152 }
1153 }
1154 request->RequestComplete();
1155 }
1156
1157 void WebDataService::GetLoginsImpl(GenericRequest<PasswordForm>* request) {
1158 InitializeDatabaseIfNecessary();
1159 if (db_ && !request->IsCancelled(NULL)) {
1160 std::vector<PasswordForm*> forms;
1161 db_->GetLoginsTable()->GetLogins(request->arg(), &forms);
1162 request->SetResult(
1163 new WDResult<std::vector<PasswordForm*> >(PASSWORD_RESULT, forms));
1164 }
1165 request->RequestComplete();
1166 }
1167
1168 void WebDataService::GetAutofillableLoginsImpl(WebDataRequest* request) {
1169 InitializeDatabaseIfNecessary();
1170 if (db_ && !request->IsCancelled(NULL)) {
1171 std::vector<PasswordForm*> forms;
1172 db_->GetLoginsTable()->GetAllLogins(&forms, false);
1173 request->SetResult(
1174 new WDResult<std::vector<PasswordForm*> >(PASSWORD_RESULT, forms));
1175 }
1176 request->RequestComplete();
1177 }
1178
1179 void WebDataService::GetBlacklistLoginsImpl(WebDataRequest* request) {
1180 InitializeDatabaseIfNecessary();
1181 if (db_ && !request->IsCancelled(NULL)) {
1182 std::vector<PasswordForm*> all_forms;
1183 db_->GetLoginsTable()->GetAllLogins(&all_forms, true);
1184 std::vector<PasswordForm*> blacklist_forms;
1185 for (std::vector<PasswordForm*>::iterator i = all_forms.begin();
1186 i != all_forms.end(); ++i) {
1187 scoped_ptr<PasswordForm> form(*i);
1188 if (form->blacklisted_by_user) {
1189 blacklist_forms.push_back(form.release());
1190 }
1191 }
1192 all_forms.clear();
1193 request->SetResult(
1194 new WDResult<std::vector<PasswordForm*> >(PASSWORD_RESULT,
1195 blacklist_forms));
1196 }
1197 request->RequestComplete();
1198 }
1199
1200 ////////////////////////////////////////////////////////////////////////////////
1201 //
1202 // Autofill implementation. 1032 // Autofill implementation.
1203 // 1033 //
1204 //////////////////////////////////////////////////////////////////////////////// 1034 ////////////////////////////////////////////////////////////////////////////////
1205 1035
1206 void WebDataService::AddFormElementsImpl( 1036 void WebDataService::AddFormElementsImpl(
1207 GenericRequest<std::vector<FormField> >* request) { 1037 GenericRequest<std::vector<FormField> >* request) {
1208 InitializeDatabaseIfNecessary(); 1038 InitializeDatabaseIfNecessary();
1209 if (db_ && !request->IsCancelled(NULL)) { 1039 if (db_ && !request->IsCancelled(NULL)) {
1210 AutofillChangeList changes; 1040 AutofillChangeList changes;
1211 if (!db_->GetAutofillTable()->AddFormFieldValues( 1041 if (!db_->GetAutofillTable()->AddFormFieldValues(
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
1652 } 1482 }
1653 1483
1654 const WDTypedResult* WebDataService::WebDataRequest::GetResult() const { 1484 const WDTypedResult* WebDataService::WebDataRequest::GetResult() const {
1655 return result_; 1485 return result_;
1656 } 1486 }
1657 1487
1658 void WebDataService::WebDataRequest::RequestComplete() { 1488 void WebDataService::WebDataRequest::RequestComplete() {
1659 message_loop_->PostTask(FROM_HERE, Bind(&WebDataService::RequestCompleted, 1489 message_loop_->PostTask(FROM_HERE, Bind(&WebDataService::RequestCompleted,
1660 service_.get(), handle_)); 1490 service_.get(), handle_));
1661 } 1491 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698