diff options
author | sdefresne <sdefresne@chromium.org> | 2014-12-15 15:21:56 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-12-15 23:22:23 +0000 |
commit | cb955cd06650ee281f745b5a86aff7864fe44066 (patch) | |
tree | d663541ca9f25582d5de09be3844285467d404dd /components/webdata_services/web_data_service_wrapper.h | |
parent | 81c98ba5f74cbe9e6f1a12a0b96371b65dd4374e (diff) | |
download | chromium_src-cb955cd06650ee281f745b5a86aff7864fe44066.zip chromium_src-cb955cd06650ee281f745b5a86aff7864fe44066.tar.gz chromium_src-cb955cd06650ee281f745b5a86aff7864fe44066.tar.bz2 |
Introduce new component webdata_services
Move WebDataServiceWrapper into its own component webdata_services so
that the code can be shared with iOS.
The code cannot go into webdata component since it depends on other
components (autofill, password_manager, search_engine, signin) that
depends on webdata (as they implements the WebDataService interface).
BUG=437508
Review URL: https://codereview.chromium.org/777863002
Cr-Commit-Position: refs/heads/master@{#308451}
Diffstat (limited to 'components/webdata_services/web_data_service_wrapper.h')
-rw-r--r-- | components/webdata_services/web_data_service_wrapper.h | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/components/webdata_services/web_data_service_wrapper.h b/components/webdata_services/web_data_service_wrapper.h new file mode 100644 index 0000000..76f5693 --- /dev/null +++ b/components/webdata_services/web_data_service_wrapper.h @@ -0,0 +1,85 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef COMPONENTS_WEBDATA_SERVICES_WEB_DATA_SERVICE_WRAPPER_H_ +#define COMPONENTS_WEBDATA_SERVICES_WEB_DATA_SERVICE_WRAPPER_H_ + +#include <string> + +#include "base/callback_forward.h" +#include "base/macros.h" +#include "base/memory/ref_counted.h" +#include "components/keyed_service/core/keyed_service.h" +#include "sql/init_status.h" + +class KeywordWebDataService; +class TokenWebData; +class WebDatabaseService; + +#if defined(OS_WIN) +class PasswordWebDataService; +#endif + +namespace autofill { +class AutofillWebDataBackend; +class AutofillWebDataService; +} // namespace autofill + +namespace base { +class FilePath; +class MessageLoopProxy; +} // namespace base + +// WebDataServiceWrapper is a KeyedService that owns multiple WebDataServices +// so that they can be associated with a context. +class WebDataServiceWrapper : public KeyedService { + public: + // ErrorType indicates which service encountered an error loading its data. + enum ErrorType { + ERROR_LOADING_AUTOFILL, + ERROR_LOADING_KEYWORD, + ERROR_LOADING_TOKEN, + ERROR_LOADING_PASSWORD, + }; + + // Shows an error message if a loading error occurs. + using ShowErrorCallback = void (*)(ErrorType, sql::InitStatus); + + WebDataServiceWrapper(const base::FilePath& profile_path, + const std::string& application_locale, + const scoped_refptr<base::MessageLoopProxy>& ui_thread, + const scoped_refptr<base::MessageLoopProxy>& db_thread, + ShowErrorCallback show_error_callback); + ~WebDataServiceWrapper() override; + + // For testing. + WebDataServiceWrapper(); + + // KeyedService: + void Shutdown() override; + + // Create the various types of service instances. These methods are virtual + // for testing purpose. + virtual scoped_refptr<autofill::AutofillWebDataService> GetAutofillWebData(); + virtual scoped_refptr<KeywordWebDataService> GetKeywordWebData(); + virtual scoped_refptr<TokenWebData> GetTokenWebData(); +#if defined(OS_WIN) + virtual scoped_refptr<PasswordWebDataService> GetPasswordWebData(); +#endif + + private: + scoped_refptr<WebDatabaseService> web_database_; + + scoped_refptr<autofill::AutofillWebDataService> autofill_web_data_; + scoped_refptr<KeywordWebDataService> keyword_web_data_; + scoped_refptr<TokenWebData> token_web_data_; + +#if defined(OS_WIN) + scoped_refptr<PasswordWebDataService> password_web_data_; +#endif + + DISALLOW_COPY_AND_ASSIGN(WebDataServiceWrapper); +}; + +#endif // COMPONENTS_WEBDATA_SERVICES_WEB_DATA_SERVICE_WRAPPER_H_ |