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"
13 template <typename T
> struct DefaultSingletonTraits
;
14 class KeywordWebDataService
;
17 class WebDataServiceWrapper
;
20 class PasswordWebDataService
;
24 class AutofillWebDataService
;
27 // Singleton that owns all WebDataServiceWrappers and associates them with
29 class WebDataServiceFactory
: public BrowserContextKeyedServiceFactory
{
31 // Returns the WebDataServiceWrapper associated with the |profile|.
32 static WebDataServiceWrapper
* GetForProfile(Profile
* profile
,
33 ServiceAccessType access_type
);
35 static WebDataServiceWrapper
* GetForProfileIfExists(
37 ServiceAccessType access_type
);
39 // Returns the AutofillWebDataService associated with the |profile|.
40 static scoped_refptr
<autofill::AutofillWebDataService
>
41 GetAutofillWebDataForProfile(Profile
* profile
, ServiceAccessType access_type
);
43 // Returns the KeywordWebDataService associated with the |profile|.
44 static scoped_refptr
<KeywordWebDataService
> GetKeywordWebDataForProfile(
46 ServiceAccessType access_type
);
48 // Returns the TokenWebData associated with the |profile|.
49 static scoped_refptr
<TokenWebData
> GetTokenWebDataForProfile(
51 ServiceAccessType access_type
);
54 // Returns the PasswordWebDataService associated with the |profile|.
55 static scoped_refptr
<PasswordWebDataService
> GetPasswordWebDataForProfile(
57 ServiceAccessType access_type
);
60 static WebDataServiceFactory
* GetInstance();
63 friend struct DefaultSingletonTraits
<WebDataServiceFactory
>;
65 WebDataServiceFactory();
66 ~WebDataServiceFactory() override
;
68 // |BrowserContextKeyedBaseFactory| methods:
69 content::BrowserContext
* GetBrowserContextToUse(
70 content::BrowserContext
* context
) const override
;
71 KeyedService
* BuildServiceInstanceFor(
72 content::BrowserContext
* profile
) const override
;
73 bool ServiceIsNULLWhileTesting() const override
;
75 DISALLOW_COPY_AND_ASSIGN(WebDataServiceFactory
);
78 #endif // CHROME_BROWSER_WEB_DATA_SERVICE_FACTORY_H_