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

Unified Diff: chrome/browser/password_manager/keyring_proxy/gnome_keyring_loader.cc

Issue 8509038: Linux: split GNOME Keyring integration into a separate process. Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: merge Created 8 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/password_manager/keyring_proxy/gnome_keyring_loader.cc
===================================================================
--- chrome/browser/password_manager/keyring_proxy/gnome_keyring_loader.cc (revision 0)
+++ chrome/browser/password_manager/keyring_proxy/gnome_keyring_loader.cc (revision 0)
@@ -0,0 +1,75 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/password_manager/keyring_proxy/gnome_keyring_loader.h"
+
+#include <dlfcn.h>
+#include <stdio.h>
+
+namespace keyring_proxy {
+
+#define GNOME_KEYRING_DEFINE_POINTER(name) \
+ typeof(&::gnome_keyring_##name) GnomeKeyringLoader::gnome_keyring_##name;
+GNOME_KEYRING_FOR_EACH_FUNC(GNOME_KEYRING_DEFINE_POINTER)
+#undef GNOME_KEYRING_DEFINE_POINTER
+
+bool GnomeKeyringLoader::keyring_loaded = false;
+
+#if defined(DLOPEN_GNOME_KEYRING)
+
+#define GNOME_KEYRING_FUNCTION_INFO(name) \
+ {"gnome_keyring_"#name, reinterpret_cast<void**>(&gnome_keyring_##name)},
+const GnomeKeyringLoader::FunctionInfo GnomeKeyringLoader::functions[] = {
+ GNOME_KEYRING_FOR_EACH_FUNC(GNOME_KEYRING_FUNCTION_INFO)
+ {NULL, NULL}
+};
+#undef GNOME_KEYRING_FUNCTION_INFO
+
+// Load the library and initialize the function pointers.
+bool GnomeKeyringLoader::LoadGnomeKeyring() {
+ if (keyring_loaded)
+ return true;
+
+ void* handle = dlopen("libgnome-keyring.so.0", RTLD_NOW | RTLD_GLOBAL);
+ if (!handle) {
+ // We wanted to use GNOME Keyring, but we couldn't load it. Warn, because
+ // either the user asked for this, or we autodetected it incorrectly. (Or
+ // the system has broken libraries, which is also good to warn about.)
+ fprintf(stderr, "Could not load libgnome-keyring.so.0: %s\n", dlerror());
+ return false;
+ }
+
+ for (size_t i = 0; functions[i].name; ++i) {
+ dlerror();
+ *functions[i].pointer = dlsym(handle, functions[i].name);
+ const char* error = dlerror();
+ if (error) {
+ fprintf(stderr, "Unable to load symbol %s: %s\n",
+ functions[i].name, error);
+ dlclose(handle);
+ return false;
+ }
+ }
+
+ keyring_loaded = true;
+ // We leak the library handle. That's OK: this function is called only once.
+ return true;
+}
+
+#else // defined(DLOPEN_GNOME_KEYRING)
+
+bool GnomeKeyringLoader::LoadGnomeKeyring() {
+ if (keyring_loaded)
+ return true;
+#define GNOME_KEYRING_ASSIGN_POINTER(name) \
+ gnome_keyring_##name = &::gnome_keyring_##name;
+ GNOME_KEYRING_FOR_EACH_FUNC(GNOME_KEYRING_ASSIGN_POINTER)
+#undef GNOME_KEYRING_ASSIGN_POINTER
+ keyring_loaded = true;
+ return true;
+}
+
+#endif // defined(DLOPEN_GNOME_KEYRING)
+
+} // namespace keyring_proxy
Property changes on: chrome/browser/password_manager/keyring_proxy/gnome_keyring_loader.cc
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698