Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: chrome/browser/password_manager/password_store_x.h

Issue 2806002: Linux: refactor GNOME Keyring and KWallet integration to allow migration. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2010 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.
4
5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_X_H_
6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_X_H_
7
8 #include <vector>
9
10 #include "base/scoped_ptr.h"
11 #include "base/time.h"
12 #include "chrome/browser/password_manager/password_store_default.h"
13
14 class LoginDatabase;
15 class Profile;
16 class WebDataService;
17
18 // PasswordStoreX is used on Linux and other non-Windows, non-Mac OS X
19 // operating systems. It uses a "native backend" to actually store the password
20 // data when such a backend is available, and otherwise falls back to using the
21 // login database like PasswordStoreDefault. It also handles automatically
22 // migrating password data to a native backend from the login database.
23 //
24 // There are currently native backends for GNOME Keyring and KWallet.
25 class PasswordStoreX : public PasswordStoreDefault {
26 public:
27 // NativeBackends more or less implement the PaswordStore interface, but
28 // with return values rather than implicit consumer notification.
29 class NativeBackend {
30 public:
31 typedef std::vector<webkit_glue::PasswordForm*> PasswordFormList;
32
33 virtual ~NativeBackend() {}
34
35 virtual bool Init() = 0;
36
37 virtual bool AddLogin(const webkit_glue::PasswordForm& form) = 0;
38 virtual bool UpdateLogin(const webkit_glue::PasswordForm& form) = 0;
39 virtual bool RemoveLogin(const webkit_glue::PasswordForm& form) = 0;
40 virtual bool RemoveLoginsCreatedBetween(const base::Time& delete_begin,
41 const base::Time& delete_end) = 0;
42 virtual bool GetLogins(const webkit_glue::PasswordForm& form,
43 PasswordFormList* forms) = 0;
44 virtual bool GetLoginsCreatedBetween(const base::Time& get_begin,
45 const base::Time& get_end,
46 PasswordFormList* forms) = 0;
47 virtual bool GetAutofillableLogins(PasswordFormList* forms) = 0;
48 virtual bool GetBlacklistLogins(PasswordFormList* forms) = 0;
49 };
50
51 // Takes ownership of |login_db| and |backend|. |backend| may be NULL in which
52 // case this PasswordStoreX will act the same as PasswordStoreDefault.
53 PasswordStoreX(LoginDatabase* login_db,
54 Profile* profile,
55 WebDataService* web_data_service,
56 NativeBackend* backend);
57
58 private:
59 friend class PasswordStoreXTest;
60
61 virtual ~PasswordStoreX();
62
63 // Implements PasswordStore interface.
64 virtual void AddLoginImpl(const webkit_glue::PasswordForm& form);
65 virtual void UpdateLoginImpl(const webkit_glue::PasswordForm& form);
66 virtual void RemoveLoginImpl(const webkit_glue::PasswordForm& form);
67 virtual void RemoveLoginsCreatedBetweenImpl(const base::Time& delete_begin,
68 const base::Time& delete_end);
69 virtual void GetLoginsImpl(GetLoginsRequest* request,
70 const webkit_glue::PasswordForm& form);
71 virtual void GetAutofillableLoginsImpl(GetLoginsRequest* request);
72 virtual void GetBlacklistLoginsImpl(GetLoginsRequest* request);
73 virtual bool FillAutofillableLogins(
74 std::vector<webkit_glue::PasswordForm*>* forms);
75 virtual bool FillBlacklistLogins(
76 std::vector<webkit_glue::PasswordForm*>* forms);
77
78 // Check to see whether migration is necessary, and perform it if so.
79 void CheckMigration();
80
81 // Return true if we should try using the native backend.
82 bool use_native_backend() { return !!backend_.get(); }
83
84 // Return true if we can fall back on the default store, warning the first
85 // time we call it when falling back is necessary. See |allow_fallback_|.
86 bool allow_default_store();
87
88 // Synchronously migrates all the passwords stored in the login database to
89 // the native backend. If successful, the login database will be left with no
90 // stored passwords, and the number of passwords migrated will be returned.
91 // (This might be 0 if migration was not necessary.) Returns < 0 on failure.
92 ssize_t MigrateLogins();
93
94 // The native backend in use, or NULL if none.
95 scoped_ptr<NativeBackend> backend_;
96 // Whether we have already attempted migration to the native store.
97 bool migration_checked_;
98 // Whether we should allow falling back to the default store. If there is
99 // nothing to migrate, then the first attempt to use the native store will
100 // be the first time we try to use it and we should allow falling back. If
101 // we have migrated successfully, then we do not allow falling back.
102 bool allow_fallback_;
103
104 DISALLOW_COPY_AND_ASSIGN(PasswordStoreX);
105 };
106
107 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_X_H_
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/password_store_kwallet.cc ('k') | chrome/browser/password_manager/password_store_x.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698