| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <gnome-keyring.h> | 9 #include <gnome-keyring.h> |
| 10 | 10 |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/time.h" | 14 #include "base/time.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; | 18 class PrefService; |
| 19 | 19 |
| 20 namespace webkit_glue { | 20 namespace webkit { |
| 21 namespace forms { |
| 21 struct PasswordForm; | 22 struct PasswordForm; |
| 22 } | 23 } |
| 24 } |
| 23 | 25 |
| 24 // Many of the gnome_keyring_* functions use variable arguments, which makes | 26 // 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 | 27 // 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 | 28 // 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 | 29 // 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 | 30 // 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_* | 31 // from GnomeKeyringLoader will use its versions of the gnome_keyring_* |
| 30 // functions. Note that it has only static fields. | 32 // functions. Note that it has only static fields. |
| 31 class GnomeKeyringLoader { | 33 class GnomeKeyringLoader { |
| 32 protected: | 34 protected: |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 class NativeBackendGnome : public PasswordStoreX::NativeBackend, | 68 class NativeBackendGnome : public PasswordStoreX::NativeBackend, |
| 67 public GnomeKeyringLoader { | 69 public GnomeKeyringLoader { |
| 68 public: | 70 public: |
| 69 NativeBackendGnome(LocalProfileId id, PrefService* prefs); | 71 NativeBackendGnome(LocalProfileId id, PrefService* prefs); |
| 70 | 72 |
| 71 virtual ~NativeBackendGnome(); | 73 virtual ~NativeBackendGnome(); |
| 72 | 74 |
| 73 virtual bool Init() OVERRIDE; | 75 virtual bool Init() OVERRIDE; |
| 74 | 76 |
| 75 // Implements NativeBackend interface. | 77 // Implements NativeBackend interface. |
| 76 virtual bool AddLogin(const webkit_glue::PasswordForm& form) OVERRIDE; | 78 virtual bool AddLogin(const webkit::forms::PasswordForm& form) OVERRIDE; |
| 77 virtual bool UpdateLogin(const webkit_glue::PasswordForm& form) OVERRIDE; | 79 virtual bool UpdateLogin(const webkit::forms::PasswordForm& form) OVERRIDE; |
| 78 virtual bool RemoveLogin(const webkit_glue::PasswordForm& form) OVERRIDE; | 80 virtual bool RemoveLogin(const webkit::forms::PasswordForm& form) OVERRIDE; |
| 79 virtual bool RemoveLoginsCreatedBetween( | 81 virtual bool RemoveLoginsCreatedBetween( |
| 80 const base::Time& delete_begin, const base::Time& delete_end) OVERRIDE; | 82 const base::Time& delete_begin, const base::Time& delete_end) OVERRIDE; |
| 81 virtual bool GetLogins(const webkit_glue::PasswordForm& form, | 83 virtual bool GetLogins(const webkit::forms::PasswordForm& form, |
| 82 PasswordFormList* forms) OVERRIDE; | 84 PasswordFormList* forms) OVERRIDE; |
| 83 virtual bool GetLoginsCreatedBetween(const base::Time& get_begin, | 85 virtual bool GetLoginsCreatedBetween(const base::Time& get_begin, |
| 84 const base::Time& get_end, | 86 const base::Time& get_end, |
| 85 PasswordFormList* forms) OVERRIDE; | 87 PasswordFormList* forms) OVERRIDE; |
| 86 virtual bool GetAutofillableLogins(PasswordFormList* forms) OVERRIDE; | 88 virtual bool GetAutofillableLogins(PasswordFormList* forms) OVERRIDE; |
| 87 virtual bool GetBlacklistLogins(PasswordFormList* forms) OVERRIDE; | 89 virtual bool GetBlacklistLogins(PasswordFormList* forms) OVERRIDE; |
| 88 | 90 |
| 89 private: | 91 private: |
| 90 // Adds a login form without checking for one to replace first. | 92 // Adds a login form without checking for one to replace first. |
| 91 bool RawAddLogin(const webkit_glue::PasswordForm& form); | 93 bool RawAddLogin(const webkit::forms::PasswordForm& form); |
| 92 | 94 |
| 93 // Reads PasswordForms from the keyring with the given autofillability state. | 95 // Reads PasswordForms from the keyring with the given autofillability state. |
| 94 bool GetLoginsList(PasswordFormList* forms, bool autofillable); | 96 bool GetLoginsList(PasswordFormList* forms, bool autofillable); |
| 95 | 97 |
| 96 // Helper for GetLoginsCreatedBetween(). | 98 // Helper for GetLoginsCreatedBetween(). |
| 97 bool GetAllLogins(PasswordFormList* forms); | 99 bool GetAllLogins(PasswordFormList* forms); |
| 98 | 100 |
| 99 // Generates a profile-specific app string based on profile_id_. | 101 // Generates a profile-specific app string based on profile_id_. |
| 100 std::string GetProfileSpecificAppString() const; | 102 std::string GetProfileSpecificAppString() const; |
| 101 | 103 |
| 102 // Migrates non-profile-specific logins to be profile-specific. | 104 // Migrates non-profile-specific logins to be profile-specific. |
| 103 void MigrateToProfileSpecificLogins(); | 105 void MigrateToProfileSpecificLogins(); |
| 104 | 106 |
| 105 // The local profile id, used to generate the app string. | 107 // The local profile id, used to generate the app string. |
| 106 const LocalProfileId profile_id_; | 108 const LocalProfileId profile_id_; |
| 107 | 109 |
| 108 // The pref service to use for persistent migration settings. | 110 // The pref service to use for persistent migration settings. |
| 109 PrefService* prefs_; | 111 PrefService* prefs_; |
| 110 | 112 |
| 111 // The app string, possibly based on the local profile id. | 113 // The app string, possibly based on the local profile id. |
| 112 std::string app_string_; | 114 std::string app_string_; |
| 113 | 115 |
| 114 // True once MigrateToProfileSpecificLogins() has been attempted. | 116 // True once MigrateToProfileSpecificLogins() has been attempted. |
| 115 bool migrate_tried_; | 117 bool migrate_tried_; |
| 116 | 118 |
| 117 DISALLOW_COPY_AND_ASSIGN(NativeBackendGnome); | 119 DISALLOW_COPY_AND_ASSIGN(NativeBackendGnome); |
| 118 }; | 120 }; |
| 119 | 121 |
| 120 #endif // CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_GNOME_X_H_ | 122 #endif // CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_GNOME_X_H_ |
| OLD | NEW |