| 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/macros.h" | 
|   9 #include "base/memory/ref_counted.h" |   9 #include "base/memory/ref_counted.h" | 
|  10 #include "chrome/browser/profiles/profile.h" |  | 
|  11 #include "components/keyed_service/content/browser_context_keyed_service_factory
    .h" |  10 #include "components/keyed_service/content/browser_context_keyed_service_factory
    .h" | 
 |  11 #include "components/keyed_service/core/service_access_type.h" | 
|  12  |  12  | 
|  13 template <typename T> struct DefaultSingletonTraits; |  13 template <typename T> struct DefaultSingletonTraits; | 
|  14 class KeywordWebDataService; |  14 class KeywordWebDataService; | 
 |  15 class Profile; | 
|  15 class TokenWebData; |  16 class TokenWebData; | 
|  16 class WebDataServiceWrapper; |  17 class WebDataServiceWrapper; | 
|  17  |  18  | 
|  18 #if defined(OS_WIN) |  19 #if defined(OS_WIN) | 
|  19 class PasswordWebDataService; |  20 class PasswordWebDataService; | 
|  20 #endif |  21 #endif | 
|  21  |  22  | 
|  22 namespace autofill { |  23 namespace autofill { | 
|  23 class AutofillWebDataBackend; |  | 
|  24 class AutofillWebDataService; |  24 class AutofillWebDataService; | 
|  25 }  // namespace autofill |  25 } | 
|  26  |  26  | 
|  27 // Singleton that owns all WebDataServiceWrappers and associates them with |  27 // Singleton that owns all WebDataServiceWrappers and associates them with | 
|  28 // Profiles. |  28 // Profiles. | 
|  29 class WebDataServiceFactory : public BrowserContextKeyedServiceFactory { |  29 class WebDataServiceFactory : public BrowserContextKeyedServiceFactory { | 
|  30  public: |  30  public: | 
|  31   // Returns the WebDataServiceWrapper associated with the |profile|. |  31   // Returns the WebDataServiceWrapper associated with the |profile|. | 
|  32   static WebDataServiceWrapper* GetForProfile( |  32   static WebDataServiceWrapper* GetForProfile(Profile* profile, | 
|  33       Profile* profile, |  33                                               ServiceAccessType access_type); | 
|  34       Profile::ServiceAccessType access_type); |  | 
|  35  |  34  | 
|  36   static WebDataServiceWrapper* GetForProfileIfExists( |  35   static WebDataServiceWrapper* GetForProfileIfExists( | 
|  37       Profile* profile, |  36       Profile* profile, | 
|  38       Profile::ServiceAccessType access_type); |  37       ServiceAccessType access_type); | 
|  39  |  38  | 
|  40   // Returns the AutofillWebDataService associated with the |profile|. |  39   // Returns the AutofillWebDataService associated with the |profile|. | 
|  41   static scoped_refptr<autofill::AutofillWebDataService> |  40   static scoped_refptr<autofill::AutofillWebDataService> | 
|  42       GetAutofillWebDataForProfile(Profile* profile, |  41   GetAutofillWebDataForProfile(Profile* profile, ServiceAccessType access_type); | 
|  43                                    Profile::ServiceAccessType access_type); |  | 
|  44  |  42  | 
|  45   // Returns the KeywordWebDataService associated with the |profile|. |  43   // Returns the KeywordWebDataService associated with the |profile|. | 
|  46   static scoped_refptr<KeywordWebDataService> GetKeywordWebDataForProfile( |  44   static scoped_refptr<KeywordWebDataService> GetKeywordWebDataForProfile( | 
|  47       Profile* profile, |  45       Profile* profile, | 
|  48       Profile::ServiceAccessType access_type); |  46       ServiceAccessType access_type); | 
|  49  |  47  | 
|  50   // Returns the TokenWebData associated with the |profile|. |  48   // Returns the TokenWebData associated with the |profile|. | 
|  51   static scoped_refptr<TokenWebData> GetTokenWebDataForProfile( |  49   static scoped_refptr<TokenWebData> GetTokenWebDataForProfile( | 
|  52       Profile* profile, |  50       Profile* profile, | 
|  53       Profile::ServiceAccessType access_type); |  51       ServiceAccessType access_type); | 
|  54  |  52  | 
|  55 #if defined(OS_WIN) |  53 #if defined(OS_WIN) | 
|  56   // Returns the PasswordWebDataService associated with the |profile|. |  54   // Returns the PasswordWebDataService associated with the |profile|. | 
|  57   static scoped_refptr<PasswordWebDataService> GetPasswordWebDataForProfile( |  55   static scoped_refptr<PasswordWebDataService> GetPasswordWebDataForProfile( | 
|  58       Profile* profile, |  56       Profile* profile, | 
|  59       Profile::ServiceAccessType access_type); |  57       ServiceAccessType access_type); | 
|  60 #endif |  58 #endif | 
|  61  |  59  | 
|  62   static WebDataServiceFactory* GetInstance(); |  60   static WebDataServiceFactory* GetInstance(); | 
|  63  |  61  | 
|  64  private: |  62  private: | 
|  65   friend struct DefaultSingletonTraits<WebDataServiceFactory>; |  63   friend struct DefaultSingletonTraits<WebDataServiceFactory>; | 
|  66  |  64  | 
|  67   WebDataServiceFactory(); |  65   WebDataServiceFactory(); | 
|  68   ~WebDataServiceFactory() override; |  66   ~WebDataServiceFactory() override; | 
|  69  |  67  | 
|  70   // |BrowserContextKeyedBaseFactory| methods: |  68   // |BrowserContextKeyedBaseFactory| methods: | 
|  71   content::BrowserContext* GetBrowserContextToUse( |  69   content::BrowserContext* GetBrowserContextToUse( | 
|  72       content::BrowserContext* context) const override; |  70       content::BrowserContext* context) const override; | 
|  73   KeyedService* BuildServiceInstanceFor( |  71   KeyedService* BuildServiceInstanceFor( | 
|  74       content::BrowserContext* profile) const override; |  72       content::BrowserContext* profile) const override; | 
|  75   bool ServiceIsNULLWhileTesting() const override; |  73   bool ServiceIsNULLWhileTesting() const override; | 
|  76  |  74  | 
|  77   DISALLOW_COPY_AND_ASSIGN(WebDataServiceFactory); |  75   DISALLOW_COPY_AND_ASSIGN(WebDataServiceFactory); | 
|  78 }; |  76 }; | 
|  79  |  77  | 
|  80 #endif  // CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_FACTORY_H__ |  78 #endif  // CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_FACTORY_H__ | 
| OLD | NEW |