OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_FACTORY_H__ | 5 #ifndef CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_FACTORY_H__ |
6 #define CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_FACTORY_H__ | 6 #define CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_FACTORY_H__ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/singleton.h" | |
11 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
12 #include "components/keyed_service/content/browser_context_keyed_service_factory
.h" | 11 #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" | |
15 | 12 |
| 13 template <typename T> struct DefaultSingletonTraits; |
16 class KeywordWebDataService; | 14 class KeywordWebDataService; |
17 class TokenWebData; | 15 class TokenWebData; |
| 16 class WebDataServiceWrapper; |
18 | 17 |
19 #if defined(OS_WIN) | 18 #if defined(OS_WIN) |
20 class PasswordWebDataService; | 19 class PasswordWebDataService; |
21 #endif | 20 #endif |
22 | 21 |
23 namespace autofill { | 22 namespace autofill { |
| 23 class AutofillWebDataBackend; |
24 class AutofillWebDataService; | 24 class AutofillWebDataService; |
25 } // namespace autofill | 25 } // namespace autofill |
26 | 26 |
27 // A wrapper of WebDataService so that we can use it as a profile keyed service. | 27 // Initialize syncable services on database thread. |
28 class WebDataServiceWrapper : public KeyedService { | 28 // (visible for testing) |
29 public: | 29 void InitSyncableServicesOnDBThread( |
30 explicit WebDataServiceWrapper(Profile* profile); | 30 scoped_refptr<autofill::AutofillWebDataService> autofill_web_data, |
31 | 31 const base::FilePath& profile_path, |
32 // For testing. | 32 const std::string& app_locale, |
33 WebDataServiceWrapper(); | 33 autofill::AutofillWebDataBackend* autofill_backend); |
34 | |
35 ~WebDataServiceWrapper() override; | |
36 | |
37 // KeyedService: | |
38 void Shutdown() override; | |
39 | |
40 virtual scoped_refptr<autofill::AutofillWebDataService> GetAutofillWebData(); | |
41 | |
42 virtual scoped_refptr<KeywordWebDataService> GetKeywordWebData(); | |
43 | |
44 virtual scoped_refptr<TokenWebData> GetTokenWebData(); | |
45 | |
46 #if defined(OS_WIN) | |
47 virtual scoped_refptr<PasswordWebDataService> GetPasswordWebData(); | |
48 #endif | |
49 | |
50 private: | |
51 scoped_refptr<WebDatabaseService> web_database_; | |
52 | |
53 scoped_refptr<autofill::AutofillWebDataService> autofill_web_data_; | |
54 scoped_refptr<KeywordWebDataService> keyword_web_data_; | |
55 scoped_refptr<TokenWebData> token_web_data_; | |
56 | |
57 #if defined(OS_WIN) | |
58 scoped_refptr<PasswordWebDataService> password_web_data_; | |
59 #endif | |
60 | |
61 DISALLOW_COPY_AND_ASSIGN(WebDataServiceWrapper); | |
62 }; | |
63 | 34 |
64 // Singleton that owns all WebDataServiceWrappers and associates them with | 35 // Singleton that owns all WebDataServiceWrappers and associates them with |
65 // Profiles. | 36 // Profiles. |
66 class WebDataServiceFactory : public BrowserContextKeyedServiceFactory { | 37 class WebDataServiceFactory : public BrowserContextKeyedServiceFactory { |
67 public: | 38 public: |
68 // Returns the WebDataServiceWrapper associated with the |profile|. | 39 // Returns the WebDataServiceWrapper associated with the |profile|. |
69 static WebDataServiceWrapper* GetForProfile( | 40 static WebDataServiceWrapper* GetForProfile( |
70 Profile* profile, | 41 Profile* profile, |
71 Profile::ServiceAccessType access_type); | 42 Profile::ServiceAccessType access_type); |
72 | 43 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 content::BrowserContext* GetBrowserContextToUse( | 79 content::BrowserContext* GetBrowserContextToUse( |
109 content::BrowserContext* context) const override; | 80 content::BrowserContext* context) const override; |
110 KeyedService* BuildServiceInstanceFor( | 81 KeyedService* BuildServiceInstanceFor( |
111 content::BrowserContext* profile) const override; | 82 content::BrowserContext* profile) const override; |
112 bool ServiceIsNULLWhileTesting() const override; | 83 bool ServiceIsNULLWhileTesting() const override; |
113 | 84 |
114 DISALLOW_COPY_AND_ASSIGN(WebDataServiceFactory); | 85 DISALLOW_COPY_AND_ASSIGN(WebDataServiceFactory); |
115 }; | 86 }; |
116 | 87 |
117 #endif // CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_FACTORY_H__ | 88 #endif // CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_FACTORY_H__ |
OLD | NEW |