| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
| 10 #include "chrome/browser/search_engines/template_url.h" | 10 #include "chrome/browser/search_engines/template_url.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 GenericRequest<std::vector<AutofillForm::Element> >* request = | 119 GenericRequest<std::vector<AutofillForm::Element> >* request = |
| 120 new GenericRequest<std::vector<AutofillForm::Element> >( | 120 new GenericRequest<std::vector<AutofillForm::Element> >( |
| 121 this, GetNextRequestHandle(), NULL, element); | 121 this, GetNextRequestHandle(), NULL, element); |
| 122 RegisterRequest(request); | 122 RegisterRequest(request); |
| 123 ScheduleTask(NewRunnableMethod(this, | 123 ScheduleTask(NewRunnableMethod(this, |
| 124 &WebDataService::AddAutofillFormElementsImpl, | 124 &WebDataService::AddAutofillFormElementsImpl, |
| 125 request)); | 125 request)); |
| 126 } | 126 } |
| 127 | 127 |
| 128 WebDataService::Handle WebDataService::GetFormValuesForElementName( | 128 WebDataService::Handle WebDataService::GetFormValuesForElementName( |
| 129 const std::wstring& name, const std::wstring& prefix, int limit, | 129 const string16& name, const string16& prefix, int limit, |
| 130 WebDataServiceConsumer* consumer) { | 130 WebDataServiceConsumer* consumer) { |
| 131 WebDataRequest* request = | 131 WebDataRequest* request = |
| 132 new WebDataRequest(this, GetNextRequestHandle(), consumer); | 132 new WebDataRequest(this, GetNextRequestHandle(), consumer); |
| 133 RegisterRequest(request); | 133 RegisterRequest(request); |
| 134 ScheduleTask( | 134 ScheduleTask( |
| 135 NewRunnableMethod(this, | 135 NewRunnableMethod(this, |
| 136 &WebDataService::GetFormValuesForElementNameImpl, | 136 &WebDataService::GetFormValuesForElementNameImpl, |
| 137 request, | 137 request, |
| 138 name, | 138 name, |
| 139 prefix, | 139 prefix, |
| 140 limit)); | 140 limit)); |
| 141 return request->GetHandle(); | 141 return request->GetHandle(); |
| 142 } | 142 } |
| 143 | 143 |
| 144 void WebDataService::RemoveFormValueForElementName( | 144 void WebDataService::RemoveFormValueForElementName( |
| 145 const std::wstring& name, const std::wstring& value) { | 145 const string16& name, const string16& value) { |
| 146 GenericRequest2<std::wstring, std::wstring>* request = | 146 GenericRequest2<string16, string16>* request = |
| 147 new GenericRequest2<std::wstring, std::wstring>(this, | 147 new GenericRequest2<string16, string16>(this, |
| 148 GetNextRequestHandle(), | 148 GetNextRequestHandle(), |
| 149 NULL, | 149 NULL, |
| 150 name, value); | 150 name, value); |
| 151 RegisterRequest(request); | 151 RegisterRequest(request); |
| 152 ScheduleTask( | 152 ScheduleTask( |
| 153 NewRunnableMethod(this, | 153 NewRunnableMethod(this, |
| 154 &WebDataService::RemoveFormValueForElementNameImpl, | 154 &WebDataService::RemoveFormValueForElementNameImpl, |
| 155 request)); | 155 request)); |
| 156 } | 156 } |
| 157 | 157 |
| 158 void WebDataService::RequestCompleted(Handle h) { | 158 void WebDataService::RequestCompleted(Handle h) { |
| 159 pending_lock_.Acquire(); | 159 pending_lock_.Acquire(); |
| 160 RequestMap::iterator i = pending_requests_.find(h); | 160 RequestMap::iterator i = pending_requests_.find(h); |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 void WebDataService::AddAutofillFormElementsImpl( | 575 void WebDataService::AddAutofillFormElementsImpl( |
| 576 GenericRequest<std::vector<AutofillForm::Element> >* request) { | 576 GenericRequest<std::vector<AutofillForm::Element> >* request) { |
| 577 if (db_ && !request->IsCancelled()) { | 577 if (db_ && !request->IsCancelled()) { |
| 578 if (db_->AddAutofillFormElements(request->GetArgument())) | 578 if (db_->AddAutofillFormElements(request->GetArgument())) |
| 579 ScheduleCommit(); | 579 ScheduleCommit(); |
| 580 } | 580 } |
| 581 request->RequestComplete(); | 581 request->RequestComplete(); |
| 582 } | 582 } |
| 583 | 583 |
| 584 void WebDataService::GetFormValuesForElementNameImpl(WebDataRequest* request, | 584 void WebDataService::GetFormValuesForElementNameImpl(WebDataRequest* request, |
| 585 const std::wstring& name, const std::wstring& prefix, int limit) { | 585 const string16& name, const string16& prefix, int limit) { |
| 586 if (db_ && !request->IsCancelled()) { | 586 if (db_ && !request->IsCancelled()) { |
| 587 std::vector<std::wstring> values; | 587 std::vector<string16> values; |
| 588 db_->GetFormValuesForElementName(name, prefix, &values, limit); | 588 db_->GetFormValuesForElementName(name, prefix, &values, limit); |
| 589 request->SetResult( | 589 request->SetResult( |
| 590 new WDResult<std::vector<std::wstring> >(AUTOFILL_VALUE_RESULT, | 590 new WDResult<std::vector<string16> >(AUTOFILL_VALUE_RESULT, |
| 591 values)); | 591 values)); |
| 592 } | 592 } |
| 593 request->RequestComplete(); | 593 request->RequestComplete(); |
| 594 } | 594 } |
| 595 | 595 |
| 596 void WebDataService::RemoveFormElementsAddedBetweenImpl( | 596 void WebDataService::RemoveFormElementsAddedBetweenImpl( |
| 597 GenericRequest2<Time, Time>* request) { | 597 GenericRequest2<Time, Time>* request) { |
| 598 if (db_ && !request->IsCancelled()) { | 598 if (db_ && !request->IsCancelled()) { |
| 599 if (db_->RemoveFormElementsAddedBetween(request->GetArgument1(), | 599 if (db_->RemoveFormElementsAddedBetween(request->GetArgument1(), |
| 600 request->GetArgument2())) | 600 request->GetArgument2())) |
| 601 ScheduleCommit(); | 601 ScheduleCommit(); |
| 602 } | 602 } |
| 603 request->RequestComplete(); | 603 request->RequestComplete(); |
| 604 } | 604 } |
| 605 | 605 |
| 606 void WebDataService::RemoveFormValueForElementNameImpl( | 606 void WebDataService::RemoveFormValueForElementNameImpl( |
| 607 GenericRequest2<std::wstring, std::wstring>* request) { | 607 GenericRequest2<string16, string16>* request) { |
| 608 if (db_ && !request->IsCancelled()) { | 608 if (db_ && !request->IsCancelled()) { |
| 609 if (db_->RemoveFormElement(request->GetArgument1(), | 609 if (db_->RemoveFormElement(request->GetArgument1(), |
| 610 request->GetArgument2())) | 610 request->GetArgument2())) |
| 611 ScheduleCommit(); | 611 ScheduleCommit(); |
| 612 } | 612 } |
| 613 request->RequestComplete(); | 613 request->RequestComplete(); |
| 614 } | 614 } |
| 615 | 615 |
| 616 //////////////////////////////////////////////////////////////////////////////// | 616 //////////////////////////////////////////////////////////////////////////////// |
| 617 // | 617 // |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 Task* t = NewRunnableMethod(s, | 708 Task* t = NewRunnableMethod(s, |
| 709 &WebDataService::RequestCompleted, | 709 &WebDataService::RequestCompleted, |
| 710 handle_); | 710 handle_); |
| 711 message_loop_->PostTask(FROM_HERE, t); | 711 message_loop_->PostTask(FROM_HERE, t); |
| 712 } | 712 } |
| 713 | 713 |
| 714 int WebDataService::GetNextRequestHandle() { | 714 int WebDataService::GetNextRequestHandle() { |
| 715 AutoLock l(pending_lock_); | 715 AutoLock l(pending_lock_); |
| 716 return ++next_request_handle_; | 716 return ++next_request_handle_; |
| 717 } | 717 } |
| OLD | NEW |