| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "android_webview/browser/aw_form_database_service.h" | 5 #include "android_webview/browser/aw_form_database_service.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/ptr_util.h" |
| 8 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
| 9 #include "components/autofill/core/browser/webdata/autofill_table.h" | 10 #include "components/autofill/core/browser/webdata/autofill_table.h" |
| 10 #include "components/webdata/common/webdata_constants.h" | 11 #include "components/webdata/common/webdata_constants.h" |
| 11 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
| 12 | 13 |
| 13 using base::WaitableEvent; | 14 using base::WaitableEvent; |
| 14 using content::BrowserThread; | 15 using content::BrowserThread; |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| 18 // Callback to handle database error. It seems chrome uses this to | 19 // Callback to handle database error. It seems chrome uses this to |
| 19 // display an error dialog box only. | 20 // display an error dialog box only. |
| 20 void DatabaseErrorCallback(sql::InitStatus status) { | 21 void DatabaseErrorCallback(sql::InitStatus status) { |
| 21 LOG(WARNING) << "initializing autocomplete database failed"; | 22 LOG(WARNING) << "initializing autocomplete database failed"; |
| 22 } | 23 } |
| 23 | 24 |
| 24 } // namespace | 25 } // namespace |
| 25 | 26 |
| 26 namespace android_webview { | 27 namespace android_webview { |
| 27 | 28 |
| 28 AwFormDatabaseService::AwFormDatabaseService(const base::FilePath path) { | 29 AwFormDatabaseService::AwFormDatabaseService(const base::FilePath path) { |
| 29 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 30 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 30 web_database_ = new WebDatabaseService(path.Append(kWebDataFilename), | 31 web_database_ = new WebDatabaseService(path.Append(kWebDataFilename), |
| 31 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), | 32 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), |
| 32 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB)); | 33 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB)); |
| 33 web_database_->AddTable(make_scoped_ptr(new autofill::AutofillTable)); | 34 web_database_->AddTable(base::WrapUnique(new autofill::AutofillTable)); |
| 34 web_database_->LoadDatabase(); | 35 web_database_->LoadDatabase(); |
| 35 | 36 |
| 36 autofill_data_ = new autofill::AutofillWebDataService( | 37 autofill_data_ = new autofill::AutofillWebDataService( |
| 37 web_database_, | 38 web_database_, |
| 38 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), | 39 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), |
| 39 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB), | 40 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB), |
| 40 base::Bind(&DatabaseErrorCallback)); | 41 base::Bind(&DatabaseErrorCallback)); |
| 41 autofill_data_->Init(); | 42 autofill_data_->Init(); |
| 42 } | 43 } |
| 43 | 44 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 if (it == result_map_.end()) { | 118 if (it == result_map_.end()) { |
| 118 LOG(WARNING) << "Received unexpected callback from web data service"; | 119 LOG(WARNING) << "Received unexpected callback from web data service"; |
| 119 return; | 120 return; |
| 120 } | 121 } |
| 121 *(it->second.result) = has_form_data; | 122 *(it->second.result) = has_form_data; |
| 122 it->second.completion->Signal(); | 123 it->second.completion->Signal(); |
| 123 result_map_.erase(h); | 124 result_map_.erase(h); |
| 124 } | 125 } |
| 125 | 126 |
| 126 } // namespace android_webview | 127 } // namespace android_webview |
| OLD | NEW |