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.
5 #ifndef CHROME_BROWSER_WEB_DATA_SERVICE_FACTORY_H_
6 #define CHROME_BROWSER_WEB_DATA_SERVICE_FACTORY_H_
8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h"
10 #include "components/keyed_service/content/browser_context_keyed_service_factory.h"
11 #include "components/keyed_service/core/service_access_type.h"
14 template <typename T
> struct DefaultSingletonTraits
;
17 class KeywordWebDataService
;
20 class WebDataServiceWrapper
;
23 class PasswordWebDataService
;
27 class AutofillWebDataService
;
30 // Singleton that owns all WebDataServiceWrappers and associates them with
32 class WebDataServiceFactory
: public BrowserContextKeyedServiceFactory
{
34 // Returns the WebDataServiceWrapper associated with the |profile|.
35 static WebDataServiceWrapper
* GetForProfile(Profile
* profile
,
36 ServiceAccessType access_type
);
38 static WebDataServiceWrapper
* GetForProfileIfExists(
40 ServiceAccessType access_type
);
42 // Returns the AutofillWebDataService associated with the |profile|.
43 static scoped_refptr
<autofill::AutofillWebDataService
>
44 GetAutofillWebDataForProfile(Profile
* profile
, ServiceAccessType access_type
);
46 // Returns the KeywordWebDataService associated with the |profile|.
47 static scoped_refptr
<KeywordWebDataService
> GetKeywordWebDataForProfile(
49 ServiceAccessType access_type
);
51 // Returns the TokenWebData associated with the |profile|.
52 static scoped_refptr
<TokenWebData
> GetTokenWebDataForProfile(
54 ServiceAccessType access_type
);
57 // Returns the PasswordWebDataService associated with the |profile|.
58 static scoped_refptr
<PasswordWebDataService
> GetPasswordWebDataForProfile(
60 ServiceAccessType access_type
);
63 static WebDataServiceFactory
* GetInstance();
66 friend struct base::DefaultSingletonTraits
<WebDataServiceFactory
>;
68 WebDataServiceFactory();
69 ~WebDataServiceFactory() override
;
71 // |BrowserContextKeyedBaseFactory| methods:
72 content::BrowserContext
* GetBrowserContextToUse(
73 content::BrowserContext
* context
) const override
;
74 KeyedService
* BuildServiceInstanceFor(
75 content::BrowserContext
* profile
) const override
;
76 bool ServiceIsNULLWhileTesting() const override
;
78 DISALLOW_COPY_AND_ASSIGN(WebDataServiceFactory
);
81 #endif // CHROME_BROWSER_WEB_DATA_SERVICE_FACTORY_H_