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

Side by Side Diff: components/autofill/browser/webdata/autofill_webdata_service.cc

Issue 14503010: Implement WebViewDatabase's hasFormData API for chromium based webview. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix typos Created 7 years, 7 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
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 "components/autofill/browser/webdata/autofill_webdata_service.h" 5 #include "components/autofill/browser/webdata/autofill_webdata_service.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "components/autofill/browser/autofill_country.h" 9 #include "components/autofill/browser/autofill_country.h"
10 #include "components/autofill/browser/autofill_profile.h" 10 #include "components/autofill/browser/autofill_profile.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 } 54 }
55 55
56 WebDataServiceBase::Handle AutofillWebDataService::GetFormValuesForElementName( 56 WebDataServiceBase::Handle AutofillWebDataService::GetFormValuesForElementName(
57 const base::string16& name, const base::string16& prefix, int limit, 57 const base::string16& name, const base::string16& prefix, int limit,
58 WebDataServiceConsumer* consumer) { 58 WebDataServiceConsumer* consumer) {
59 return wdbs_->ScheduleDBTaskWithResult(FROM_HERE, 59 return wdbs_->ScheduleDBTaskWithResult(FROM_HERE,
60 Bind(&AutofillWebDataService::GetFormValuesForElementNameImpl, 60 Bind(&AutofillWebDataService::GetFormValuesForElementNameImpl,
61 this, name, prefix, limit), consumer); 61 this, name, prefix, limit), consumer);
62 } 62 }
63 63
64 WebDataServiceBase::Handle AutofillWebDataService::HasFormElements(
65 WebDataServiceConsumer* consumer) {
66 return wdbs_->ScheduleDBTaskWithResult(FROM_HERE,
67 Bind(&AutofillWebDataService::HasFormElementsImpl, this), consumer);
68 }
69
64 void AutofillWebDataService::RemoveFormElementsAddedBetween( 70 void AutofillWebDataService::RemoveFormElementsAddedBetween(
65 const Time& delete_begin, const Time& delete_end) { 71 const Time& delete_begin, const Time& delete_end) {
66 wdbs_->ScheduleDBTask(FROM_HERE, 72 wdbs_->ScheduleDBTask(FROM_HERE,
67 Bind(&AutofillWebDataService::RemoveFormElementsAddedBetweenImpl, 73 Bind(&AutofillWebDataService::RemoveFormElementsAddedBetweenImpl,
68 this, delete_begin, delete_end)); 74 this, delete_begin, delete_end));
69 } 75 }
70 76
71 void AutofillWebDataService::RemoveExpiredFormElements() { 77 void AutofillWebDataService::RemoveExpiredFormElements() {
72 wdbs_->ScheduleDBTask(FROM_HERE, 78 wdbs_->ScheduleDBTask(FROM_HERE,
73 Bind(&AutofillWebDataService::RemoveExpiredFormElementsImpl, this)); 79 Bind(&AutofillWebDataService::RemoveExpiredFormElementsImpl, this));
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 WebDatabase* db) { 211 WebDatabase* db) {
206 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); 212 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
207 std::vector<base::string16> values; 213 std::vector<base::string16> values;
208 AutofillTable::FromWebDatabase(db)->GetFormValuesForElementName( 214 AutofillTable::FromWebDatabase(db)->GetFormValuesForElementName(
209 name, prefix, &values, limit); 215 name, prefix, &values, limit);
210 return scoped_ptr<WDTypedResult>( 216 return scoped_ptr<WDTypedResult>(
211 new WDResult<std::vector<base::string16> >(AUTOFILL_VALUE_RESULT, 217 new WDResult<std::vector<base::string16> >(AUTOFILL_VALUE_RESULT,
212 values)); 218 values));
213 } 219 }
214 220
221 scoped_ptr<WDTypedResult> AutofillWebDataService::HasFormElementsImpl(
222 WebDatabase* db) {
223 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
224 bool value = AutofillTable::FromWebDatabase(db)->HasFormElements();
225 return scoped_ptr<WDTypedResult>(
226 new WDResult<bool>(AUTOFILL_VALUE_RESULT, value));
227 }
228
215 WebDatabase::State AutofillWebDataService::RemoveFormElementsAddedBetweenImpl( 229 WebDatabase::State AutofillWebDataService::RemoveFormElementsAddedBetweenImpl(
216 const base::Time& delete_begin, const base::Time& delete_end, 230 const base::Time& delete_begin, const base::Time& delete_end,
217 WebDatabase* db) { 231 WebDatabase* db) {
218 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); 232 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
219 AutofillChangeList changes; 233 AutofillChangeList changes;
220 234
221 if (AutofillTable::FromWebDatabase(db)->RemoveFormElementsAddedBetween( 235 if (AutofillTable::FromWebDatabase(db)->RemoveFormElementsAddedBetween(
222 delete_begin, delete_end, &changes)) { 236 delete_begin, delete_end, &changes)) {
223 if (!changes.empty()) { 237 if (!changes.empty()) {
224 // Post the notifications including the list of affected keys. 238 // Post the notifications including the list of affected keys.
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 } 469 }
456 470
457 void AutofillWebDataService::NotifyAutofillMultipleChangedOnUIThread() { 471 void AutofillWebDataService::NotifyAutofillMultipleChangedOnUIThread() {
458 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 472 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
459 FOR_EACH_OBSERVER(AutofillWebDataServiceObserverOnUIThread, 473 FOR_EACH_OBSERVER(AutofillWebDataServiceObserverOnUIThread,
460 ui_observer_list_, 474 ui_observer_list_,
461 AutofillMultipleChanged()); 475 AutofillMultipleChanged());
462 } 476 }
463 477
464 } // namespace autofill 478 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698