Put screenshot.py back to work
[chromium-blink-merge.git] / components / webdata_services / web_data_service_wrapper.h
blob76f5693352ef63e0658c0f1ba90eddd4ce6d27b9
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.
5 #ifndef COMPONENTS_WEBDATA_SERVICES_WEB_DATA_SERVICE_WRAPPER_H_
6 #define COMPONENTS_WEBDATA_SERVICES_WEB_DATA_SERVICE_WRAPPER_H_
8 #include <string>
10 #include "base/callback_forward.h"
11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h"
13 #include "components/keyed_service/core/keyed_service.h"
14 #include "sql/init_status.h"
16 class KeywordWebDataService;
17 class TokenWebData;
18 class WebDatabaseService;
20 #if defined(OS_WIN)
21 class PasswordWebDataService;
22 #endif
24 namespace autofill {
25 class AutofillWebDataBackend;
26 class AutofillWebDataService;
27 } // namespace autofill
29 namespace base {
30 class FilePath;
31 class MessageLoopProxy;
32 } // namespace base
34 // WebDataServiceWrapper is a KeyedService that owns multiple WebDataServices
35 // so that they can be associated with a context.
36 class WebDataServiceWrapper : public KeyedService {
37 public:
38 // ErrorType indicates which service encountered an error loading its data.
39 enum ErrorType {
40 ERROR_LOADING_AUTOFILL,
41 ERROR_LOADING_KEYWORD,
42 ERROR_LOADING_TOKEN,
43 ERROR_LOADING_PASSWORD,
46 // Shows an error message if a loading error occurs.
47 using ShowErrorCallback = void (*)(ErrorType, sql::InitStatus);
49 WebDataServiceWrapper(const base::FilePath& profile_path,
50 const std::string& application_locale,
51 const scoped_refptr<base::MessageLoopProxy>& ui_thread,
52 const scoped_refptr<base::MessageLoopProxy>& db_thread,
53 ShowErrorCallback show_error_callback);
54 ~WebDataServiceWrapper() override;
56 // For testing.
57 WebDataServiceWrapper();
59 // KeyedService:
60 void Shutdown() override;
62 // Create the various types of service instances. These methods are virtual
63 // for testing purpose.
64 virtual scoped_refptr<autofill::AutofillWebDataService> GetAutofillWebData();
65 virtual scoped_refptr<KeywordWebDataService> GetKeywordWebData();
66 virtual scoped_refptr<TokenWebData> GetTokenWebData();
67 #if defined(OS_WIN)
68 virtual scoped_refptr<PasswordWebDataService> GetPasswordWebData();
69 #endif
71 private:
72 scoped_refptr<WebDatabaseService> web_database_;
74 scoped_refptr<autofill::AutofillWebDataService> autofill_web_data_;
75 scoped_refptr<KeywordWebDataService> keyword_web_data_;
76 scoped_refptr<TokenWebData> token_web_data_;
78 #if defined(OS_WIN)
79 scoped_refptr<PasswordWebDataService> password_web_data_;
80 #endif
82 DISALLOW_COPY_AND_ASSIGN(WebDataServiceWrapper);
85 #endif // COMPONENTS_WEBDATA_SERVICES_WEB_DATA_SERVICE_WRAPPER_H_