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

Side by Side Diff: components/os_crypt/keyring_util_linux.h

Issue 2216313002: Move GnomeKeyringLoader to components/os_crypt (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed guard Created 4 years, 4 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
« no previous file with comments | « components/os_crypt/BUILD.gn ('k') | components/os_crypt/keyring_util_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 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 COMPONENTS_OS_CRYPT_KEYRING_UTIL_LINUX_H_
6 #define COMPONENTS_OS_CRYPT_KEYRING_UTIL_LINUX_H_
7
8 // libgnome-keyring has been deprecated in favor of libsecret.
9 // See: https://mail.gnome.org/archives/commits-list/2013-October/msg08876.html
10 //
11 // The define below turns off the deprecations, in order to avoid build
12 // failures with Gnome 3.12. When we move to libsecret, the define can be
13 // removed, together with the include below it.
14 //
15 // The porting is tracked in http://crbug.com/355223
16 #define GNOME_KEYRING_DEPRECATED
17 #define GNOME_KEYRING_DEPRECATED_FOR(x)
18 #include <gnome-keyring.h>
19
20 #include "base/macros.h"
21
22 // Many of the gnome_keyring_* functions use variable arguments, which makes
23 // them difficult if not impossible to truly wrap in C. Therefore, we use
24 // appropriately-typed function pointers and scoping to make the fact that we
25 // might be dynamically loading the library almost invisible. As a bonus, we
26 // also get a simple way to mock the library for testing. Classes that inherit
27 // from GnomeKeyringLoader will use its versions of the gnome_keyring_*
28 // functions. Note that it has only static fields.
29 class GnomeKeyringLoader {
30 protected:
31 static bool LoadGnomeKeyring();
32
33 // Declare the actual function pointers that we'll use in client code.
34 static decltype(&::gnome_keyring_is_available) gnome_keyring_is_available_ptr;
35 static decltype(
36 &::gnome_keyring_store_password) gnome_keyring_store_password_ptr;
37 static decltype(
38 &::gnome_keyring_delete_password) gnome_keyring_delete_password_ptr;
39 static decltype(&::gnome_keyring_find_items) gnome_keyring_find_items_ptr;
40 static decltype(
41 &::gnome_keyring_result_to_message) gnome_keyring_result_to_message_ptr;
42 static decltype(&::gnome_keyring_attribute_list_free)
43 gnome_keyring_attribute_list_free_ptr;
44 static decltype(
45 &::gnome_keyring_attribute_list_new) gnome_keyring_attribute_list_new_ptr;
46 static decltype(&::gnome_keyring_attribute_list_append_string)
47 gnome_keyring_attribute_list_append_string_ptr;
48 static decltype(&::gnome_keyring_attribute_list_append_uint32)
49 gnome_keyring_attribute_list_append_uint32_ptr;
50 // We also use gnome_keyring_attribute_list_index(), which is a macro and
51 // can't be referenced.
52
53 // Set to true if LoadGnomeKeyring() has already succeeded.
54 static bool keyring_loaded;
55
56 private:
57 struct FunctionInfo {
58 const char* name;
59 void** pointer;
60 };
61
62 // Make it easy to initialize the function pointers in LoadGnomeKeyring().
63 static const FunctionInfo functions[];
64 };
65
66 #endif // COMPONENTS_OS_CRYPT_KEYRING_UTIL_LINUX_H_
OLDNEW
« no previous file with comments | « components/os_crypt/BUILD.gn ('k') | components/os_crypt/keyring_util_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698