OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_profile.h" | 11 #include "chrome/browser/autofill/autofill_profile.h" |
12 #include "chrome/browser/autofill/credit_card.h" | 12 #include "chrome/browser/autofill/credit_card.h" |
13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/search_engines/template_url.h" | 14 #include "chrome/browser/search_engines/template_url.h" |
15 #include "chrome/browser/ui/profile_error_dialog.h" | 15 #include "chrome/browser/ui/profile_error_dialog.h" |
16 #include "chrome/browser/webdata/autofill_change.h" | 16 #include "chrome/browser/webdata/autofill_change.h" |
17 #include "chrome/browser/webdata/autofill_entry.h" | 17 #include "chrome/browser/webdata/autofill_entry.h" |
18 #include "chrome/browser/webdata/autofill_profile_syncable_service.h" | 18 #include "chrome/browser/webdata/autofill_profile_syncable_service.h" |
19 #include "chrome/browser/webdata/autofill_table.h" | 19 #include "chrome/browser/webdata/autofill_table.h" |
20 #include "chrome/browser/webdata/keyword_table.h" | 20 #include "chrome/browser/webdata/keyword_table.h" |
21 #include "chrome/browser/webdata/logins_table.h" | 21 #include "chrome/browser/webdata/logins_table.h" |
22 #include "chrome/browser/webdata/token_service_table.h" | 22 #include "chrome/browser/webdata/token_service_table.h" |
23 #include "chrome/browser/webdata/web_apps_table.h" | 23 #include "chrome/browser/webdata/web_apps_table.h" |
24 #include "chrome/browser/webdata/web_intents_table.h" | 24 #include "chrome/browser/webdata/web_intents_table.h" |
25 #include "chrome/browser/webdata/web_database.h" | 25 #include "chrome/browser/webdata/web_database.h" |
26 #include "chrome/common/chrome_constants.h" | 26 #include "chrome/common/chrome_constants.h" |
27 #include "chrome/common/chrome_notification_types.h" | 27 #include "chrome/common/chrome_notification_types.h" |
28 #include "content/common/notification_service.h" | 28 #include "content/public/browser/notification_service.h" |
29 #include "content/public/browser/notification_details.h" | 29 #include "content/public/browser/notification_details.h" |
30 #include "content/public/browser/notification_source.h" | 30 #include "content/public/browser/notification_source.h" |
31 #include "grit/chromium_strings.h" | 31 #include "grit/chromium_strings.h" |
32 #include "grit/generated_resources.h" | 32 #include "grit/generated_resources.h" |
33 #include "third_party/skia/include/core/SkBitmap.h" | 33 #include "third_party/skia/include/core/SkBitmap.h" |
34 #include "webkit/glue/form_field.h" | 34 #include "webkit/glue/form_field.h" |
35 #include "webkit/glue/password_form.h" | 35 #include "webkit/glue/password_form.h" |
36 | 36 |
37 //////////////////////////////////////////////////////////////////////////////// | 37 //////////////////////////////////////////////////////////////////////////////// |
38 // | 38 // |
39 // WebDataService implementation. | 39 // WebDataService implementation. |
40 // | 40 // |
41 //////////////////////////////////////////////////////////////////////////////// | 41 //////////////////////////////////////////////////////////////////////////////// |
42 | 42 |
43 using base::Bind; | 43 using base::Bind; |
44 using base::Time; | 44 using base::Time; |
45 using webkit_glue::FormField; | 45 using webkit_glue::FormField; |
46 using webkit_glue::PasswordForm; | 46 using webkit_glue::PasswordForm; |
47 | 47 |
48 namespace { | 48 namespace { |
49 | 49 |
50 // A task used by WebDataService (for Sync mainly) to inform the | 50 // A task used by WebDataService (for Sync mainly) to inform the |
51 // PersonalDataManager living on the UI thread that it needs to refresh. | 51 // PersonalDataManager living on the UI thread that it needs to refresh. |
52 void NotifyOfMultipleAutofillChangesTask( | 52 void NotifyOfMultipleAutofillChangesTask( |
53 const scoped_refptr<WebDataService>& web_data_service) { | 53 const scoped_refptr<WebDataService>& web_data_service) { |
54 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 54 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
55 | 55 |
56 NotificationService::current()->Notify( | 56 content::NotificationService::current()->Notify( |
57 chrome::NOTIFICATION_AUTOFILL_MULTIPLE_CHANGED, | 57 chrome::NOTIFICATION_AUTOFILL_MULTIPLE_CHANGED, |
58 content::Source<WebDataService>(web_data_service.get()), | 58 content::Source<WebDataService>(web_data_service.get()), |
59 NotificationService::NoDetails()); | 59 content::NotificationService::NoDetails()); |
60 } | 60 } |
61 | 61 |
62 } // namespace | 62 } // namespace |
63 | 63 |
64 WDAppImagesResult::WDAppImagesResult() : has_all_images(false) {} | 64 WDAppImagesResult::WDAppImagesResult() : has_all_images(false) {} |
65 | 65 |
66 WDAppImagesResult::~WDAppImagesResult() {} | 66 WDAppImagesResult::~WDAppImagesResult() {} |
67 | 67 |
68 WDKeywordsResult::WDKeywordsResult() | 68 WDKeywordsResult::WDKeywordsResult() |
69 : default_search_provider_id(0), | 69 : default_search_provider_id(0), |
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 | 634 |
635 void WebDataService::InitializeSyncableServices() { | 635 void WebDataService::InitializeSyncableServices() { |
636 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 636 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
637 DCHECK(!autofill_profile_syncable_service_); | 637 DCHECK(!autofill_profile_syncable_service_); |
638 | 638 |
639 autofill_profile_syncable_service_ = new AutofillProfileSyncableService(this); | 639 autofill_profile_syncable_service_ = new AutofillProfileSyncableService(this); |
640 } | 640 } |
641 | 641 |
642 void WebDataService::NotifyDatabaseLoadedOnUIThread() { | 642 void WebDataService::NotifyDatabaseLoadedOnUIThread() { |
643 // Notify that the database has been initialized. | 643 // Notify that the database has been initialized. |
644 NotificationService::current()->Notify( | 644 content::NotificationService::current()->Notify( |
645 chrome::NOTIFICATION_WEB_DATABASE_LOADED, | 645 chrome::NOTIFICATION_WEB_DATABASE_LOADED, |
646 content::Source<WebDataService>(this), | 646 content::Source<WebDataService>(this), |
647 NotificationService::NoDetails()); | 647 content::NotificationService::NoDetails()); |
648 } | 648 } |
649 | 649 |
650 void WebDataService::ShutdownDatabase() { | 650 void WebDataService::ShutdownDatabase() { |
651 should_commit_ = false; | 651 should_commit_ = false; |
652 | 652 |
653 if (db_) { | 653 if (db_) { |
654 db_->CommitTransaction(); | 654 db_->CommitTransaction(); |
655 delete db_; | 655 delete db_; |
656 db_ = NULL; | 656 db_ = NULL; |
657 } | 657 } |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1024 NOTREACHED(); | 1024 NOTREACHED(); |
1025 return; | 1025 return; |
1026 } | 1026 } |
1027 request->SetResult( | 1027 request->SetResult( |
1028 new WDResult<AutofillChangeList>(AUTOFILL_CHANGES, changes)); | 1028 new WDResult<AutofillChangeList>(AUTOFILL_CHANGES, changes)); |
1029 ScheduleCommit(); | 1029 ScheduleCommit(); |
1030 | 1030 |
1031 // Post the notifications including the list of affected keys. | 1031 // Post the notifications including the list of affected keys. |
1032 // This is sent here so that work resulting from this notification will be | 1032 // This is sent here so that work resulting from this notification will be |
1033 // done on the DB thread, and not the UI thread. | 1033 // done on the DB thread, and not the UI thread. |
1034 NotificationService::current()->Notify( | 1034 content::NotificationService::current()->Notify( |
1035 chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, | 1035 chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, |
1036 content::Source<WebDataService>(this), | 1036 content::Source<WebDataService>(this), |
1037 content::Details<AutofillChangeList>(&changes)); | 1037 content::Details<AutofillChangeList>(&changes)); |
1038 } | 1038 } |
1039 | 1039 |
1040 request->RequestComplete(); | 1040 request->RequestComplete(); |
1041 } | 1041 } |
1042 | 1042 |
1043 void WebDataService::GetFormValuesForElementNameImpl(WebDataRequest* request, | 1043 void WebDataService::GetFormValuesForElementNameImpl(WebDataRequest* request, |
1044 const string16& name, const string16& prefix, int limit) { | 1044 const string16& name, const string16& prefix, int limit) { |
(...skipping 15 matching lines...) Expand all Loading... |
1060 AutofillChangeList changes; | 1060 AutofillChangeList changes; |
1061 if (db_->GetAutofillTable()->RemoveFormElementsAddedBetween( | 1061 if (db_->GetAutofillTable()->RemoveFormElementsAddedBetween( |
1062 request->arg1(), request->arg2(), &changes)) { | 1062 request->arg1(), request->arg2(), &changes)) { |
1063 if (!changes.empty()) { | 1063 if (!changes.empty()) { |
1064 request->SetResult( | 1064 request->SetResult( |
1065 new WDResult<AutofillChangeList>(AUTOFILL_CHANGES, changes)); | 1065 new WDResult<AutofillChangeList>(AUTOFILL_CHANGES, changes)); |
1066 | 1066 |
1067 // Post the notifications including the list of affected keys. | 1067 // Post the notifications including the list of affected keys. |
1068 // This is sent here so that work resulting from this notification | 1068 // This is sent here so that work resulting from this notification |
1069 // will be done on the DB thread, and not the UI thread. | 1069 // will be done on the DB thread, and not the UI thread. |
1070 NotificationService::current()->Notify( | 1070 content::NotificationService::current()->Notify( |
1071 chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, | 1071 chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, |
1072 content::Source<WebDataService>(this), | 1072 content::Source<WebDataService>(this), |
1073 content::Details<AutofillChangeList>(&changes)); | 1073 content::Details<AutofillChangeList>(&changes)); |
1074 } | 1074 } |
1075 ScheduleCommit(); | 1075 ScheduleCommit(); |
1076 } | 1076 } |
1077 } | 1077 } |
1078 request->RequestComplete(); | 1078 request->RequestComplete(); |
1079 } | 1079 } |
1080 | 1080 |
1081 void WebDataService::RemoveFormValueForElementNameImpl( | 1081 void WebDataService::RemoveFormValueForElementNameImpl( |
1082 GenericRequest2<string16, string16>* request) { | 1082 GenericRequest2<string16, string16>* request) { |
1083 InitializeDatabaseIfNecessary(); | 1083 InitializeDatabaseIfNecessary(); |
1084 if (db_ && !request->IsCancelled(NULL)) { | 1084 if (db_ && !request->IsCancelled(NULL)) { |
1085 const string16& name = request->arg1(); | 1085 const string16& name = request->arg1(); |
1086 const string16& value = request->arg2(); | 1086 const string16& value = request->arg2(); |
1087 | 1087 |
1088 if (db_->GetAutofillTable()->RemoveFormElement(name, value)) { | 1088 if (db_->GetAutofillTable()->RemoveFormElement(name, value)) { |
1089 AutofillChangeList changes; | 1089 AutofillChangeList changes; |
1090 changes.push_back(AutofillChange(AutofillChange::REMOVE, | 1090 changes.push_back(AutofillChange(AutofillChange::REMOVE, |
1091 AutofillKey(name, value))); | 1091 AutofillKey(name, value))); |
1092 request->SetResult( | 1092 request->SetResult( |
1093 new WDResult<AutofillChangeList>(AUTOFILL_CHANGES, changes)); | 1093 new WDResult<AutofillChangeList>(AUTOFILL_CHANGES, changes)); |
1094 ScheduleCommit(); | 1094 ScheduleCommit(); |
1095 | 1095 |
1096 // Post the notifications including the list of affected keys. | 1096 // Post the notifications including the list of affected keys. |
1097 NotificationService::current()->Notify( | 1097 content::NotificationService::current()->Notify( |
1098 chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, | 1098 chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, |
1099 content::Source<WebDataService>(this), | 1099 content::Source<WebDataService>(this), |
1100 content::Details<AutofillChangeList>(&changes)); | 1100 content::Details<AutofillChangeList>(&changes)); |
1101 } | 1101 } |
1102 } | 1102 } |
1103 request->RequestComplete(); | 1103 request->RequestComplete(); |
1104 } | 1104 } |
1105 | 1105 |
1106 void WebDataService::AddAutofillProfileImpl( | 1106 void WebDataService::AddAutofillProfileImpl( |
1107 GenericRequest<AutofillProfile>* request) { | 1107 GenericRequest<AutofillProfile>* request) { |
1108 InitializeDatabaseIfNecessary(); | 1108 InitializeDatabaseIfNecessary(); |
1109 if (db_ && !request->IsCancelled(NULL)) { | 1109 if (db_ && !request->IsCancelled(NULL)) { |
1110 const AutofillProfile& profile = request->arg(); | 1110 const AutofillProfile& profile = request->arg(); |
1111 if (!db_->GetAutofillTable()->AddAutofillProfile(profile)) { | 1111 if (!db_->GetAutofillTable()->AddAutofillProfile(profile)) { |
1112 NOTREACHED(); | 1112 NOTREACHED(); |
1113 return; | 1113 return; |
1114 } | 1114 } |
1115 ScheduleCommit(); | 1115 ScheduleCommit(); |
1116 | 1116 |
1117 // Send GUID-based notification. | 1117 // Send GUID-based notification. |
1118 AutofillProfileChange change(AutofillProfileChange::ADD, | 1118 AutofillProfileChange change(AutofillProfileChange::ADD, |
1119 profile.guid(), &profile); | 1119 profile.guid(), &profile); |
1120 NotificationService::current()->Notify( | 1120 content::NotificationService::current()->Notify( |
1121 chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, | 1121 chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, |
1122 content::Source<WebDataService>(this), | 1122 content::Source<WebDataService>(this), |
1123 content::Details<AutofillProfileChange>(&change)); | 1123 content::Details<AutofillProfileChange>(&change)); |
1124 } | 1124 } |
1125 request->RequestComplete(); | 1125 request->RequestComplete(); |
1126 } | 1126 } |
1127 | 1127 |
1128 void WebDataService::UpdateAutofillProfileImpl( | 1128 void WebDataService::UpdateAutofillProfileImpl( |
1129 GenericRequest<AutofillProfile>* request) { | 1129 GenericRequest<AutofillProfile>* request) { |
1130 InitializeDatabaseIfNecessary(); | 1130 InitializeDatabaseIfNecessary(); |
(...skipping 13 matching lines...) Expand all Loading... |
1144 | 1144 |
1145 if (!db_->GetAutofillTable()->UpdateAutofillProfileMulti(profile)) { | 1145 if (!db_->GetAutofillTable()->UpdateAutofillProfileMulti(profile)) { |
1146 NOTREACHED(); | 1146 NOTREACHED(); |
1147 return; | 1147 return; |
1148 } | 1148 } |
1149 ScheduleCommit(); | 1149 ScheduleCommit(); |
1150 | 1150 |
1151 // Send GUID-based notification. | 1151 // Send GUID-based notification. |
1152 AutofillProfileChange change(AutofillProfileChange::UPDATE, | 1152 AutofillProfileChange change(AutofillProfileChange::UPDATE, |
1153 profile.guid(), &profile); | 1153 profile.guid(), &profile); |
1154 NotificationService::current()->Notify( | 1154 content::NotificationService::current()->Notify( |
1155 chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, | 1155 chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, |
1156 content::Source<WebDataService>(this), | 1156 content::Source<WebDataService>(this), |
1157 content::Details<AutofillProfileChange>(&change)); | 1157 content::Details<AutofillProfileChange>(&change)); |
1158 } | 1158 } |
1159 request->RequestComplete(); | 1159 request->RequestComplete(); |
1160 } | 1160 } |
1161 | 1161 |
1162 void WebDataService::RemoveAutofillProfileImpl( | 1162 void WebDataService::RemoveAutofillProfileImpl( |
1163 GenericRequest<std::string>* request) { | 1163 GenericRequest<std::string>* request) { |
1164 InitializeDatabaseIfNecessary(); | 1164 InitializeDatabaseIfNecessary(); |
1165 if (db_ && !request->IsCancelled(NULL)) { | 1165 if (db_ && !request->IsCancelled(NULL)) { |
1166 const std::string& guid = request->arg(); | 1166 const std::string& guid = request->arg(); |
1167 | 1167 |
1168 AutofillProfile* profile = NULL; | 1168 AutofillProfile* profile = NULL; |
1169 if (!db_->GetAutofillTable()->GetAutofillProfile(guid, &profile)) { | 1169 if (!db_->GetAutofillTable()->GetAutofillProfile(guid, &profile)) { |
1170 NOTREACHED(); | 1170 NOTREACHED(); |
1171 return; | 1171 return; |
1172 } | 1172 } |
1173 scoped_ptr<AutofillProfile> scoped_profile(profile); | 1173 scoped_ptr<AutofillProfile> scoped_profile(profile); |
1174 | 1174 |
1175 if (!db_->GetAutofillTable()->RemoveAutofillProfile(guid)) { | 1175 if (!db_->GetAutofillTable()->RemoveAutofillProfile(guid)) { |
1176 NOTREACHED(); | 1176 NOTREACHED(); |
1177 return; | 1177 return; |
1178 } | 1178 } |
1179 ScheduleCommit(); | 1179 ScheduleCommit(); |
1180 | 1180 |
1181 // Send GUID-based notification. | 1181 // Send GUID-based notification. |
1182 AutofillProfileChange change(AutofillProfileChange::REMOVE, guid, NULL); | 1182 AutofillProfileChange change(AutofillProfileChange::REMOVE, guid, NULL); |
1183 NotificationService::current()->Notify( | 1183 content::NotificationService::current()->Notify( |
1184 chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, | 1184 chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, |
1185 content::Source<WebDataService>(this), | 1185 content::Source<WebDataService>(this), |
1186 content::Details<AutofillProfileChange>(&change)); | 1186 content::Details<AutofillProfileChange>(&change)); |
1187 } | 1187 } |
1188 request->RequestComplete(); | 1188 request->RequestComplete(); |
1189 } | 1189 } |
1190 | 1190 |
1191 void WebDataService::GetAutofillProfilesImpl(WebDataRequest* request) { | 1191 void WebDataService::GetAutofillProfilesImpl(WebDataRequest* request) { |
1192 InitializeDatabaseIfNecessary(); | 1192 InitializeDatabaseIfNecessary(); |
1193 if (db_ && !request->IsCancelled(NULL)) { | 1193 if (db_ && !request->IsCancelled(NULL)) { |
(...skipping 16 matching lines...) Expand all Loading... |
1210 if (!db_->GetAutofillTable()->GetAutofillProfilesInTrash(&guids)) { | 1210 if (!db_->GetAutofillTable()->GetAutofillProfilesInTrash(&guids)) { |
1211 NOTREACHED(); | 1211 NOTREACHED(); |
1212 return; | 1212 return; |
1213 } | 1213 } |
1214 | 1214 |
1215 for (std::vector<std::string>::const_iterator iter = guids.begin(); | 1215 for (std::vector<std::string>::const_iterator iter = guids.begin(); |
1216 iter != guids.end(); ++iter) { | 1216 iter != guids.end(); ++iter) { |
1217 // Send GUID-based notification. | 1217 // Send GUID-based notification. |
1218 AutofillProfileChange change(AutofillProfileChange::REMOVE, | 1218 AutofillProfileChange change(AutofillProfileChange::REMOVE, |
1219 *iter, NULL); | 1219 *iter, NULL); |
1220 NotificationService::current()->Notify( | 1220 content::NotificationService::current()->Notify( |
1221 chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, | 1221 chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, |
1222 content::Source<WebDataService>(this), | 1222 content::Source<WebDataService>(this), |
1223 content::Details<AutofillProfileChange>(&change)); | 1223 content::Details<AutofillProfileChange>(&change)); |
1224 } | 1224 } |
1225 | 1225 |
1226 // If we trashed any profiles they may have been merged, so send out | 1226 // If we trashed any profiles they may have been merged, so send out |
1227 // update notifications as well. | 1227 // update notifications as well. |
1228 if (!guids.empty()) { | 1228 if (!guids.empty()) { |
1229 std::vector<AutofillProfile*> profiles; | 1229 std::vector<AutofillProfile*> profiles; |
1230 db_->GetAutofillTable()->GetAutofillProfiles(&profiles); | 1230 db_->GetAutofillTable()->GetAutofillProfiles(&profiles); |
1231 for (std::vector<AutofillProfile*>::const_iterator | 1231 for (std::vector<AutofillProfile*>::const_iterator |
1232 iter = profiles.begin(); | 1232 iter = profiles.begin(); |
1233 iter != profiles.end(); ++iter) { | 1233 iter != profiles.end(); ++iter) { |
1234 AutofillProfileChange change(AutofillProfileChange::UPDATE, | 1234 AutofillProfileChange change(AutofillProfileChange::UPDATE, |
1235 (*iter)->guid(), *iter); | 1235 (*iter)->guid(), *iter); |
1236 NotificationService::current()->Notify( | 1236 content::NotificationService::current()->Notify( |
1237 chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, | 1237 chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, |
1238 content::Source<WebDataService>(this), | 1238 content::Source<WebDataService>(this), |
1239 content::Details<AutofillProfileChange>(&change)); | 1239 content::Details<AutofillProfileChange>(&change)); |
1240 } | 1240 } |
1241 STLDeleteElements(&profiles); | 1241 STLDeleteElements(&profiles); |
1242 } | 1242 } |
1243 } | 1243 } |
1244 | 1244 |
1245 if (!db_->GetAutofillTable()->EmptyAutofillProfilesTrash()) { | 1245 if (!db_->GetAutofillTable()->EmptyAutofillProfilesTrash()) { |
1246 NOTREACHED(); | 1246 NOTREACHED(); |
(...skipping 11 matching lines...) Expand all Loading... |
1258 const CreditCard& credit_card = request->arg(); | 1258 const CreditCard& credit_card = request->arg(); |
1259 if (!db_->GetAutofillTable()->AddCreditCard(credit_card)) { | 1259 if (!db_->GetAutofillTable()->AddCreditCard(credit_card)) { |
1260 NOTREACHED(); | 1260 NOTREACHED(); |
1261 return; | 1261 return; |
1262 } | 1262 } |
1263 ScheduleCommit(); | 1263 ScheduleCommit(); |
1264 | 1264 |
1265 // Send GUID-based notification. | 1265 // Send GUID-based notification. |
1266 AutofillCreditCardChange change(AutofillCreditCardChange::ADD, | 1266 AutofillCreditCardChange change(AutofillCreditCardChange::ADD, |
1267 credit_card.guid(), &credit_card); | 1267 credit_card.guid(), &credit_card); |
1268 NotificationService::current()->Notify( | 1268 content::NotificationService::current()->Notify( |
1269 chrome::NOTIFICATION_AUTOFILL_CREDIT_CARD_CHANGED, | 1269 chrome::NOTIFICATION_AUTOFILL_CREDIT_CARD_CHANGED, |
1270 content::Source<WebDataService>(this), | 1270 content::Source<WebDataService>(this), |
1271 content::Details<AutofillCreditCardChange>(&change)); | 1271 content::Details<AutofillCreditCardChange>(&change)); |
1272 } | 1272 } |
1273 request->RequestComplete(); | 1273 request->RequestComplete(); |
1274 } | 1274 } |
1275 | 1275 |
1276 void WebDataService::UpdateCreditCardImpl( | 1276 void WebDataService::UpdateCreditCardImpl( |
1277 GenericRequest<CreditCard>* request) { | 1277 GenericRequest<CreditCard>* request) { |
1278 InitializeDatabaseIfNecessary(); | 1278 InitializeDatabaseIfNecessary(); |
(...skipping 12 matching lines...) Expand all Loading... |
1291 | 1291 |
1292 if (!db_->GetAutofillTable()->UpdateCreditCard(credit_card)) { | 1292 if (!db_->GetAutofillTable()->UpdateCreditCard(credit_card)) { |
1293 NOTREACHED(); | 1293 NOTREACHED(); |
1294 return; | 1294 return; |
1295 } | 1295 } |
1296 ScheduleCommit(); | 1296 ScheduleCommit(); |
1297 | 1297 |
1298 // Send GUID-based notification. | 1298 // Send GUID-based notification. |
1299 AutofillCreditCardChange change(AutofillCreditCardChange::UPDATE, | 1299 AutofillCreditCardChange change(AutofillCreditCardChange::UPDATE, |
1300 credit_card.guid(), &credit_card); | 1300 credit_card.guid(), &credit_card); |
1301 NotificationService::current()->Notify( | 1301 content::NotificationService::current()->Notify( |
1302 chrome::NOTIFICATION_AUTOFILL_CREDIT_CARD_CHANGED, | 1302 chrome::NOTIFICATION_AUTOFILL_CREDIT_CARD_CHANGED, |
1303 content::Source<WebDataService>(this), | 1303 content::Source<WebDataService>(this), |
1304 content::Details<AutofillCreditCardChange>(&change)); | 1304 content::Details<AutofillCreditCardChange>(&change)); |
1305 } | 1305 } |
1306 request->RequestComplete(); | 1306 request->RequestComplete(); |
1307 } | 1307 } |
1308 | 1308 |
1309 void WebDataService::RemoveCreditCardImpl( | 1309 void WebDataService::RemoveCreditCardImpl( |
1310 GenericRequest<std::string>* request) { | 1310 GenericRequest<std::string>* request) { |
1311 InitializeDatabaseIfNecessary(); | 1311 InitializeDatabaseIfNecessary(); |
1312 if (db_ && !request->IsCancelled(NULL)) { | 1312 if (db_ && !request->IsCancelled(NULL)) { |
1313 const std::string& guid = request->arg(); | 1313 const std::string& guid = request->arg(); |
1314 if (!db_->GetAutofillTable()->RemoveCreditCard(guid)) { | 1314 if (!db_->GetAutofillTable()->RemoveCreditCard(guid)) { |
1315 NOTREACHED(); | 1315 NOTREACHED(); |
1316 return; | 1316 return; |
1317 } | 1317 } |
1318 ScheduleCommit(); | 1318 ScheduleCommit(); |
1319 | 1319 |
1320 // Send GUID-based notification. | 1320 // Send GUID-based notification. |
1321 AutofillCreditCardChange change(AutofillCreditCardChange::REMOVE, guid, | 1321 AutofillCreditCardChange change(AutofillCreditCardChange::REMOVE, guid, |
1322 NULL); | 1322 NULL); |
1323 NotificationService::current()->Notify( | 1323 content::NotificationService::current()->Notify( |
1324 chrome::NOTIFICATION_AUTOFILL_CREDIT_CARD_CHANGED, | 1324 chrome::NOTIFICATION_AUTOFILL_CREDIT_CARD_CHANGED, |
1325 content::Source<WebDataService>(this), | 1325 content::Source<WebDataService>(this), |
1326 content::Details<AutofillCreditCardChange>(&change)); | 1326 content::Details<AutofillCreditCardChange>(&change)); |
1327 } | 1327 } |
1328 request->RequestComplete(); | 1328 request->RequestComplete(); |
1329 } | 1329 } |
1330 | 1330 |
1331 void WebDataService::GetCreditCardsImpl(WebDataRequest* request) { | 1331 void WebDataService::GetCreditCardsImpl(WebDataRequest* request) { |
1332 InitializeDatabaseIfNecessary(); | 1332 InitializeDatabaseIfNecessary(); |
1333 if (db_ && !request->IsCancelled(NULL)) { | 1333 if (db_ && !request->IsCancelled(NULL)) { |
(...skipping 15 matching lines...) Expand all Loading... |
1349 if (db_->GetAutofillTable()-> | 1349 if (db_->GetAutofillTable()-> |
1350 RemoveAutofillProfilesAndCreditCardsModifiedBetween( | 1350 RemoveAutofillProfilesAndCreditCardsModifiedBetween( |
1351 request->arg1(), | 1351 request->arg1(), |
1352 request->arg2(), | 1352 request->arg2(), |
1353 &profile_guids, | 1353 &profile_guids, |
1354 &credit_card_guids)) { | 1354 &credit_card_guids)) { |
1355 for (std::vector<std::string>::iterator iter = profile_guids.begin(); | 1355 for (std::vector<std::string>::iterator iter = profile_guids.begin(); |
1356 iter != profile_guids.end(); ++iter) { | 1356 iter != profile_guids.end(); ++iter) { |
1357 AutofillProfileChange change(AutofillProfileChange::REMOVE, *iter, | 1357 AutofillProfileChange change(AutofillProfileChange::REMOVE, *iter, |
1358 NULL); | 1358 NULL); |
1359 NotificationService::current()->Notify( | 1359 content::NotificationService::current()->Notify( |
1360 chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, | 1360 chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, |
1361 content::Source<WebDataService>(this), | 1361 content::Source<WebDataService>(this), |
1362 content::Details<AutofillProfileChange>(&change)); | 1362 content::Details<AutofillProfileChange>(&change)); |
1363 } | 1363 } |
1364 | 1364 |
1365 for (std::vector<std::string>::iterator iter = credit_card_guids.begin(); | 1365 for (std::vector<std::string>::iterator iter = credit_card_guids.begin(); |
1366 iter != credit_card_guids.end(); ++iter) { | 1366 iter != credit_card_guids.end(); ++iter) { |
1367 AutofillCreditCardChange change(AutofillCreditCardChange::REMOVE, | 1367 AutofillCreditCardChange change(AutofillCreditCardChange::REMOVE, |
1368 *iter, NULL); | 1368 *iter, NULL); |
1369 NotificationService::current()->Notify( | 1369 content::NotificationService::current()->Notify( |
1370 chrome::NOTIFICATION_AUTOFILL_CREDIT_CARD_CHANGED, | 1370 chrome::NOTIFICATION_AUTOFILL_CREDIT_CARD_CHANGED, |
1371 content::Source<WebDataService>(this), | 1371 content::Source<WebDataService>(this), |
1372 content::Details<AutofillCreditCardChange>(&change)); | 1372 content::Details<AutofillCreditCardChange>(&change)); |
1373 } | 1373 } |
1374 // Note: It is the caller's responsibility to post notifications for any | 1374 // Note: It is the caller's responsibility to post notifications for any |
1375 // changes, e.g. by calling the Refresh() method of PersonalDataManager. | 1375 // changes, e.g. by calling the Refresh() method of PersonalDataManager. |
1376 ScheduleCommit(); | 1376 ScheduleCommit(); |
1377 } | 1377 } |
1378 } | 1378 } |
1379 request->RequestComplete(); | 1379 request->RequestComplete(); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1431 } | 1431 } |
1432 | 1432 |
1433 const WDTypedResult* WebDataService::WebDataRequest::GetResult() const { | 1433 const WDTypedResult* WebDataService::WebDataRequest::GetResult() const { |
1434 return result_; | 1434 return result_; |
1435 } | 1435 } |
1436 | 1436 |
1437 void WebDataService::WebDataRequest::RequestComplete() { | 1437 void WebDataService::WebDataRequest::RequestComplete() { |
1438 message_loop_->PostTask(FROM_HERE, Bind(&WebDataService::RequestCompleted, | 1438 message_loop_->PostTask(FROM_HERE, Bind(&WebDataService::RequestCompleted, |
1439 service_.get(), handle_)); | 1439 service_.get(), handle_)); |
1440 } | 1440 } |
OLD | NEW |