Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(299)

Side by Side Diff: components/webdata_services/web_data_service_wrapper.cc

Issue 777863002: Introduce new component webdata_services (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Compile as static_library instead of component Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/webdata_services/web_data_service_wrapper.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 WebDataServiceWrapper::WebDataServiceWrapper() {
26 }
27
28 WebDataServiceWrapper::WebDataServiceWrapper(
29 const base::FilePath& profile_path,
30 const std::string& application_locale,
31 const scoped_refptr<base::MessageLoopProxy>& ui_thread,
32 const scoped_refptr<base::MessageLoopProxy>& db_thread,
33 ShowErrorCallback show_error_callback) {
34 base::FilePath path = profile_path.Append(kWebDataFilename);
35 web_database_ = new WebDatabaseService(path, ui_thread, db_thread);
36
37 // All tables objects that participate in managing the database must
38 // be added here.
39 web_database_->AddTable(scoped_ptr<WebDatabaseTable>(
40 new autofill::AutofillTable(application_locale)));
41 web_database_->AddTable(scoped_ptr<WebDatabaseTable>(new KeywordTable()));
42 // TODO(mdm): We only really need the LoginsTable on Windows for IE7 password
43 // access, but for now, we still create it on all platforms since it deletes
44 // the old logins table. We can remove this after a while, e.g. in M22 or so.
45 web_database_->AddTable(scoped_ptr<WebDatabaseTable>(new LoginsTable()));
46 web_database_->AddTable(
47 scoped_ptr<WebDatabaseTable>(new TokenServiceTable()));
48 web_database_->LoadDatabase();
49
50 autofill_web_data_ = new autofill::AutofillWebDataService(
51 web_database_, ui_thread, db_thread,
52 base::Bind(show_error_callback, ERROR_LOADING_AUTOFILL));
53 autofill_web_data_->Init();
54
55 keyword_web_data_ = new KeywordWebDataService(
56 web_database_, ui_thread,
57 base::Bind(show_error_callback, ERROR_LOADING_KEYWORD));
58 keyword_web_data_->Init();
59
60 token_web_data_ = new TokenWebData(
61 web_database_, ui_thread, db_thread,
62 base::Bind(show_error_callback, ERROR_LOADING_TOKEN));
63 token_web_data_->Init();
64
65 #if defined(OS_WIN)
66 password_web_data_ = new PasswordWebDataService(
67 web_database_, ui_thread,
68 base::Bind(show_error_callback, ERROR_LOADING_PASSWORD));
69 password_web_data_->Init();
70 #endif
71 }
72
73 WebDataServiceWrapper::~WebDataServiceWrapper() {
74 }
75
76 void WebDataServiceWrapper::Shutdown() {
77 autofill_web_data_->ShutdownOnUIThread();
78 keyword_web_data_->ShutdownOnUIThread();
79 token_web_data_->ShutdownOnUIThread();
80
81 #if defined(OS_WIN)
82 password_web_data_->ShutdownOnUIThread();
83 #endif
84
85 web_database_->ShutdownDatabase();
86 }
87
88 scoped_refptr<autofill::AutofillWebDataService>
89 WebDataServiceWrapper::GetAutofillWebData() {
90 return autofill_web_data_.get();
91 }
92
93 scoped_refptr<KeywordWebDataService>
94 WebDataServiceWrapper::GetKeywordWebData() {
95 return keyword_web_data_.get();
96 }
97
98 scoped_refptr<TokenWebData> WebDataServiceWrapper::GetTokenWebData() {
99 return token_web_data_.get();
100 }
101
102 #if defined(OS_WIN)
103 scoped_refptr<PasswordWebDataService>
104 WebDataServiceWrapper::GetPasswordWebData() {
105 return password_web_data_.get();
106 }
107 #endif
OLDNEW
« no previous file with comments | « components/webdata_services/web_data_service_wrapper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698