| 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_NATIVE_BACKEND_GNOME_X_H_ | 5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_GNOME_X_H_ |
| 6 #define CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_GNOME_X_H_ | 6 #define CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_GNOME_X_H_ |
| 7 | 7 |
| 8 #include <gnome-keyring.h> | 8 #include <gnome-keyring.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "chrome/browser/password_manager/password_store_factory.h" | 14 #include "chrome/browser/password_manager/password_store_factory.h" |
| 15 #include "chrome/browser/password_manager/password_store_x.h" | 15 #include "chrome/browser/password_manager/password_store_x.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 17 | 17 |
| 18 class PrefService; | |
| 19 | |
| 20 namespace autofill { | 18 namespace autofill { |
| 21 struct PasswordForm; | 19 struct PasswordForm; |
| 22 } | 20 } |
| 23 | 21 |
| 24 // Many of the gnome_keyring_* functions use variable arguments, which makes | 22 // Many of the gnome_keyring_* functions use variable arguments, which makes |
| 25 // them difficult if not impossible to truly wrap in C. Therefore, we use | 23 // them difficult if not impossible to truly wrap in C. Therefore, we use |
| 26 // appropriately-typed function pointers and scoping to make the fact that we | 24 // appropriately-typed function pointers and scoping to make the fact that we |
| 27 // might be dynamically loading the library almost invisible. As a bonus, we | 25 // might be dynamically loading the library almost invisible. As a bonus, we |
| 28 // also get a simple way to mock the library for testing. Classes that inherit | 26 // also get a simple way to mock the library for testing. Classes that inherit |
| 29 // from GnomeKeyringLoader will use its versions of the gnome_keyring_* | 27 // from GnomeKeyringLoader will use its versions of the gnome_keyring_* |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 | 67 |
| 70 // Make it easy to initialize the function pointers in LoadGnomeKeyring(). | 68 // Make it easy to initialize the function pointers in LoadGnomeKeyring(). |
| 71 static const FunctionInfo functions[]; | 69 static const FunctionInfo functions[]; |
| 72 #endif // defined(DLOPEN_GNOME_KEYRING) | 70 #endif // defined(DLOPEN_GNOME_KEYRING) |
| 73 }; | 71 }; |
| 74 | 72 |
| 75 // NativeBackend implementation using GNOME Keyring. | 73 // NativeBackend implementation using GNOME Keyring. |
| 76 class NativeBackendGnome : public PasswordStoreX::NativeBackend, | 74 class NativeBackendGnome : public PasswordStoreX::NativeBackend, |
| 77 public GnomeKeyringLoader { | 75 public GnomeKeyringLoader { |
| 78 public: | 76 public: |
| 79 NativeBackendGnome(LocalProfileId id, PrefService* prefs); | 77 explicit NativeBackendGnome(LocalProfileId id); |
| 80 | 78 |
| 81 virtual ~NativeBackendGnome(); | 79 virtual ~NativeBackendGnome(); |
| 82 | 80 |
| 83 virtual bool Init() OVERRIDE; | 81 virtual bool Init() OVERRIDE; |
| 84 | 82 |
| 85 // Implements NativeBackend interface. | 83 // Implements NativeBackend interface. |
| 86 virtual bool AddLogin(const autofill::PasswordForm& form) OVERRIDE; | 84 virtual bool AddLogin(const autofill::PasswordForm& form) OVERRIDE; |
| 87 virtual bool UpdateLogin(const autofill::PasswordForm& form) OVERRIDE; | 85 virtual bool UpdateLogin(const autofill::PasswordForm& form) OVERRIDE; |
| 88 virtual bool RemoveLogin(const autofill::PasswordForm& form) OVERRIDE; | 86 virtual bool RemoveLogin(const autofill::PasswordForm& form) OVERRIDE; |
| 89 virtual bool RemoveLoginsCreatedBetween( | 87 virtual bool RemoveLoginsCreatedBetween( |
| (...skipping 12 matching lines...) Expand all Loading... |
| 102 | 100 |
| 103 // Reads PasswordForms from the keyring with the given autofillability state. | 101 // Reads PasswordForms from the keyring with the given autofillability state. |
| 104 bool GetLoginsList(PasswordFormList* forms, bool autofillable); | 102 bool GetLoginsList(PasswordFormList* forms, bool autofillable); |
| 105 | 103 |
| 106 // Helper for GetLoginsCreatedBetween(). | 104 // Helper for GetLoginsCreatedBetween(). |
| 107 bool GetAllLogins(PasswordFormList* forms); | 105 bool GetAllLogins(PasswordFormList* forms); |
| 108 | 106 |
| 109 // Generates a profile-specific app string based on profile_id_. | 107 // Generates a profile-specific app string based on profile_id_. |
| 110 std::string GetProfileSpecificAppString() const; | 108 std::string GetProfileSpecificAppString() const; |
| 111 | 109 |
| 112 // Migrates non-profile-specific logins to be profile-specific. | |
| 113 void MigrateToProfileSpecificLogins(); | |
| 114 | |
| 115 // The local profile id, used to generate the app string. | 110 // The local profile id, used to generate the app string. |
| 116 const LocalProfileId profile_id_; | 111 const LocalProfileId profile_id_; |
| 117 | 112 |
| 118 // The pref service to use for persistent migration settings. | |
| 119 PrefService* prefs_; | |
| 120 | |
| 121 // The app string, possibly based on the local profile id. | 113 // The app string, possibly based on the local profile id. |
| 122 std::string app_string_; | 114 std::string app_string_; |
| 123 | 115 |
| 124 // True once MigrateToProfileSpecificLogins() has been attempted. | |
| 125 bool migrate_tried_; | |
| 126 | |
| 127 DISALLOW_COPY_AND_ASSIGN(NativeBackendGnome); | 116 DISALLOW_COPY_AND_ASSIGN(NativeBackendGnome); |
| 128 }; | 117 }; |
| 129 | 118 |
| 130 #endif // CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_GNOME_X_H_ | 119 #endif // CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_GNOME_X_H_ |
| OLD | NEW |