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

Unified Diff: chrome/browser/password_manager/native_backend_libsecret.cc

Issue 891463002: Fill empty fields from keyring result with default values. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comments. Created 5 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
« no previous file with comments | « no previous file | chrome/browser/password_manager/native_backend_libsecret_unittest.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_libsecret.cc
diff --git a/chrome/browser/password_manager/native_backend_libsecret.cc b/chrome/browser/password_manager/native_backend_libsecret.cc
index 17051f9ccbf82d1de69850dfb255c26b2c3ffcc0..95886e50c63bb90038c1ef43d973530fe113051f 100644
--- a/chrome/browser/password_manager/native_backend_libsecret.cc
+++ b/chrome/browser/password_manager/native_backend_libsecret.cc
@@ -119,14 +119,17 @@ const SecretSchema kLibsecretSchema = {
{"application", SECRET_SCHEMA_ATTRIBUTE_STRING},
{nullptr, SECRET_SCHEMA_ATTRIBUTE_STRING}}};
-char* GetStringFromAttributes(GHashTable* attrs, const char* keyname) {
- return static_cast<char*>(g_hash_table_lookup(attrs, keyname));
+std::string GetStringFromAttributes(GHashTable* attrs, const char* keyname) {
vabr (Chromium) 2015/01/29 14:10:34 I would suggest still returning char* and carefull
dvadym 2015/01/29 14:21:40 Done.
+ gpointer value = g_hash_table_lookup(attrs, keyname);
+ return value ? std::string(static_cast<char*>(value)) : std::string();
}
uint32_t GetUintFromAttributes(GHashTable* attrs, const char* keyname) {
- char* value = static_cast<char*>(g_hash_table_lookup(attrs, keyname));
+ gpointer value = g_hash_table_lookup(attrs, keyname);
+ if (value == NULL)
vabr (Chromium) 2015/01/29 14:10:34 nit: NULL -> nullptr
dvadym 2015/01/29 14:21:40 Done.
+ return uint32_t();
uint32_t result;
- bool value_ok = base::StringToUint(value, &result);
+ bool value_ok = base::StringToUint(static_cast<char*>(value), &result);
DCHECK(value_ok);
return result;
}
@@ -135,7 +138,8 @@ uint32_t GetUintFromAttributes(GHashTable* attrs, const char* keyname) {
// Note: does *not* get the actual password, as that is not a key attribute!
// Returns nullptr if the attributes are for the wrong application.
scoped_ptr<PasswordForm> FormOutOfAttributes(GHashTable* attrs) {
- base::StringPiece app_value = GetStringFromAttributes(attrs, "application");
+ std::string app_string = GetStringFromAttributes(attrs, "application");
vabr (Chromium) 2015/01/29 14:10:34 Please do not convert to std::string, that harms p
dvadym 2015/01/29 14:21:39 Done.
+ base::StringPiece app_value = app_string;
if (!app_value.starts_with(kLibsecretAppString))
return scoped_ptr<PasswordForm>();
« no previous file with comments | « no previous file | chrome/browser/password_manager/native_backend_libsecret_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698