| 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 |
| 7 #include "base/android/locale_utils.h" |
| 6 #include "base/logging.h" | 8 #include "base/logging.h" |
| 7 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
| 8 #include "components/autofill/core/browser/webdata/autofill_table.h" | 10 #include "components/autofill/core/browser/webdata/autofill_table.h" |
| 9 #include "components/webdata/common/webdata_constants.h" | 11 #include "components/webdata/common/webdata_constants.h" |
| 10 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
| 11 #include "ui/base/l10n/l10n_util_android.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( | 34 web_database_->AddTable( |
| 34 scoped_ptr<WebDatabaseTable>(new autofill::AutofillTable( | 35 scoped_ptr<WebDatabaseTable>(new autofill::AutofillTable( |
| 35 l10n_util::GetDefaultLocale()))); | 36 base::android::GetDefaultLocale()))); |
| 36 web_database_->LoadDatabase(); | 37 web_database_->LoadDatabase(); |
| 37 | 38 |
| 38 autofill_data_ = new autofill::AutofillWebDataService( | 39 autofill_data_ = new autofill::AutofillWebDataService( |
| 39 web_database_, | 40 web_database_, |
| 40 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), | 41 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), |
| 41 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB), | 42 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB), |
| 42 base::Bind(&DatabaseErrorCallback)); | 43 base::Bind(&DatabaseErrorCallback)); |
| 43 autofill_data_->Init(); | 44 autofill_data_->Init(); |
| 44 } | 45 } |
| 45 | 46 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 if (it == result_map_.end()) { | 119 if (it == result_map_.end()) { |
| 119 LOG(WARNING) << "Received unexpected callback from web data service"; | 120 LOG(WARNING) << "Received unexpected callback from web data service"; |
| 120 return; | 121 return; |
| 121 } | 122 } |
| 122 *(it->second.result) = has_form_data; | 123 *(it->second.result) = has_form_data; |
| 123 it->second.completion->Signal(); | 124 it->second.completion->Signal(); |
| 124 result_map_.erase(h); | 125 result_map_.erase(h); |
| 125 } | 126 } |
| 126 | 127 |
| 127 } // namespace android_webview | 128 } // namespace android_webview |
| OLD | NEW |