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

Unified Diff: chrome/browser/password_manager/native_backend_gnome_x.h

Issue 11437025: Linux: add library loader for GNOME keyring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix for bots Created 8 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/linux/system.gyp ('k') | chrome/browser/password_manager/native_backend_gnome_x.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/password_manager/native_backend_gnome_x.h
diff --git a/chrome/browser/password_manager/native_backend_gnome_x.h b/chrome/browser/password_manager/native_backend_gnome_x.h
index f4218314e5351b997aac3fdb58d6c506dbd0788d..f0ba47b1188c8f7e9ac8f2064c5104a8da4c043b 100644
--- a/chrome/browser/password_manager/native_backend_gnome_x.h
+++ b/chrome/browser/password_manager/native_backend_gnome_x.h
@@ -5,8 +5,6 @@
#ifndef CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_GNOME_X_H_
#define CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_GNOME_X_H_
-#include <gnome-keyring.h>
-
#include <string>
#include "base/basictypes.h"
@@ -15,56 +13,16 @@
#include "chrome/browser/password_manager/password_store_x.h"
#include "chrome/browser/profiles/profile.h"
+#include "library_loaders/libgnome-keyring.h"
+
class PrefService;
namespace content {
struct PasswordForm;
}
-// Many of the gnome_keyring_* functions use variable arguments, which makes
-// them difficult if not impossible to truly wrap in C. Therefore, we use
-// appropriately-typed function pointers and scoping to make the fact that we
-// might be dynamically loading the library almost invisible. As a bonus, we
-// also get a simple way to mock the library for testing. Classes that inherit
-// from GnomeKeyringLoader will use its versions of the gnome_keyring_*
-// functions. Note that it has only static fields.
-class GnomeKeyringLoader {
- protected:
- static bool LoadGnomeKeyring();
-
-// Call a given parameter with the name of each function we use from GNOME
-// Keyring. Make sure to adjust the unit test if you change these.
-#define GNOME_KEYRING_FOR_EACH_FUNC(F) \
- F(is_available) \
- F(store_password) \
- F(delete_password) \
- F(find_itemsv) \
- F(result_to_message)
-
-// Declare the actual function pointers that we'll use in client code.
-#define GNOME_KEYRING_DECLARE_POINTER(name) \
- static typeof(&::gnome_keyring_##name) gnome_keyring_##name;
- GNOME_KEYRING_FOR_EACH_FUNC(GNOME_KEYRING_DECLARE_POINTER)
-#undef GNOME_KEYRING_DECLARE_POINTER
-
- // Set to true if LoadGnomeKeyring() has already succeeded.
- static bool keyring_loaded;
-
- private:
-#if defined(DLOPEN_GNOME_KEYRING)
- struct FunctionInfo {
- const char* name;
- void** pointer;
- };
-
- // Make it easy to initialize the function pointers in LoadGnomeKeyring().
- static const FunctionInfo functions[];
-#endif // defined(DLOPEN_GNOME_KEYRING)
-};
-
// NativeBackend implementation using GNOME Keyring.
-class NativeBackendGnome : public PasswordStoreX::NativeBackend,
- public GnomeKeyringLoader {
+class NativeBackendGnome : public PasswordStoreX::NativeBackend {
public:
NativeBackendGnome(LocalProfileId id, PrefService* prefs);
@@ -86,6 +44,12 @@ class NativeBackendGnome : public PasswordStoreX::NativeBackend,
virtual bool GetAutofillableLogins(PasswordFormList* forms) OVERRIDE;
virtual bool GetBlacklistLogins(PasswordFormList* forms) OVERRIDE;
+#ifdef UNIT_TEST
+ LibGnomeKeyringLoader* libgnome_keyring_loader() {
+ return &libgnome_keyring_loader_;
+ }
+#endif // UNIT_TEST
+
private:
// Adds a login form without checking for one to replace first.
bool RawAddLogin(const content::PasswordForm& form);
@@ -114,6 +78,8 @@ class NativeBackendGnome : public PasswordStoreX::NativeBackend,
// True once MigrateToProfileSpecificLogins() has been attempted.
bool migrate_tried_;
+ LibGnomeKeyringLoader libgnome_keyring_loader_;
+
DISALLOW_COPY_AND_ASSIGN(NativeBackendGnome);
};
« no previous file with comments | « build/linux/system.gyp ('k') | chrome/browser/password_manager/native_backend_gnome_x.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698