Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "components/webdata_services/web_data_service_wrapper.h" | |
| 6 | |
| 7 #include "base/bind.h" | |
| 8 #include "base/callback.h" | |
| 9 #include "base/files/file_path.h" | |
| 10 #include "base/message_loop/message_loop_proxy.h" | |
| 11 #include "components/autofill/core/browser/webdata/autofill_table.h" | |
| 12 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" | |
| 13 #include "components/password_manager/core/browser/webdata/logins_table.h" | |
| 14 #include "components/search_engines/keyword_table.h" | |
| 15 #include "components/search_engines/keyword_web_data_service.h" | |
| 16 #include "components/signin/core/browser/webdata/token_service_table.h" | |
| 17 #include "components/signin/core/browser/webdata/token_web_data.h" | |
| 18 #include "components/webdata/common/web_database_service.h" | |
| 19 #include "components/webdata/common/webdata_constants.h" | |
| 20 | |
| 21 #if defined(OS_WIN) | |
| 22 #include "components/password_manager/core/browser/webdata/password_web_data_ser vice_win.h" | |
| 23 #endif | |
| 24 | |
| 25 using autofill::AutofillTable; | |
|
Peter Kasting
2014/12/05 21:47:56
Nit: Avoid using directives unless they noticeably
sdefresne
2014/12/08 10:54:42
Done.
| |
| 26 using autofill::AutofillWebDataService; | |
| 27 | |
| 28 WebDataServiceWrapper::WebDataServiceWrapper() { | |
| 29 } | |
| 30 | |
| 31 WebDataServiceWrapper::WebDataServiceWrapper( | |
| 32 const base::FilePath& profile_path, | |
| 33 const std::string& application_locale, | |
| 34 const scoped_refptr<base::MessageLoopProxy>& ui_thread, | |
| 35 const scoped_refptr<base::MessageLoopProxy>& db_thread, | |
| 36 ShowErrorCallback show_error_callback) { | |
| 37 base::FilePath path = profile_path.Append(kWebDataFilename); | |
| 38 web_database_ = new WebDatabaseService(path, ui_thread, db_thread); | |
| 39 | |
| 40 // All tables objects that participate in managing the database must | |
| 41 // be added here. | |
| 42 web_database_->AddTable( | |
| 43 scoped_ptr<WebDatabaseTable>(new AutofillTable(application_locale))); | |
| 44 web_database_->AddTable(scoped_ptr<WebDatabaseTable>(new KeywordTable())); | |
| 45 // TODO(mdm): We only really need the LoginsTable on Windows for IE7 password | |
| 46 // access, but for now, we still create it on all platforms since it deletes | |
| 47 // the old logins table. We can remove this after a while, e.g. in M22 or so. | |
|
Peter Kasting
2014/12/05 21:47:56
This milestone is long in the past. Can we obey i
sdefresne
2014/12/08 10:54:42
I'd prefer to leave this for a separate CL in orde
| |
| 48 web_database_->AddTable(scoped_ptr<WebDatabaseTable>(new LoginsTable())); | |
| 49 web_database_->AddTable( | |
| 50 scoped_ptr<WebDatabaseTable>(new TokenServiceTable())); | |
| 51 web_database_->LoadDatabase(); | |
| 52 | |
| 53 autofill_web_data_ = new AutofillWebDataService( | |
| 54 web_database_, ui_thread, db_thread, | |
| 55 base::Bind(show_error_callback, ERROR_DB_AUTOFILL_WEB_DATA)); | |
| 56 autofill_web_data_->Init(); | |
| 57 | |
| 58 keyword_web_data_ = new KeywordWebDataService( | |
| 59 web_database_, ui_thread, | |
| 60 base::Bind(show_error_callback, ERROR_DB_KEYWORD_WEB_DATA)); | |
| 61 keyword_web_data_->Init(); | |
| 62 | |
| 63 token_web_data_ = new TokenWebData( | |
| 64 web_database_, ui_thread, db_thread, | |
| 65 base::Bind(show_error_callback, ERROR_DB_TOKEN_WEB_DATA)); | |
| 66 token_web_data_->Init(); | |
| 67 | |
| 68 #if defined(OS_WIN) | |
| 69 password_web_data_ = new PasswordWebDataService( | |
| 70 web_database_, ui_thread, | |
| 71 base::Bind(show_error_callback, ERROR_DB_PASSWORD_WEB_DATA)); | |
| 72 password_web_data_->Init(); | |
| 73 #endif | |
| 74 } | |
| 75 | |
| 76 WebDataServiceWrapper::~WebDataServiceWrapper() { | |
| 77 } | |
| 78 | |
| 79 void WebDataServiceWrapper::Shutdown() { | |
| 80 autofill_web_data_->ShutdownOnUIThread(); | |
| 81 keyword_web_data_->ShutdownOnUIThread(); | |
| 82 token_web_data_->ShutdownOnUIThread(); | |
| 83 | |
| 84 #if defined(OS_WIN) | |
| 85 password_web_data_->ShutdownOnUIThread(); | |
| 86 #endif | |
| 87 | |
| 88 web_database_->ShutdownDatabase(); | |
| 89 } | |
| 90 | |
| 91 scoped_refptr<AutofillWebDataService> | |
| 92 WebDataServiceWrapper::GetAutofillWebData() { | |
| 93 return autofill_web_data_.get(); | |
| 94 } | |
| 95 | |
| 96 scoped_refptr<KeywordWebDataService> | |
| 97 WebDataServiceWrapper::GetKeywordWebData() { | |
| 98 return keyword_web_data_.get(); | |
| 99 } | |
| 100 | |
| 101 scoped_refptr<TokenWebData> WebDataServiceWrapper::GetTokenWebData() { | |
| 102 return token_web_data_.get(); | |
| 103 } | |
| 104 | |
| 105 #if defined(OS_WIN) | |
| 106 scoped_refptr<PasswordWebDataService> | |
| 107 WebDataServiceWrapper::GetPasswordWebData() { | |
| 108 return password_web_data_.get(); | |
| 109 } | |
| 110 #endif | |
| OLD | NEW |