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/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" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "chrome/browser/webdata/autofill_profile_syncable_service.h" | 21 #include "chrome/browser/webdata/autofill_profile_syncable_service.h" |
22 #include "chrome/browser/webdata/autofill_table.h" | 22 #include "chrome/browser/webdata/autofill_table.h" |
23 #include "chrome/browser/webdata/keyword_table.h" | 23 #include "chrome/browser/webdata/keyword_table.h" |
24 #include "chrome/browser/webdata/logins_table.h" | 24 #include "chrome/browser/webdata/logins_table.h" |
25 #include "chrome/browser/webdata/token_service_table.h" | 25 #include "chrome/browser/webdata/token_service_table.h" |
26 #include "chrome/browser/webdata/web_apps_table.h" | 26 #include "chrome/browser/webdata/web_apps_table.h" |
27 #include "chrome/browser/webdata/web_database.h" | 27 #include "chrome/browser/webdata/web_database.h" |
28 #include "chrome/browser/webdata/web_intents_table.h" | 28 #include "chrome/browser/webdata/web_intents_table.h" |
29 #include "chrome/common/chrome_constants.h" | 29 #include "chrome/common/chrome_constants.h" |
30 #include "chrome/common/chrome_notification_types.h" | 30 #include "chrome/common/chrome_notification_types.h" |
| 31 #include "chrome/common/form_field_data.h" |
31 #ifdef DEBUG | 32 #ifdef DEBUG |
32 #include "content/public/browser/browser_thread.h" | 33 #include "content/public/browser/browser_thread.h" |
33 #endif | 34 #endif |
34 #include "content/public/browser/notification_details.h" | 35 #include "content/public/browser/notification_details.h" |
35 #include "content/public/browser/notification_service.h" | 36 #include "content/public/browser/notification_service.h" |
36 #include "content/public/browser/notification_source.h" | 37 #include "content/public/browser/notification_source.h" |
37 #include "grit/chromium_strings.h" | 38 #include "grit/chromium_strings.h" |
38 #include "grit/generated_resources.h" | 39 #include "grit/generated_resources.h" |
39 #include "third_party/skia/include/core/SkBitmap.h" | 40 #include "third_party/skia/include/core/SkBitmap.h" |
40 #include "webkit/forms/form_field.h" | |
41 | 41 |
42 //////////////////////////////////////////////////////////////////////////////// | 42 //////////////////////////////////////////////////////////////////////////////// |
43 // | 43 // |
44 // WebDataService implementation. | 44 // WebDataService implementation. |
45 // | 45 // |
46 //////////////////////////////////////////////////////////////////////////////// | 46 //////////////////////////////////////////////////////////////////////////////// |
47 | 47 |
48 using base::Bind; | 48 using base::Bind; |
49 using base::Time; | 49 using base::Time; |
50 using content::BrowserThread; | 50 using content::BrowserThread; |
51 using webkit::forms::FormField; | |
52 using webkit_glue::WebIntentServiceData; | 51 using webkit_glue::WebIntentServiceData; |
53 | 52 |
54 namespace { | 53 namespace { |
55 | 54 |
56 // A task used by WebDataService (for Sync mainly) to inform the | 55 // A task used by WebDataService (for Sync mainly) to inform the |
57 // PersonalDataManager living on the UI thread that it needs to refresh. | 56 // PersonalDataManager living on the UI thread that it needs to refresh. |
58 void NotifyOfMultipleAutofillChangesTask( | 57 void NotifyOfMultipleAutofillChangesTask( |
59 const scoped_refptr<WebDataService>& web_data_service) { | 58 const scoped_refptr<WebDataService>& web_data_service) { |
60 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 59 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
61 | 60 |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 return request->GetHandle(); | 410 return request->GetHandle(); |
412 } | 411 } |
413 | 412 |
414 //////////////////////////////////////////////////////////////////////////////// | 413 //////////////////////////////////////////////////////////////////////////////// |
415 // | 414 // |
416 // Autofill. | 415 // Autofill. |
417 // | 416 // |
418 //////////////////////////////////////////////////////////////////////////////// | 417 //////////////////////////////////////////////////////////////////////////////// |
419 | 418 |
420 void WebDataService::AddFormFields( | 419 void WebDataService::AddFormFields( |
421 const std::vector<FormField>& fields) { | 420 const std::vector<FormFieldData>& fields) { |
422 GenericRequest<std::vector<FormField> >* request = | 421 GenericRequest<std::vector<FormFieldData> >* request = |
423 new GenericRequest<std::vector<FormField> >( | 422 new GenericRequest<std::vector<FormFieldData> >( |
424 this, GetNextRequestHandle(), NULL, fields); | 423 this, GetNextRequestHandle(), NULL, fields); |
425 RegisterRequest(request); | 424 RegisterRequest(request); |
426 ScheduleTask(FROM_HERE, | 425 ScheduleTask(FROM_HERE, |
427 Bind(&WebDataService::AddFormElementsImpl, this, request)); | 426 Bind(&WebDataService::AddFormElementsImpl, this, request)); |
428 } | 427 } |
429 | 428 |
430 WebDataService::Handle WebDataService::GetFormValuesForElementName( | 429 WebDataService::Handle WebDataService::GetFormValuesForElementName( |
431 const string16& name, const string16& prefix, int limit, | 430 const string16& name, const string16& prefix, int limit, |
432 WebDataServiceConsumer* consumer) { | 431 WebDataServiceConsumer* consumer) { |
433 WebDataRequest* request = | 432 WebDataRequest* request = |
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1060 request->RequestComplete(); | 1059 request->RequestComplete(); |
1061 } | 1060 } |
1062 | 1061 |
1063 //////////////////////////////////////////////////////////////////////////////// | 1062 //////////////////////////////////////////////////////////////////////////////// |
1064 // | 1063 // |
1065 // Autofill implementation. | 1064 // Autofill implementation. |
1066 // | 1065 // |
1067 //////////////////////////////////////////////////////////////////////////////// | 1066 //////////////////////////////////////////////////////////////////////////////// |
1068 | 1067 |
1069 void WebDataService::AddFormElementsImpl( | 1068 void WebDataService::AddFormElementsImpl( |
1070 GenericRequest<std::vector<FormField> >* request) { | 1069 GenericRequest<std::vector<FormFieldData> >* request) { |
1071 InitializeDatabaseIfNecessary(); | 1070 InitializeDatabaseIfNecessary(); |
1072 if (db_ && !request->IsCancelled(NULL)) { | 1071 if (db_ && !request->IsCancelled(NULL)) { |
1073 AutofillChangeList changes; | 1072 AutofillChangeList changes; |
1074 if (!db_->GetAutofillTable()->AddFormFieldValues( | 1073 if (!db_->GetAutofillTable()->AddFormFieldValues( |
1075 request->arg(), &changes)) { | 1074 request->arg(), &changes)) { |
1076 NOTREACHED(); | 1075 NOTREACHED(); |
1077 return; | 1076 return; |
1078 } | 1077 } |
1079 request->SetResult( | 1078 request->SetResult( |
1080 new WDResult<AutofillChangeList>(AUTOFILL_CHANGES, changes)); | 1079 new WDResult<AutofillChangeList>(AUTOFILL_CHANGES, changes)); |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1515 } | 1514 } |
1516 | 1515 |
1517 const WDTypedResult* WebDataService::WebDataRequest::GetResult() const { | 1516 const WDTypedResult* WebDataService::WebDataRequest::GetResult() const { |
1518 return result_; | 1517 return result_; |
1519 } | 1518 } |
1520 | 1519 |
1521 void WebDataService::WebDataRequest::RequestComplete() { | 1520 void WebDataService::WebDataRequest::RequestComplete() { |
1522 message_loop_->PostTask(FROM_HERE, Bind(&WebDataService::RequestCompleted, | 1521 message_loop_->PostTask(FROM_HERE, Bind(&WebDataService::RequestCompleted, |
1523 service_.get(), handle_)); | 1522 service_.get(), handle_)); |
1524 } | 1523 } |
OLD | NEW |