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

Side by Side Diff: chrome/browser/password_manager/native_backend_gnome_x.cc

Issue 2196193002: Expanded GnomeKeyringLoader macros (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: unnecessary null termination 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
OLDNEW
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 #include "chrome/browser/password_manager/native_backend_gnome_x.h" 5 #include "chrome/browser/password_manager/native_backend_gnome_x.h"
6 6
7 #include <dlfcn.h> 7 #include <dlfcn.h>
8 #include <gnome-keyring.h> 8 #include <gnome-keyring.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <stdint.h> 10 #include <stdint.h>
(...skipping 24 matching lines...) Expand all
35 using base::UTF8ToUTF16; 35 using base::UTF8ToUTF16;
36 using base::UTF16ToUTF8; 36 using base::UTF16ToUTF8;
37 using content::BrowserThread; 37 using content::BrowserThread;
38 using namespace password_manager::metrics_util; 38 using namespace password_manager::metrics_util;
39 using password_manager::PasswordStore; 39 using password_manager::PasswordStore;
40 40
41 namespace { 41 namespace {
42 const int kMaxPossibleTimeTValue = std::numeric_limits<int>::max(); 42 const int kMaxPossibleTimeTValue = std::numeric_limits<int>::max();
43 } 43 }
44 44
45 #define GNOME_KEYRING_DEFINE_POINTER(name) \ 45 typeof(&::gnome_keyring_is_available)
vasilii 2016/08/01 09:51:26 decltype
cfroussios 2016/08/01 10:54:52 Done.
46 typeof(&::gnome_keyring_##name) GnomeKeyringLoader::gnome_keyring_##name; 46 GnomeKeyringLoader::gnome_keyring_is_available;
47 GNOME_KEYRING_FOR_EACH_FUNC(GNOME_KEYRING_DEFINE_POINTER) 47 typeof(&::gnome_keyring_store_password)
48 #undef GNOME_KEYRING_DEFINE_POINTER 48 GnomeKeyringLoader::gnome_keyring_store_password;
49 typeof(&::gnome_keyring_delete_password)
50 GnomeKeyringLoader::gnome_keyring_delete_password;
51 typeof(&::gnome_keyring_find_items)
52 GnomeKeyringLoader::gnome_keyring_find_items;
53 typeof(&::gnome_keyring_result_to_message)
54 GnomeKeyringLoader::gnome_keyring_result_to_message;
55 typeof(&::gnome_keyring_attribute_list_free)
56 GnomeKeyringLoader::gnome_keyring_attribute_list_free;
57 typeof(&::gnome_keyring_attribute_list_new)
58 GnomeKeyringLoader::gnome_keyring_attribute_list_new;
59 typeof(&::gnome_keyring_attribute_list_append_string)
60 GnomeKeyringLoader::gnome_keyring_attribute_list_append_string;
61 typeof(&::gnome_keyring_attribute_list_append_uint32)
62 GnomeKeyringLoader::gnome_keyring_attribute_list_append_uint32;
49 63
50 bool GnomeKeyringLoader::keyring_loaded = false; 64 bool GnomeKeyringLoader::keyring_loaded = false;
51 65
52 #define GNOME_KEYRING_FUNCTION_INFO(name) \
53 {"gnome_keyring_"#name, reinterpret_cast<void**>(&gnome_keyring_##name)},
54 const GnomeKeyringLoader::FunctionInfo GnomeKeyringLoader::functions[] = { 66 const GnomeKeyringLoader::FunctionInfo GnomeKeyringLoader::functions[] = {
55 GNOME_KEYRING_FOR_EACH_FUNC(GNOME_KEYRING_FUNCTION_INFO) 67 {"gnome_keyring_is_available",
56 {nullptr, nullptr} 68 reinterpret_cast<void**>(&gnome_keyring_is_available)},
vasilii 2016/08/01 09:51:26 Will static_cast work here?
cfroussios 2016/08/01 10:54:52 The compiler does not allow it.
57 }; 69 {"gnome_keyring_store_password",
58 #undef GNOME_KEYRING_FUNCTION_INFO 70 reinterpret_cast<void**>(&gnome_keyring_store_password)},
71 {"gnome_keyring_delete_password",
72 reinterpret_cast<void**>(&gnome_keyring_delete_password)},
73 {"gnome_keyring_find_items",
74 reinterpret_cast<void**>(&gnome_keyring_find_items)},
75 {"gnome_keyring_result_to_message",
76 reinterpret_cast<void**>(&gnome_keyring_result_to_message)},
77 {"gnome_keyring_attribute_list_free",
78 reinterpret_cast<void**>(&gnome_keyring_attribute_list_free)},
79 {"gnome_keyring_attribute_list_new",
80 reinterpret_cast<void**>(&gnome_keyring_attribute_list_new)},
81 {"gnome_keyring_attribute_list_append_string",
82 reinterpret_cast<void**>(&gnome_keyring_attribute_list_append_string)},
83 {"gnome_keyring_attribute_list_append_uint32",
84 reinterpret_cast<void**>(&gnome_keyring_attribute_list_append_uint32)}};
59 85
60 /* Load the library and initialize the function pointers. */ 86 /* Load the library and initialize the function pointers. */
61 bool GnomeKeyringLoader::LoadGnomeKeyring() { 87 bool GnomeKeyringLoader::LoadGnomeKeyring() {
62 if (keyring_loaded) 88 if (keyring_loaded)
63 return true; 89 return true;
64 90
65 void* handle = dlopen("libgnome-keyring.so.0", RTLD_NOW | RTLD_GLOBAL); 91 void* handle = dlopen("libgnome-keyring.so.0", RTLD_NOW | RTLD_GLOBAL);
66 if (!handle) { 92 if (!handle) {
67 // We wanted to use GNOME Keyring, but we couldn't load it. Warn, because 93 // We wanted to use GNOME Keyring, but we couldn't load it. Warn, because
68 // either the user asked for this, or we autodetected it incorrectly. (Or 94 // either the user asked for this, or we autodetected it incorrectly. (Or
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 ScopedVector<PasswordForm> forms; 850 ScopedVector<PasswordForm> forms;
825 if (!GetLoginsBetween(get_begin, get_end, date_to_compare, &forms)) 851 if (!GetLoginsBetween(get_begin, get_end, date_to_compare, &forms))
826 return false; 852 return false;
827 853
828 for (size_t i = 0; i < forms.size(); ++i) { 854 for (size_t i = 0; i < forms.size(); ++i) {
829 if (!RemoveLogin(*forms[i], changes)) 855 if (!RemoveLogin(*forms[i], changes))
830 return false; 856 return false;
831 } 857 }
832 return true; 858 return true;
833 } 859 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698