Update mojo surfaces bindings and mojo/cc/ glue
[chromium-blink-merge.git] / chrome / browser / password_manager / password_store_factory.h
blob3a318a570bec5dd93dd7023b51999f4123abf04d
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/keyed_service/content/browser_context_keyed_service_factory.h"
13 class Profile;
15 namespace password_manager {
16 class PasswordStore;
19 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) && defined(OS_POSIX)
20 // Local profile ids are used to associate resources stored outside the profile
21 // directory, like saved passwords in GNOME Keyring / KWallet, with a profile.
22 // With high probability, they are unique on the local machine. They are almost
23 // certainly not unique globally, by design. Do not send them over the network.
24 typedef int LocalProfileId;
25 #endif
27 // A wrapper of PasswordStore so we can use it as a profiled keyed service.
28 class PasswordStoreService : public KeyedService {
29 public:
30 // |password_store| needs to be not-NULL, and the constructor expects that
31 // Init() was already called successfully on it.
32 explicit PasswordStoreService(
33 scoped_refptr<password_manager::PasswordStore> password_store);
34 virtual ~PasswordStoreService();
36 scoped_refptr<password_manager::PasswordStore> GetPasswordStore();
38 // KeyedService implementation.
39 virtual void Shutdown() OVERRIDE;
41 private:
42 scoped_refptr<password_manager::PasswordStore> password_store_;
43 DISALLOW_COPY_AND_ASSIGN(PasswordStoreService);
46 // Singleton that owns all PasswordStores and associates them with
47 // Profiles.
48 class PasswordStoreFactory : public BrowserContextKeyedServiceFactory {
49 public:
50 static scoped_refptr<password_manager::PasswordStore> GetForProfile(
51 Profile* profile,
52 Profile::ServiceAccessType set);
54 static PasswordStoreFactory* GetInstance();
56 private:
57 friend struct DefaultSingletonTraits<PasswordStoreFactory>;
59 PasswordStoreFactory();
60 virtual ~PasswordStoreFactory();
62 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) && defined(OS_POSIX)
63 LocalProfileId GetLocalProfileId(PrefService* prefs) const;
64 #endif
66 // BrowserContextKeyedServiceFactory:
67 virtual KeyedService* BuildServiceInstanceFor(
68 content::BrowserContext* context) const OVERRIDE;
69 virtual void RegisterProfilePrefs(
70 user_prefs::PrefRegistrySyncable* registry) OVERRIDE;
71 virtual content::BrowserContext* GetBrowserContextToUse(
72 content::BrowserContext* context) const OVERRIDE;
73 virtual bool ServiceIsNULLWhileTesting() const OVERRIDE;
75 DISALLOW_COPY_AND_ASSIGN(PasswordStoreFactory);
78 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_FACTORY_H_