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_PASSWORD_MANAGER_PASSWORD_STORE_FACTORY_H_ | 5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_FACTORY_H_ |
6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_FACTORY_H_ | 6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_FACTORY_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 typedef int LocalProfileId; | 25 typedef int LocalProfileId; |
26 #endif | 26 #endif |
27 | 27 |
28 // A wrapper of PasswordStore so we can use it as a profiled keyed service. | 28 // A wrapper of PasswordStore so we can use it as a profiled keyed service. |
29 class PasswordStoreService : public KeyedService { | 29 class PasswordStoreService : public KeyedService { |
30 public: | 30 public: |
31 // |password_store| needs to be not-NULL, and the constructor expects that | 31 // |password_store| needs to be not-NULL, and the constructor expects that |
32 // Init() was already called successfully on it. | 32 // Init() was already called successfully on it. |
33 explicit PasswordStoreService( | 33 explicit PasswordStoreService( |
34 scoped_refptr<password_manager::PasswordStore> password_store); | 34 scoped_refptr<password_manager::PasswordStore> password_store); |
35 virtual ~PasswordStoreService(); | 35 ~PasswordStoreService() override; |
36 | 36 |
37 scoped_refptr<password_manager::PasswordStore> GetPasswordStore(); | 37 scoped_refptr<password_manager::PasswordStore> GetPasswordStore(); |
38 | 38 |
39 // KeyedService implementation. | 39 // KeyedService implementation. |
40 virtual void Shutdown() override; | 40 void Shutdown() override; |
41 | 41 |
42 private: | 42 private: |
43 scoped_refptr<password_manager::PasswordStore> password_store_; | 43 scoped_refptr<password_manager::PasswordStore> password_store_; |
44 DISALLOW_COPY_AND_ASSIGN(PasswordStoreService); | 44 DISALLOW_COPY_AND_ASSIGN(PasswordStoreService); |
45 }; | 45 }; |
46 | 46 |
47 // Singleton that owns all PasswordStores and associates them with | 47 // Singleton that owns all PasswordStores and associates them with |
48 // Profiles. | 48 // Profiles. |
49 class PasswordStoreFactory : public BrowserContextKeyedServiceFactory { | 49 class PasswordStoreFactory : public BrowserContextKeyedServiceFactory { |
50 public: | 50 public: |
51 static scoped_refptr<password_manager::PasswordStore> GetForProfile( | 51 static scoped_refptr<password_manager::PasswordStore> GetForProfile( |
52 Profile* profile, | 52 Profile* profile, |
53 Profile::ServiceAccessType set); | 53 Profile::ServiceAccessType set); |
54 | 54 |
55 static PasswordStoreFactory* GetInstance(); | 55 static PasswordStoreFactory* GetInstance(); |
56 | 56 |
57 private: | 57 private: |
58 friend struct DefaultSingletonTraits<PasswordStoreFactory>; | 58 friend struct DefaultSingletonTraits<PasswordStoreFactory>; |
59 | 59 |
60 PasswordStoreFactory(); | 60 PasswordStoreFactory(); |
61 virtual ~PasswordStoreFactory(); | 61 ~PasswordStoreFactory() override; |
62 | 62 |
63 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) && defined(OS_POSIX) | 63 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) && defined(OS_POSIX) |
64 LocalProfileId GetLocalProfileId(PrefService* prefs) const; | 64 LocalProfileId GetLocalProfileId(PrefService* prefs) const; |
65 #endif | 65 #endif |
66 | 66 |
67 // BrowserContextKeyedServiceFactory: | 67 // BrowserContextKeyedServiceFactory: |
68 virtual KeyedService* BuildServiceInstanceFor( | 68 KeyedService* BuildServiceInstanceFor( |
69 content::BrowserContext* context) const override; | 69 content::BrowserContext* context) const override; |
70 virtual void RegisterProfilePrefs( | 70 void RegisterProfilePrefs( |
71 user_prefs::PrefRegistrySyncable* registry) override; | 71 user_prefs::PrefRegistrySyncable* registry) override; |
72 virtual content::BrowserContext* GetBrowserContextToUse( | 72 content::BrowserContext* GetBrowserContextToUse( |
73 content::BrowserContext* context) const override; | 73 content::BrowserContext* context) const override; |
74 virtual bool ServiceIsNULLWhileTesting() const override; | 74 bool ServiceIsNULLWhileTesting() const override; |
75 | 75 |
76 DISALLOW_COPY_AND_ASSIGN(PasswordStoreFactory); | 76 DISALLOW_COPY_AND_ASSIGN(PasswordStoreFactory); |
77 }; | 77 }; |
78 | 78 |
79 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_FACTORY_H_ | 79 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_FACTORY_H_ |
OLD | NEW |