NaCl: Update revision in DEPS, r12770 -> r12773
[chromium-blink-merge.git] / chrome / browser / password_manager / password_store_factory.h
blobba5d289755d89a812b8e581e4a44a06b3a8b17ea
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_PASSWORD_MANAGER_PASSWORD_STORE_FACTORY_H_
6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_FACTORY_H_
8 #include "base/basictypes.h"
9 #include "base/memory/singleton.h"
10 #include "chrome/browser/profiles/profile.h"
11 #include "components/browser_context_keyed_service/browser_context_keyed_service_factory.h"
13 class PasswordStore;
14 class Profile;
16 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) && defined(OS_POSIX)
17 // Local profile ids are used to associate resources stored outside the profile
18 // directory, like saved passwords in GNOME Keyring / KWallet, with a profile.
19 // With high probability, they are unique on the local machine. They are almost
20 // certainly not unique globally, by design. Do not send them over the network.
21 typedef int LocalProfileId;
22 #endif
24 // A wrapper of PasswordStore so we can use it as a profiled keyed service.
25 class PasswordStoreService : public BrowserContextKeyedService {
26 public:
27 // |password_store| needs to be not-NULL, and the constructor expects that
28 // Init() was already called successfully on it.
29 explicit PasswordStoreService(scoped_refptr<PasswordStore> password_store);
30 virtual ~PasswordStoreService();
32 scoped_refptr<PasswordStore> GetPasswordStore();
34 // BrowserContextKeyedService implementation.
35 virtual void Shutdown() OVERRIDE;
37 private:
38 scoped_refptr<PasswordStore> password_store_;
39 DISALLOW_COPY_AND_ASSIGN(PasswordStoreService);
42 // Singleton that owns all PasswordStores and associates them with
43 // Profiles.
44 class PasswordStoreFactory : public BrowserContextKeyedServiceFactory {
45 public:
46 static scoped_refptr<PasswordStore> GetForProfile(
47 Profile* profile, Profile::ServiceAccessType set);
49 static PasswordStoreFactory* GetInstance();
51 private:
52 friend struct DefaultSingletonTraits<PasswordStoreFactory>;
54 PasswordStoreFactory();
55 virtual ~PasswordStoreFactory();
57 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) && defined(OS_POSIX)
58 LocalProfileId GetLocalProfileId(PrefService* prefs) const;
59 #endif
61 // BrowserContextKeyedServiceFactory:
62 virtual BrowserContextKeyedService* BuildServiceInstanceFor(
63 content::BrowserContext* context) const OVERRIDE;
64 virtual void RegisterProfilePrefs(
65 user_prefs::PrefRegistrySyncable* registry) OVERRIDE;
66 virtual content::BrowserContext* GetBrowserContextToUse(
67 content::BrowserContext* context) const OVERRIDE;
68 virtual bool ServiceIsNULLWhileTesting() const OVERRIDE;
70 DISALLOW_COPY_AND_ASSIGN(PasswordStoreFactory);
73 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_FACTORY_H_