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