[email protected] | d07edd4 | 2012-05-14 23:49:46 | [diff] [blame] | 1 | // Copyright (c) 2012 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 | |||||
tfarina | bf215a6f | 2015-06-15 22:24:05 | [diff] [blame] | 5 | #ifndef CHROME_BROWSER_WEB_DATA_SERVICE_FACTORY_H_ |
6 | #define CHROME_BROWSER_WEB_DATA_SERVICE_FACTORY_H_ | ||||
[email protected] | d07edd4 | 2012-05-14 23:49:46 | [diff] [blame] | 7 | |
sdefresne | e9ea3c2 | 2015-01-10 10:10:04 | [diff] [blame] | 8 | #include "base/macros.h" |
[email protected] | 78f1d9b | 2013-03-20 09:43:18 | [diff] [blame] | 9 | #include "base/memory/ref_counted.h" |
avi | 664c07b | 2015-12-26 02:18:31 | [diff] [blame] | 10 | #include "build/build_config.h" |
[email protected] | 540380fc | 2014-03-14 10:10:34 | [diff] [blame] | 11 | #include "components/keyed_service/content/browser_context_keyed_service_factory.h" |
sdefresne | e9ea3c2 | 2015-01-10 10:10:04 | [diff] [blame] | 12 | #include "components/keyed_service/core/service_access_type.h" |
[email protected] | e2b3105 | 2013-03-25 01:49:37 | [diff] [blame] | 13 | |
olli.raula | 36aa8be | 2015-09-10 11:14:22 | [diff] [blame] | 14 | namespace base { |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 15 | template <typename T> |
16 | struct DefaultSingletonTraits; | ||||
olli.raula | 36aa8be | 2015-09-10 11:14:22 | [diff] [blame] | 17 | } |
18 | |||||
[email protected] | 37b32460 | 2014-07-02 07:30:49 | [diff] [blame] | 19 | class KeywordWebDataService; |
sdefresne | e9ea3c2 | 2015-01-10 10:10:04 | [diff] [blame] | 20 | class Profile; |
[email protected] | b69d631 | 2013-05-27 21:07:36 | [diff] [blame] | 21 | class TokenWebData; |
sdefresne | cb955cd | 2014-12-15 23:21:56 | [diff] [blame] | 22 | class WebDataServiceWrapper; |
[email protected] | bd386e6 | 2014-07-09 22:17:06 | [diff] [blame] | 23 | |
gogerald | 7947209 | 2017-04-27 15:38:16 | [diff] [blame] | 24 | namespace payments { |
25 | class PaymentManifestWebDataService; | ||||
26 | } | ||||
gogerald | 7947209 | 2017-04-27 15:38:16 | [diff] [blame] | 27 | |
[email protected] | e217c563 | 2013-04-12 19:11:48 | [diff] [blame] | 28 | namespace autofill { |
29 | class AutofillWebDataService; | ||||
sdefresne | e9ea3c2 | 2015-01-10 10:10:04 | [diff] [blame] | 30 | } |
[email protected] | e217c563 | 2013-04-12 19:11:48 | [diff] [blame] | 31 | |
[email protected] | 78f1d9b | 2013-03-20 09:43:18 | [diff] [blame] | 32 | // Singleton that owns all WebDataServiceWrappers and associates them with |
33 | // Profiles. | ||||
[email protected] | f1484c5 | 2013-05-22 23:25:44 | [diff] [blame] | 34 | class WebDataServiceFactory : public BrowserContextKeyedServiceFactory { |
[email protected] | d07edd4 | 2012-05-14 23:49:46 | [diff] [blame] | 35 | public: |
[email protected] | 34b5946 | 2013-12-03 14:08:32 | [diff] [blame] | 36 | // Returns the WebDataServiceWrapper associated with the |profile|. |
sdefresne | e9ea3c2 | 2015-01-10 10:10:04 | [diff] [blame] | 37 | static WebDataServiceWrapper* GetForProfile(Profile* profile, |
38 | ServiceAccessType access_type); | ||||
[email protected] | d07edd4 | 2012-05-14 23:49:46 | [diff] [blame] | 39 | |
[email protected] | e2b3105 | 2013-03-25 01:49:37 | [diff] [blame] | 40 | static WebDataServiceWrapper* GetForProfileIfExists( |
[email protected] | 34b5946 | 2013-12-03 14:08:32 | [diff] [blame] | 41 | Profile* profile, |
sdefresne | e9ea3c2 | 2015-01-10 10:10:04 | [diff] [blame] | 42 | ServiceAccessType access_type); |
[email protected] | 34b5946 | 2013-12-03 14:08:32 | [diff] [blame] | 43 | |
44 | // Returns the AutofillWebDataService associated with the |profile|. | ||||
45 | static scoped_refptr<autofill::AutofillWebDataService> | ||||
sdefresne | e9ea3c2 | 2015-01-10 10:10:04 | [diff] [blame] | 46 | GetAutofillWebDataForProfile(Profile* profile, ServiceAccessType access_type); |
[email protected] | dd3c53f | 2013-03-14 02:59:41 | [diff] [blame] | 47 | |
Florian Uunk | 75c22c9 | 2018-06-25 12:44:10 | [diff] [blame] | 48 | // Returns the account-scoped AutofillWebDataService associated with the |
49 | // |profile|. | ||||
50 | static scoped_refptr<autofill::AutofillWebDataService> | ||||
51 | GetAutofillWebDataForAccount(Profile* profile, ServiceAccessType access_type); | ||||
52 | |||||
[email protected] | 37b32460 | 2014-07-02 07:30:49 | [diff] [blame] | 53 | // Returns the KeywordWebDataService associated with the |profile|. |
[email protected] | bd386e6 | 2014-07-09 22:17:06 | [diff] [blame] | 54 | static scoped_refptr<KeywordWebDataService> GetKeywordWebDataForProfile( |
55 | Profile* profile, | ||||
sdefresne | e9ea3c2 | 2015-01-10 10:10:04 | [diff] [blame] | 56 | ServiceAccessType access_type); |
[email protected] | 37b32460 | 2014-07-02 07:30:49 | [diff] [blame] | 57 | |
[email protected] | 1be4efd | 2014-01-09 12:43:44 | [diff] [blame] | 58 | // Returns the TokenWebData associated with the |profile|. |
[email protected] | bd386e6 | 2014-07-09 22:17:06 | [diff] [blame] | 59 | static scoped_refptr<TokenWebData> GetTokenWebDataForProfile( |
60 | Profile* profile, | ||||
sdefresne | e9ea3c2 | 2015-01-10 10:10:04 | [diff] [blame] | 61 | ServiceAccessType access_type); |
[email protected] | 1be4efd | 2014-01-09 12:43:44 | [diff] [blame] | 62 | |
gogerald | 7947209 | 2017-04-27 15:38:16 | [diff] [blame] | 63 | static scoped_refptr<payments::PaymentManifestWebDataService> |
64 | GetPaymentManifestWebDataForProfile(Profile* profile, | ||||
65 | ServiceAccessType access_type); | ||||
gogerald | 7947209 | 2017-04-27 15:38:16 | [diff] [blame] | 66 | |
[email protected] | d07edd4 | 2012-05-14 23:49:46 | [diff] [blame] | 67 | static WebDataServiceFactory* GetInstance(); |
68 | |||||
69 | private: | ||||
olli.raula | 36aa8be | 2015-09-10 11:14:22 | [diff] [blame] | 70 | friend struct base::DefaultSingletonTraits<WebDataServiceFactory>; |
[email protected] | d07edd4 | 2012-05-14 23:49:46 | [diff] [blame] | 71 | |
72 | WebDataServiceFactory(); | ||||
Daniel Cheng | a542fca | 2014-10-21 09:51:29 | [diff] [blame] | 73 | ~WebDataServiceFactory() override; |
[email protected] | d07edd4 | 2012-05-14 23:49:46 | [diff] [blame] | 74 | |
Henrique Nakashima | 9745124 | 2019-04-29 16:14:28 | [diff] [blame] | 75 | // |BrowserContextKeyedServiceFactory| methods: |
Daniel Cheng | a542fca | 2014-10-21 09:51:29 | [diff] [blame] | 76 | content::BrowserContext* GetBrowserContextToUse( |
mostynb | fb66cb4f | 2014-10-07 09:15:42 | [diff] [blame] | 77 | content::BrowserContext* context) const override; |
Daniel Cheng | a542fca | 2014-10-21 09:51:29 | [diff] [blame] | 78 | KeyedService* BuildServiceInstanceFor( |
mostynb | fb66cb4f | 2014-10-07 09:15:42 | [diff] [blame] | 79 | content::BrowserContext* profile) const override; |
Daniel Cheng | a542fca | 2014-10-21 09:51:29 | [diff] [blame] | 80 | bool ServiceIsNULLWhileTesting() const override; |
[email protected] | 78f1d9b | 2013-03-20 09:43:18 | [diff] [blame] | 81 | |
82 | DISALLOW_COPY_AND_ASSIGN(WebDataServiceFactory); | ||||
[email protected] | d07edd4 | 2012-05-14 23:49:46 | [diff] [blame] | 83 | }; |
84 | |||||
tfarina | bf215a6f | 2015-06-15 22:24:05 | [diff] [blame] | 85 | #endif // CHROME_BROWSER_WEB_DATA_SERVICE_FACTORY_H_ |