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/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "chrome/browser/search_engines/template_url.h" | 8 #include "chrome/browser/search_engines/template_url.h" |
9 #include "chrome/browser/webdata/autofill_change.h" | 9 #include "chrome/browser/webdata/autofill_change.h" |
10 #include "chrome/browser/webdata/autofill_entry.h" | 10 #include "chrome/browser/webdata/autofill_entry.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 | 55 |
56 WDAppImagesResult::~WDAppImagesResult() {} | 56 WDAppImagesResult::~WDAppImagesResult() {} |
57 | 57 |
58 WDKeywordsResult::WDKeywordsResult() | 58 WDKeywordsResult::WDKeywordsResult() |
59 : default_search_provider_id(0), | 59 : default_search_provider_id(0), |
60 builtin_keyword_version(0) { | 60 builtin_keyword_version(0) { |
61 } | 61 } |
62 | 62 |
63 WDKeywordsResult::~WDKeywordsResult() {} | 63 WDKeywordsResult::~WDKeywordsResult() {} |
64 | 64 |
65 WebDataService::WebDataService(const ProfileErrorCallback& callback) | 65 WebDataService::WebDataService(scoped_refptr<WebDatabaseService> wdbs, |
66 : WebDataServiceBase(callback) { | 66 const ProfileErrorCallback& callback) |
| 67 : WebDataServiceBase(wdbs, callback) { |
67 } | 68 } |
68 | 69 |
69 // static | 70 // static |
70 void WebDataService::NotifyOfMultipleAutofillChanges( | 71 void WebDataService::NotifyOfMultipleAutofillChanges( |
71 WebDataService* web_data_service) { | 72 WebDataService* web_data_service) { |
72 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 73 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
73 | 74 |
74 if (!web_data_service) | 75 if (!web_data_service) |
75 return; | 76 return; |
76 | 77 |
(...skipping 17 matching lines...) Expand all Loading... |
94 void WebDataService::RemoveKeyword(TemplateURLID id) { | 95 void WebDataService::RemoveKeyword(TemplateURLID id) { |
95 wdbs_->ScheduleDBTask( | 96 wdbs_->ScheduleDBTask( |
96 FROM_HERE, Bind(&WebDataService::RemoveKeywordImpl, this, id)); | 97 FROM_HERE, Bind(&WebDataService::RemoveKeywordImpl, this, id)); |
97 } | 98 } |
98 | 99 |
99 void WebDataService::UpdateKeyword(const TemplateURLData& data) { | 100 void WebDataService::UpdateKeyword(const TemplateURLData& data) { |
100 wdbs_->ScheduleDBTask( | 101 wdbs_->ScheduleDBTask( |
101 FROM_HERE, Bind(&WebDataService::UpdateKeywordImpl, this, data)); | 102 FROM_HERE, Bind(&WebDataService::UpdateKeywordImpl, this, data)); |
102 } | 103 } |
103 | 104 |
104 WebDataService::Handle WebDataService::GetKeywords( | 105 WebDataServiceBase::Handle WebDataService::GetKeywords( |
105 WebDataServiceConsumer* consumer) { | 106 WebDataServiceConsumer* consumer) { |
106 return wdbs_->ScheduleDBTaskWithResult(FROM_HERE, | 107 return wdbs_->ScheduleDBTaskWithResult(FROM_HERE, |
107 Bind(&WebDataService::GetKeywordsImpl, this), consumer); | 108 Bind(&WebDataService::GetKeywordsImpl, this), consumer); |
108 } | 109 } |
109 | 110 |
110 void WebDataService::SetDefaultSearchProvider(const TemplateURL* url) { | 111 void WebDataService::SetDefaultSearchProvider(const TemplateURL* url) { |
111 wdbs_->ScheduleDBTask(FROM_HERE, | 112 wdbs_->ScheduleDBTask(FROM_HERE, |
112 Bind(&WebDataService::SetDefaultSearchProviderImpl, this, | 113 Bind(&WebDataService::SetDefaultSearchProviderImpl, this, |
113 url ? url->id() : 0)); | 114 url ? url->id() : 0)); |
114 } | 115 } |
(...skipping 20 matching lines...) Expand all Loading... |
135 wdbs_->ScheduleDBTask(FROM_HERE, | 136 wdbs_->ScheduleDBTask(FROM_HERE, |
136 Bind(&WebDataService::SetWebAppHasAllImagesImpl, this, app_url, | 137 Bind(&WebDataService::SetWebAppHasAllImagesImpl, this, app_url, |
137 has_all_images)); | 138 has_all_images)); |
138 } | 139 } |
139 | 140 |
140 void WebDataService::RemoveWebApp(const GURL& app_url) { | 141 void WebDataService::RemoveWebApp(const GURL& app_url) { |
141 wdbs_->ScheduleDBTask(FROM_HERE, | 142 wdbs_->ScheduleDBTask(FROM_HERE, |
142 Bind(&WebDataService::RemoveWebAppImpl, this, app_url)); | 143 Bind(&WebDataService::RemoveWebAppImpl, this, app_url)); |
143 } | 144 } |
144 | 145 |
145 WebDataService::Handle WebDataService::GetWebAppImages( | 146 WebDataServiceBase::Handle WebDataService::GetWebAppImages( |
146 const GURL& app_url, WebDataServiceConsumer* consumer) { | 147 const GURL& app_url, WebDataServiceConsumer* consumer) { |
147 return wdbs_->ScheduleDBTaskWithResult(FROM_HERE, | 148 return wdbs_->ScheduleDBTaskWithResult(FROM_HERE, |
148 Bind(&WebDataService::GetWebAppImagesImpl, this, app_url), consumer); | 149 Bind(&WebDataService::GetWebAppImagesImpl, this, app_url), consumer); |
149 } | 150 } |
150 | 151 |
151 //////////////////////////////////////////////////////////////////////////////// | 152 //////////////////////////////////////////////////////////////////////////////// |
152 // | 153 // |
153 // Token Service | 154 // Token Service |
154 // | 155 // |
155 //////////////////////////////////////////////////////////////////////////////// | 156 //////////////////////////////////////////////////////////////////////////////// |
156 | 157 |
157 void WebDataService::SetTokenForService(const std::string& service, | 158 void WebDataService::SetTokenForService(const std::string& service, |
158 const std::string& token) { | 159 const std::string& token) { |
159 wdbs_->ScheduleDBTask(FROM_HERE, | 160 wdbs_->ScheduleDBTask(FROM_HERE, |
160 Bind(&WebDataService::SetTokenForServiceImpl, this, service, token)); | 161 Bind(&WebDataService::SetTokenForServiceImpl, this, service, token)); |
161 } | 162 } |
162 | 163 |
163 void WebDataService::RemoveAllTokens() { | 164 void WebDataService::RemoveAllTokens() { |
164 wdbs_->ScheduleDBTask(FROM_HERE, | 165 wdbs_->ScheduleDBTask(FROM_HERE, |
165 Bind(&WebDataService::RemoveAllTokensImpl, this)); | 166 Bind(&WebDataService::RemoveAllTokensImpl, this)); |
166 } | 167 } |
167 | 168 |
168 // Null on failure. Success is WDResult<std::string> | 169 // Null on failure. Success is WDResult<std::string> |
169 WebDataService::Handle WebDataService::GetAllTokens( | 170 WebDataServiceBase::Handle WebDataService::GetAllTokens( |
170 WebDataServiceConsumer* consumer) { | 171 WebDataServiceConsumer* consumer) { |
171 return wdbs_->ScheduleDBTaskWithResult(FROM_HERE, | 172 return wdbs_->ScheduleDBTaskWithResult(FROM_HERE, |
172 Bind(&WebDataService::GetAllTokensImpl, this), consumer); | 173 Bind(&WebDataService::GetAllTokensImpl, this), consumer); |
173 } | 174 } |
174 | 175 |
175 //////////////////////////////////////////////////////////////////////////////// | 176 //////////////////////////////////////////////////////////////////////////////// |
176 // | 177 // |
177 // Autofill. | 178 // Autofill. |
178 // | 179 // |
179 //////////////////////////////////////////////////////////////////////////////// | 180 //////////////////////////////////////////////////////////////////////////////// |
180 | 181 |
181 void WebDataService::AddFormFields( | 182 void WebDataService::AddFormFields( |
182 const std::vector<FormFieldData>& fields) { | 183 const std::vector<FormFieldData>& fields) { |
183 wdbs_->ScheduleDBTask(FROM_HERE, | 184 wdbs_->ScheduleDBTask(FROM_HERE, |
184 Bind(&WebDataService::AddFormElementsImpl, this, fields)); | 185 Bind(&WebDataService::AddFormElementsImpl, this, fields)); |
185 } | 186 } |
186 | 187 |
187 WebDataService::Handle WebDataService::GetFormValuesForElementName( | 188 WebDataServiceBase::Handle WebDataService::GetFormValuesForElementName( |
188 const string16& name, const string16& prefix, int limit, | 189 const string16& name, const string16& prefix, int limit, |
189 WebDataServiceConsumer* consumer) { | 190 WebDataServiceConsumer* consumer) { |
190 return wdbs_->ScheduleDBTaskWithResult(FROM_HERE, | 191 return wdbs_->ScheduleDBTaskWithResult(FROM_HERE, |
191 Bind(&WebDataService::GetFormValuesForElementNameImpl, | 192 Bind(&WebDataService::GetFormValuesForElementNameImpl, |
192 this, name, prefix, limit), consumer); | 193 this, name, prefix, limit), consumer); |
193 } | 194 } |
194 | 195 |
195 void WebDataService::RemoveFormElementsAddedBetween(const Time& delete_begin, | 196 void WebDataService::RemoveFormElementsAddedBetween(const Time& delete_begin, |
196 const Time& delete_end) { | 197 const Time& delete_end) { |
197 wdbs_->ScheduleDBTask(FROM_HERE, | 198 wdbs_->ScheduleDBTask(FROM_HERE, |
(...skipping 21 matching lines...) Expand all Loading... |
219 void WebDataService::UpdateAutofillProfile(const AutofillProfile& profile) { | 220 void WebDataService::UpdateAutofillProfile(const AutofillProfile& profile) { |
220 wdbs_->ScheduleDBTask(FROM_HERE, | 221 wdbs_->ScheduleDBTask(FROM_HERE, |
221 Bind(&WebDataService::UpdateAutofillProfileImpl, this, profile)); | 222 Bind(&WebDataService::UpdateAutofillProfileImpl, this, profile)); |
222 } | 223 } |
223 | 224 |
224 void WebDataService::RemoveAutofillProfile(const std::string& guid) { | 225 void WebDataService::RemoveAutofillProfile(const std::string& guid) { |
225 wdbs_->ScheduleDBTask(FROM_HERE, | 226 wdbs_->ScheduleDBTask(FROM_HERE, |
226 Bind(&WebDataService::RemoveAutofillProfileImpl, this, guid)); | 227 Bind(&WebDataService::RemoveAutofillProfileImpl, this, guid)); |
227 } | 228 } |
228 | 229 |
229 WebDataService::Handle WebDataService::GetAutofillProfiles( | 230 WebDataServiceBase::Handle WebDataService::GetAutofillProfiles( |
230 WebDataServiceConsumer* consumer) { | 231 WebDataServiceConsumer* consumer) { |
231 return wdbs_->ScheduleDBTaskWithResult(FROM_HERE, | 232 return wdbs_->ScheduleDBTaskWithResult(FROM_HERE, |
232 Bind(&WebDataService::GetAutofillProfilesImpl, this), consumer); | 233 Bind(&WebDataService::GetAutofillProfilesImpl, this), consumer); |
233 } | 234 } |
234 | 235 |
235 void WebDataService::AddCreditCard(const CreditCard& credit_card) { | 236 void WebDataService::AddCreditCard(const CreditCard& credit_card) { |
236 wdbs_->ScheduleDBTask(FROM_HERE, | 237 wdbs_->ScheduleDBTask(FROM_HERE, |
237 Bind(&WebDataService::AddCreditCardImpl, this, credit_card)); | 238 Bind(&WebDataService::AddCreditCardImpl, this, credit_card)); |
238 } | 239 } |
239 | 240 |
240 void WebDataService::UpdateCreditCard(const CreditCard& credit_card) { | 241 void WebDataService::UpdateCreditCard(const CreditCard& credit_card) { |
241 wdbs_->ScheduleDBTask(FROM_HERE, | 242 wdbs_->ScheduleDBTask(FROM_HERE, |
242 Bind(&WebDataService::UpdateCreditCardImpl, this, credit_card)); | 243 Bind(&WebDataService::UpdateCreditCardImpl, this, credit_card)); |
243 } | 244 } |
244 | 245 |
245 void WebDataService::RemoveCreditCard(const std::string& guid) { | 246 void WebDataService::RemoveCreditCard(const std::string& guid) { |
246 wdbs_->ScheduleDBTask(FROM_HERE, | 247 wdbs_->ScheduleDBTask(FROM_HERE, |
247 Bind(&WebDataService::RemoveCreditCardImpl, this, guid)); | 248 Bind(&WebDataService::RemoveCreditCardImpl, this, guid)); |
248 } | 249 } |
249 | 250 |
250 WebDataService::Handle WebDataService::GetCreditCards( | 251 WebDataServiceBase::Handle WebDataService::GetCreditCards( |
251 WebDataServiceConsumer* consumer) { | 252 WebDataServiceConsumer* consumer) { |
252 return wdbs_->ScheduleDBTaskWithResult(FROM_HERE, | 253 return wdbs_->ScheduleDBTaskWithResult(FROM_HERE, |
253 Bind(&WebDataService::GetCreditCardsImpl, this), consumer); | 254 Bind(&WebDataService::GetCreditCardsImpl, this), consumer); |
254 } | 255 } |
255 | 256 |
256 void WebDataService::RemoveAutofillProfilesAndCreditCardsModifiedBetween( | 257 void WebDataService::RemoveAutofillProfilesAndCreditCardsModifiedBetween( |
257 const Time& delete_begin, | 258 const Time& delete_begin, |
258 const Time& delete_end) { | 259 const Time& delete_end) { |
259 wdbs_->ScheduleDBTask(FROM_HERE, Bind( | 260 wdbs_->ScheduleDBTask(FROM_HERE, Bind( |
260 &WebDataService::RemoveAutofillProfilesAndCreditCardsModifiedBetweenImpl, | 261 &WebDataService::RemoveAutofillProfilesAndCreditCardsModifiedBetweenImpl, |
261 this, delete_begin, delete_end)); | 262 this, delete_begin, delete_end)); |
262 } | 263 } |
263 | 264 |
264 WebDataService::WebDataService() | 265 WebDataService::WebDataService() |
265 : WebDataServiceBase(ProfileErrorCallback()) { | 266 : WebDataServiceBase(NULL, ProfileErrorCallback()) { |
266 } | 267 } |
267 | 268 |
268 WebDataService::~WebDataService() { | 269 WebDataService::~WebDataService() { |
269 } | 270 } |
270 | 271 |
271 //////////////////////////////////////////////////////////////////////////////// | 272 //////////////////////////////////////////////////////////////////////////////// |
272 // | 273 // |
273 // Keywords implementation. | 274 // Keywords implementation. |
274 // | 275 // |
275 //////////////////////////////////////////////////////////////////////////////// | 276 //////////////////////////////////////////////////////////////////////////////// |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 | 653 |
653 void WebDataService::DestroyAutofillCreditCardResult( | 654 void WebDataService::DestroyAutofillCreditCardResult( |
654 const WDTypedResult* result) { | 655 const WDTypedResult* result) { |
655 DCHECK(result->GetType() == AUTOFILL_CREDITCARDS_RESULT); | 656 DCHECK(result->GetType() == AUTOFILL_CREDITCARDS_RESULT); |
656 const WDResult<std::vector<CreditCard*> >* r = | 657 const WDResult<std::vector<CreditCard*> >* r = |
657 static_cast<const WDResult<std::vector<CreditCard*> >*>(result); | 658 static_cast<const WDResult<std::vector<CreditCard*> >*>(result); |
658 | 659 |
659 std::vector<CreditCard*> credit_cards = r->GetValue(); | 660 std::vector<CreditCard*> credit_cards = r->GetValue(); |
660 STLDeleteElements(&credit_cards); | 661 STLDeleteElements(&credit_cards); |
661 } | 662 } |
OLD | NEW |