Componentize component_updater: Copy over test data with executable bit.
[chromium-blink-merge.git] / chrome / browser / webdata / web_data_service_factory.h
blob80b40c1c0d13f8b5fff767214be9abe460689b36
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_WEBDATA_WEB_DATA_SERVICE_FACTORY_H__
6 #define CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_FACTORY_H__
8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/singleton.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "components/keyed_service/content/browser_context_keyed_service_factory.h"
13 #include "components/keyed_service/core/keyed_service.h"
14 #include "components/webdata/common/web_database_service.h"
16 class KeywordWebDataService;
17 class TokenWebData;
19 #if defined(OS_WIN)
20 class PasswordWebDataService;
21 #endif
23 namespace autofill {
24 class AutofillWebDataService;
25 } // namespace autofill
27 // A wrapper of WebDataService so that we can use it as a profile keyed service.
28 class WebDataServiceWrapper : public KeyedService {
29 public:
30 explicit WebDataServiceWrapper(Profile* profile);
32 // For testing.
33 WebDataServiceWrapper();
35 virtual ~WebDataServiceWrapper();
37 // KeyedService:
38 virtual void Shutdown() OVERRIDE;
40 virtual scoped_refptr<autofill::AutofillWebDataService> GetAutofillWebData();
42 virtual scoped_refptr<KeywordWebDataService> GetKeywordWebData();
44 virtual scoped_refptr<TokenWebData> GetTokenWebData();
46 #if defined(OS_WIN)
47 virtual scoped_refptr<PasswordWebDataService> GetPasswordWebData();
48 #endif
50 private:
51 scoped_refptr<WebDatabaseService> web_database_;
53 scoped_refptr<autofill::AutofillWebDataService> autofill_web_data_;
54 scoped_refptr<KeywordWebDataService> keyword_web_data_;
55 scoped_refptr<TokenWebData> token_web_data_;
57 #if defined(OS_WIN)
58 scoped_refptr<PasswordWebDataService> password_web_data_;
59 #endif
61 DISALLOW_COPY_AND_ASSIGN(WebDataServiceWrapper);
64 // Singleton that owns all WebDataServiceWrappers and associates them with
65 // Profiles.
66 class WebDataServiceFactory : public BrowserContextKeyedServiceFactory {
67 public:
68 // Returns the WebDataServiceWrapper associated with the |profile|.
69 static WebDataServiceWrapper* GetForProfile(
70 Profile* profile,
71 Profile::ServiceAccessType access_type);
73 static WebDataServiceWrapper* GetForProfileIfExists(
74 Profile* profile,
75 Profile::ServiceAccessType access_type);
77 // Returns the AutofillWebDataService associated with the |profile|.
78 static scoped_refptr<autofill::AutofillWebDataService>
79 GetAutofillWebDataForProfile(Profile* profile,
80 Profile::ServiceAccessType access_type);
82 // Returns the KeywordWebDataService associated with the |profile|.
83 static scoped_refptr<KeywordWebDataService> GetKeywordWebDataForProfile(
84 Profile* profile,
85 Profile::ServiceAccessType access_type);
87 // Returns the TokenWebData associated with the |profile|.
88 static scoped_refptr<TokenWebData> GetTokenWebDataForProfile(
89 Profile* profile,
90 Profile::ServiceAccessType access_type);
92 #if defined(OS_WIN)
93 // Returns the PasswordWebDataService associated with the |profile|.
94 static scoped_refptr<PasswordWebDataService> GetPasswordWebDataForProfile(
95 Profile* profile,
96 Profile::ServiceAccessType access_type);
97 #endif
99 static WebDataServiceFactory* GetInstance();
101 private:
102 friend struct DefaultSingletonTraits<WebDataServiceFactory>;
104 WebDataServiceFactory();
105 virtual ~WebDataServiceFactory();
107 // |BrowserContextKeyedBaseFactory| methods:
108 virtual content::BrowserContext* GetBrowserContextToUse(
109 content::BrowserContext* context) const OVERRIDE;
110 virtual KeyedService* BuildServiceInstanceFor(
111 content::BrowserContext* profile) const OVERRIDE;
112 virtual bool ServiceIsNULLWhileTesting() const OVERRIDE;
114 DISALLOW_COPY_AND_ASSIGN(WebDataServiceFactory);
117 #endif // CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_FACTORY_H__