[M73 Dev][EFL] Disable VizDisplayCompositor for EFL port
[platform/framework/web/chromium-efl.git] / components / webdata_services / web_data_service_wrapper.h
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 #ifndef COMPONENTS_WEBDATA_SERVICES_WEB_DATA_SERVICE_WRAPPER_H_
6 #define COMPONENTS_WEBDATA_SERVICES_WEB_DATA_SERVICE_WRAPPER_H_
7
8 #include <string>
9
10 #include "base/callback_forward.h"
11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h"
13 #include "build/build_config.h"
14 #include "components/keyed_service/core/keyed_service.h"
15 #include "components/sync/model/syncable_service.h"
16 #include "sql/init_status.h"
17
18 class KeywordWebDataService;
19 class TokenWebData;
20 class WebDatabaseService;
21
22 #if !defined(OS_IOS)
23 namespace payments {
24 class PaymentManifestWebDataService;
25 }  // namespace payments
26 #endif
27
28 namespace autofill {
29 class AutofillWebDataService;
30 }  // namespace autofill
31
32 namespace base {
33 class FilePath;
34 class SingleThreadTaskRunner;
35 }  // namespace base
36
37 // WebDataServiceWrapper is a KeyedService that owns multiple WebDataServices
38 // so that they can be associated with a context.
39 class WebDataServiceWrapper : public KeyedService {
40  public:
41   // ErrorType indicates which service encountered an error loading its data.
42   enum ErrorType {
43     ERROR_LOADING_AUTOFILL,
44     ERROR_LOADING_ACCOUNT_AUTOFILL,
45     ERROR_LOADING_KEYWORD,
46     ERROR_LOADING_TOKEN,
47     ERROR_LOADING_PASSWORD,
48     ERROR_LOADING_PAYMENT_MANIFEST,
49   };
50
51   // Shows an error message if a loading error occurs.
52   // |error_type| shows which service encountered an error while loading.
53   // |init_status| is the returned status of initializing the underlying
54   // database.
55   // |diagnostics| contains information about the underlying database
56   // which can help in identifying the cause of the error.
57   using ShowErrorCallback =
58       base::RepeatingCallback<void(ErrorType error_type,
59                                    sql::InitStatus init_status,
60                                    const std::string& diagnostics)>;
61
62   // Constructor for WebDataServiceWrapper that initializes the different
63   // WebDataServices and starts the synchronization services using |flare|.
64   // Since |flare| will be copied and called multiple times, it cannot bind
65   // values using base::Owned nor base::Passed; it should only bind simple or
66   // refcounted types.
67   WebDataServiceWrapper(
68       const base::FilePath& context_path,
69       const std::string& application_locale,
70       const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner,
71       const syncer::SyncableService::StartSyncFlare& flare,
72       const ShowErrorCallback& show_error_callback);
73
74   ~WebDataServiceWrapper() override;
75
76   // KeyedService:
77   void Shutdown() override;
78
79   // Create the various types of service instances.  These methods are virtual
80   // for testing purpose.
81   virtual scoped_refptr<autofill::AutofillWebDataService>
82   GetProfileAutofillWebData();
83   virtual scoped_refptr<autofill::AutofillWebDataService>
84   GetAccountAutofillWebData();
85   virtual scoped_refptr<KeywordWebDataService> GetKeywordWebData();
86   virtual scoped_refptr<TokenWebData> GetTokenWebData();
87 #if !defined(OS_IOS)
88   virtual scoped_refptr<payments::PaymentManifestWebDataService>
89   GetPaymentManifestWebData();
90 #endif
91
92  protected:
93   // For testing.
94   WebDataServiceWrapper();
95
96  private:
97   scoped_refptr<WebDatabaseService> profile_database_;
98   scoped_refptr<WebDatabaseService> account_database_;
99
100   scoped_refptr<autofill::AutofillWebDataService> profile_autofill_web_data_;
101   scoped_refptr<autofill::AutofillWebDataService> account_autofill_web_data_;
102   scoped_refptr<KeywordWebDataService> keyword_web_data_;
103   scoped_refptr<TokenWebData> token_web_data_;
104
105 #if !defined(OS_IOS)
106   scoped_refptr<payments::PaymentManifestWebDataService>
107       payment_manifest_web_data_;
108 #endif
109
110   DISALLOW_COPY_AND_ASSIGN(WebDataServiceWrapper);
111 };
112
113 #endif  // COMPONENTS_WEBDATA_SERVICES_WEB_DATA_SERVICE_WRAPPER_H_