This source file includes following definitions.
- LoadGnomeKeyring
- LoadGnomeKeyring
- FormFromAttributes
- ConvertFormList
- result_
- AddLogin
- AddLoginSearch
- UpdateLoginSearch
- RemoveLogin
- GetLogins
- GetLoginsList
- GetAllLogins
- WaitResult
- WaitResult
- AppendString
- AppendString
- AppendUint32
- OnOperationDone
- OnOperationGetList
- Init
- RawAddLogin
- AddLogin
- UpdateLogin
- RemoveLogin
- RemoveLoginsCreatedBetween
- GetLogins
- GetLoginsCreatedBetween
- GetAutofillableLogins
- GetBlacklistLogins
- GetLoginsList
- GetAllLogins
- GetProfileSpecificAppString
#include "chrome/browser/password_manager/native_backend_gnome_x.h"
#include <dlfcn.h>
#include <gnome-keyring.h>
#include <map>
#include <string>
#include <vector>
#include "base/basictypes.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/metrics/histogram.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_piece.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/synchronization/waitable_event.h"
#include "base/time/time.h"
#include "components/autofill/core/common/password_form.h"
#include "components/password_manager/core/browser/psl_matching_helper.h"
#include "content/public/browser/browser_thread.h"
using autofill::PasswordForm;
using base::UTF8ToUTF16;
using base::UTF16ToUTF8;
using content::BrowserThread;
#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
bool GnomeKeyringLoader::LoadGnomeKeyring() {
if (keyring_loaded)
return true;
void* handle = dlopen("libgnome-keyring.so.0", RTLD_NOW | RTLD_GLOBAL);
if (!handle) {
LOG(WARNING) << "Could not load libgnome-keyring.so.0: " << 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) {
LOG(ERROR) << "Unable to load symbol "
<< functions[i].name << ": " << error;
dlclose(handle);
return false;
}
}
keyring_loaded = true;
return true;
}
#else
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
namespace {
const char kGnomeKeyringAppString[] = "chrome";
scoped_ptr<PasswordForm> FormFromAttributes(GnomeKeyringAttributeList* attrs) {
std::map<std::string, std::string> string_attr_map;
std::map<std::string, uint32_t> uint_attr_map;
for (guint i = 0; i < attrs->len; ++i) {
GnomeKeyringAttribute attr = gnome_keyring_attribute_list_index(attrs, i);
if (attr.type == GNOME_KEYRING_ATTRIBUTE_TYPE_STRING)
string_attr_map[attr.name] = attr.value.string;
else if (attr.type == GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32)
uint_attr_map[attr.name] = attr.value.integer;
}
const std::string& app_value = string_attr_map["application"];
if (!base::StringPiece(app_value).starts_with(kGnomeKeyringAppString))
return scoped_ptr<PasswordForm>();
scoped_ptr<PasswordForm> form(new PasswordForm());
form->origin = GURL(string_attr_map["origin_url"]);
form->action = GURL(string_attr_map["action_url"]);
form->username_element = UTF8ToUTF16(string_attr_map["username_element"]);
form->username_value = UTF8ToUTF16(string_attr_map["username_value"]);
form->password_element = UTF8ToUTF16(string_attr_map["password_element"]);
form->submit_element = UTF8ToUTF16(string_attr_map["submit_element"]);
form->signon_realm = string_attr_map["signon_realm"];
form->ssl_valid = uint_attr_map["ssl_valid"];
form->preferred = uint_attr_map["preferred"];
int64 date_created = 0;
bool date_ok = base::StringToInt64(string_attr_map["date_created"],
&date_created);
DCHECK(date_ok);
form->date_created = base::Time::FromTimeT(date_created);
form->blacklisted_by_user = uint_attr_map["blacklisted_by_user"];
form->type = static_cast<PasswordForm::Type>(uint_attr_map["type"]);
form->times_used = uint_attr_map["times_used"];
form->scheme = static_cast<PasswordForm::Scheme>(uint_attr_map["scheme"]);
return form.Pass();
}
void ConvertFormList(GList* found,
const std::string& filter_by_signon_realm,
const PSLMatchingHelper& helper,
NativeBackendGnome::PasswordFormList* forms) {
PSLMatchingHelper::PSLDomainMatchMetric psl_domain_match_metric =
PSLMatchingHelper::PSL_DOMAIN_MATCH_NONE;
for (GList* element = g_list_first(found); element != NULL;
element = g_list_next(element)) {
GnomeKeyringFound* data = static_cast<GnomeKeyringFound*>(element->data);
GnomeKeyringAttributeList* attrs = data->attributes;
scoped_ptr<PasswordForm> form(FormFromAttributes(attrs));
if (form) {
if (!filter_by_signon_realm.empty() &&
form->signon_realm != filter_by_signon_realm) {
if (!(PSLMatchingHelper::IsPublicSuffixDomainMatch(
filter_by_signon_realm, form->signon_realm))) {
continue;
}
psl_domain_match_metric = PSLMatchingHelper::PSL_DOMAIN_MATCH_FOUND;
form->original_signon_realm = form->signon_realm;
}
if (data->secret) {
form->password_value = UTF8ToUTF16(data->secret);
} else {
LOG(WARNING) << "Unable to access password from list element!";
}
forms->push_back(form.release());
} else {
LOG(WARNING) << "Could not initialize PasswordForm from attributes!";
}
}
if (!filter_by_signon_realm.empty()) {
UMA_HISTOGRAM_ENUMERATION(
"PasswordManager.PslDomainMatchTriggering",
helper.IsMatchingEnabled()
? psl_domain_match_metric
: PSLMatchingHelper::PSL_DOMAIN_MATCH_DISABLED,
PSLMatchingHelper::PSL_DOMAIN_MATCH_COUNT);
}
}
const GnomeKeyringPasswordSchema kGnomeSchema = {
GNOME_KEYRING_ITEM_GENERIC_SECRET, {
{ "origin_url", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING },
{ "action_url", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING },
{ "username_element", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING },
{ "username_value", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING },
{ "password_element", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING },
{ "submit_element", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING },
{ "signon_realm", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING },
{ "ssl_valid", GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32 },
{ "preferred", GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32 },
{ "date_created", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING },
{ "blacklisted_by_user", GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32 },
{ "scheme", GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32 },
{ "type", GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32 },
{ "times_used", GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32 },
{ "application", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING },
{ NULL }
}
};
class GKRMethod : public GnomeKeyringLoader {
public:
typedef NativeBackendGnome::PasswordFormList PasswordFormList;
GKRMethod() : event_(false, false), result_(GNOME_KEYRING_RESULT_CANCELLED) {}
void AddLogin(const PasswordForm& form, const char* app_string);
void AddLoginSearch(const PasswordForm& form, const char* app_string);
void UpdateLoginSearch(const PasswordForm& form, const char* app_string);
void RemoveLogin(const PasswordForm& form, const char* app_string);
void GetLogins(const PasswordForm& form, const char* app_string);
void GetLoginsList(uint32_t blacklisted_by_user, const char* app_string);
void GetAllLogins(const char* app_string);
GnomeKeyringResult WaitResult();
GnomeKeyringResult WaitResult(PasswordFormList* forms);
private:
struct GnomeKeyringAttributeListFreeDeleter {
inline void operator()(void* list) const {
gnome_keyring_attribute_list_free(
static_cast<GnomeKeyringAttributeList*>(list));
}
};
typedef scoped_ptr<GnomeKeyringAttributeList,
GnomeKeyringAttributeListFreeDeleter> ScopedAttributeList;
static void AppendString(ScopedAttributeList* list,
const char* name,
const char* value);
static void AppendString(ScopedAttributeList* list,
const char* name,
const std::string& value);
static void AppendUint32(ScopedAttributeList* list,
const char* name,
guint32 value);
static void OnOperationDone(GnomeKeyringResult result, gpointer data);
static void OnOperationGetList(GnomeKeyringResult result, GList* list,
gpointer data);
base::WaitableEvent event_;
GnomeKeyringResult result_;
NativeBackendGnome::PasswordFormList forms_;
std::string original_signon_realm_;
const PSLMatchingHelper helper_;
};
void GKRMethod::AddLogin(const PasswordForm& form, const char* app_string) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
time_t date_created = form.date_created.ToTimeT();
if (!date_created)
date_created = time(NULL);
gnome_keyring_store_password(
&kGnomeSchema,
NULL,
form.origin.spec().c_str(),
UTF16ToUTF8(form.password_value).c_str(),
OnOperationDone,
this,
NULL,
"origin_url", form.origin.spec().c_str(),
"action_url", form.action.spec().c_str(),
"username_element", UTF16ToUTF8(form.username_element).c_str(),
"username_value", UTF16ToUTF8(form.username_value).c_str(),
"password_element", UTF16ToUTF8(form.password_element).c_str(),
"submit_element", UTF16ToUTF8(form.submit_element).c_str(),
"signon_realm", form.signon_realm.c_str(),
"ssl_valid", form.ssl_valid,
"preferred", form.preferred,
"date_created", base::Int64ToString(date_created).c_str(),
"blacklisted_by_user", form.blacklisted_by_user,
"type", form.type,
"times_used", form.times_used,
"scheme", form.scheme,
"application", app_string,
NULL);
}
void GKRMethod::AddLoginSearch(const PasswordForm& form,
const char* app_string) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
original_signon_realm_ = form.signon_realm;
ScopedAttributeList attrs(gnome_keyring_attribute_list_new());
AppendString(&attrs, "origin_url", form.origin.spec());
AppendString(&attrs, "username_element", UTF16ToUTF8(form.username_element));
AppendString(&attrs, "username_value", UTF16ToUTF8(form.username_value));
AppendString(&attrs, "password_element", UTF16ToUTF8(form.password_element));
AppendString(&attrs, "submit_element", UTF16ToUTF8(form.submit_element));
AppendString(&attrs, "signon_realm", form.signon_realm);
AppendString(&attrs, "application", app_string);
gnome_keyring_find_items(GNOME_KEYRING_ITEM_GENERIC_SECRET,
attrs.get(),
OnOperationGetList,
this,
NULL);
}
void GKRMethod::UpdateLoginSearch(const PasswordForm& form,
const char* app_string) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
original_signon_realm_ = form.signon_realm;
ScopedAttributeList attrs(gnome_keyring_attribute_list_new());
AppendString(&attrs, "origin_url", form.origin.spec());
AppendString(&attrs, "username_element", UTF16ToUTF8(form.username_element));
AppendString(&attrs, "username_value", UTF16ToUTF8(form.username_value));
AppendString(&attrs, "password_element", UTF16ToUTF8(form.password_element));
AppendString(&attrs, "signon_realm", form.signon_realm);
AppendString(&attrs, "application", app_string);
gnome_keyring_find_items(GNOME_KEYRING_ITEM_GENERIC_SECRET,
attrs.get(),
OnOperationGetList,
this,
NULL);
}
void GKRMethod::RemoveLogin(const PasswordForm& form, const char* app_string) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
gnome_keyring_delete_password(
&kGnomeSchema,
OnOperationDone,
this,
NULL,
"origin_url", form.origin.spec().c_str(),
"action_url", form.action.spec().c_str(),
"username_element", UTF16ToUTF8(form.username_element).c_str(),
"username_value", UTF16ToUTF8(form.username_value).c_str(),
"password_element", UTF16ToUTF8(form.password_element).c_str(),
"submit_element", UTF16ToUTF8(form.submit_element).c_str(),
"signon_realm", form.signon_realm.c_str(),
"application", app_string,
NULL);
}
void GKRMethod::GetLogins(const PasswordForm& form, const char* app_string) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
original_signon_realm_ = form.signon_realm;
ScopedAttributeList attrs(gnome_keyring_attribute_list_new());
if (!helper_.ShouldPSLDomainMatchingApply(
PSLMatchingHelper::GetRegistryControlledDomain(
GURL(form.signon_realm)))) {
AppendString(&attrs, "signon_realm", form.signon_realm);
}
AppendString(&attrs, "application", app_string);
gnome_keyring_find_items(GNOME_KEYRING_ITEM_GENERIC_SECRET,
attrs.get(),
OnOperationGetList,
this,
NULL);
}
void GKRMethod::GetLoginsList(uint32_t blacklisted_by_user,
const char* app_string) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
original_signon_realm_.clear();
ScopedAttributeList attrs(gnome_keyring_attribute_list_new());
AppendUint32(&attrs, "blacklisted_by_user", blacklisted_by_user);
AppendString(&attrs, "application", app_string);
gnome_keyring_find_items(GNOME_KEYRING_ITEM_GENERIC_SECRET,
attrs.get(),
OnOperationGetList,
this,
NULL);
}
void GKRMethod::GetAllLogins(const char* app_string) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
original_signon_realm_.clear();
ScopedAttributeList attrs(gnome_keyring_attribute_list_new());
AppendString(&attrs, "application", app_string);
gnome_keyring_find_items(GNOME_KEYRING_ITEM_GENERIC_SECRET,
attrs.get(),
OnOperationGetList,
this,
NULL);
}
GnomeKeyringResult GKRMethod::WaitResult() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
event_.Wait();
return result_;
}
GnomeKeyringResult GKRMethod::WaitResult(PasswordFormList* forms) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
event_.Wait();
if (forms->empty()) {
forms->swap(forms_);
} else {
forms->insert(forms->end(), forms_.begin(), forms_.end());
forms_.clear();
}
return result_;
}
void GKRMethod::AppendString(GKRMethod::ScopedAttributeList* list,
const char* name,
const char* value) {
gnome_keyring_attribute_list_append_string(list->get(), name, value);
}
void GKRMethod::AppendString(GKRMethod::ScopedAttributeList* list,
const char* name,
const std::string& value) {
AppendString(list, name, value.c_str());
}
void GKRMethod::AppendUint32(GKRMethod::ScopedAttributeList* list,
const char* name,
guint32 value) {
gnome_keyring_attribute_list_append_uint32(list->get(), name, value);
}
void GKRMethod::OnOperationDone(GnomeKeyringResult result, gpointer data) {
GKRMethod* method = static_cast<GKRMethod*>(data);
method->result_ = result;
method->event_.Signal();
}
void GKRMethod::OnOperationGetList(GnomeKeyringResult result, GList* list,
gpointer data) {
GKRMethod* method = static_cast<GKRMethod*>(data);
method->result_ = result;
method->forms_.clear();
ConvertFormList(
list, method->original_signon_realm_, method->helper_, &method->forms_);
method->original_signon_realm_.clear();
method->event_.Signal();
}
}
NativeBackendGnome::NativeBackendGnome(LocalProfileId id)
: profile_id_(id) {
app_string_ = GetProfileSpecificAppString();
}
NativeBackendGnome::~NativeBackendGnome() {
}
bool NativeBackendGnome::Init() {
return LoadGnomeKeyring() && gnome_keyring_is_available();
}
bool NativeBackendGnome::RawAddLogin(const PasswordForm& form) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
GKRMethod method;
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::Bind(&GKRMethod::AddLogin,
base::Unretained(&method),
form, app_string_.c_str()));
GnomeKeyringResult result = method.WaitResult();
if (result != GNOME_KEYRING_RESULT_OK) {
LOG(ERROR) << "Keyring save failed: "
<< gnome_keyring_result_to_message(result);
return false;
}
return true;
}
bool NativeBackendGnome::AddLogin(const PasswordForm& form) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
GKRMethod method;
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::Bind(&GKRMethod::AddLoginSearch,
base::Unretained(&method),
form, app_string_.c_str()));
PasswordFormList forms;
GnomeKeyringResult result = method.WaitResult(&forms);
if (result != GNOME_KEYRING_RESULT_OK &&
result != GNOME_KEYRING_RESULT_NO_MATCH) {
LOG(ERROR) << "Keyring find failed: "
<< gnome_keyring_result_to_message(result);
return false;
}
if (forms.size() > 0) {
if (forms.size() > 1) {
LOG(WARNING) << "Adding login when there are " << forms.size()
<< " matching logins already! Will replace only the first.";
}
RemoveLogin(*forms[0]);
for (size_t i = 0; i < forms.size(); ++i)
delete forms[i];
}
return RawAddLogin(form);
}
bool NativeBackendGnome::UpdateLogin(const PasswordForm& form) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
GKRMethod method;
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::Bind(&GKRMethod::UpdateLoginSearch,
base::Unretained(&method),
form, app_string_.c_str()));
PasswordFormList forms;
GnomeKeyringResult result = method.WaitResult(&forms);
if (result != GNOME_KEYRING_RESULT_OK) {
LOG(ERROR) << "Keyring find failed: "
<< gnome_keyring_result_to_message(result);
return false;
}
bool ok = true;
for (size_t i = 0; i < forms.size(); ++i) {
if (forms[i]->action != form.action ||
forms[i]->password_value != form.password_value ||
forms[i]->ssl_valid != form.ssl_valid ||
forms[i]->preferred != form.preferred ||
forms[i]->times_used != form.times_used) {
RemoveLogin(*forms[i]);
forms[i]->action = form.action;
forms[i]->password_value = form.password_value;
forms[i]->ssl_valid = form.ssl_valid;
forms[i]->preferred = form.preferred;
forms[i]->times_used = form.times_used;
if (!RawAddLogin(*forms[i]))
ok = false;
}
delete forms[i];
}
return ok;
}
bool NativeBackendGnome::RemoveLogin(const PasswordForm& form) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
GKRMethod method;
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::Bind(&GKRMethod::RemoveLogin,
base::Unretained(&method),
form, app_string_.c_str()));
GnomeKeyringResult result = method.WaitResult();
if (result != GNOME_KEYRING_RESULT_OK) {
LOG(WARNING) << "Keyring delete failed: "
<< gnome_keyring_result_to_message(result);
return false;
}
return true;
}
bool NativeBackendGnome::RemoveLoginsCreatedBetween(
const base::Time& delete_begin,
const base::Time& delete_end) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
bool ok = true;
PasswordFormList forms;
if (!GetAllLogins(&forms))
return false;
for (size_t i = 0; i < forms.size(); ++i) {
if (delete_begin <= forms[i]->date_created &&
(delete_end.is_null() || forms[i]->date_created < delete_end)) {
if (!RemoveLogin(*forms[i]))
ok = false;
}
delete forms[i];
}
return ok;
}
bool NativeBackendGnome::GetLogins(const PasswordForm& form,
PasswordFormList* forms) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
GKRMethod method;
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::Bind(&GKRMethod::GetLogins,
base::Unretained(&method),
form, app_string_.c_str()));
GnomeKeyringResult result = method.WaitResult(forms);
if (result == GNOME_KEYRING_RESULT_NO_MATCH)
return true;
if (result != GNOME_KEYRING_RESULT_OK) {
LOG(ERROR) << "Keyring find failed: "
<< gnome_keyring_result_to_message(result);
return false;
}
return true;
}
bool NativeBackendGnome::GetLoginsCreatedBetween(const base::Time& get_begin,
const base::Time& get_end,
PasswordFormList* forms) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
PasswordFormList all_forms;
if (!GetAllLogins(&all_forms))
return false;
forms->reserve(forms->size() + all_forms.size());
for (size_t i = 0; i < all_forms.size(); ++i) {
if (get_begin <= all_forms[i]->date_created &&
(get_end.is_null() || all_forms[i]->date_created < get_end)) {
forms->push_back(all_forms[i]);
} else {
delete all_forms[i];
}
}
return true;
}
bool NativeBackendGnome::GetAutofillableLogins(PasswordFormList* forms) {
return GetLoginsList(forms, true);
}
bool NativeBackendGnome::GetBlacklistLogins(PasswordFormList* forms) {
return GetLoginsList(forms, false);
}
bool NativeBackendGnome::GetLoginsList(PasswordFormList* forms,
bool autofillable) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
uint32_t blacklisted_by_user = !autofillable;
GKRMethod method;
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::Bind(&GKRMethod::GetLoginsList,
base::Unretained(&method),
blacklisted_by_user, app_string_.c_str()));
GnomeKeyringResult result = method.WaitResult(forms);
if (result == GNOME_KEYRING_RESULT_NO_MATCH)
return true;
if (result != GNOME_KEYRING_RESULT_OK) {
LOG(ERROR) << "Keyring find failed: "
<< gnome_keyring_result_to_message(result);
return false;
}
return true;
}
bool NativeBackendGnome::GetAllLogins(PasswordFormList* forms) {
GKRMethod method;
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::Bind(&GKRMethod::GetAllLogins,
base::Unretained(&method),
app_string_.c_str()));
GnomeKeyringResult result = method.WaitResult(forms);
if (result == GNOME_KEYRING_RESULT_NO_MATCH)
return true;
if (result != GNOME_KEYRING_RESULT_OK) {
LOG(ERROR) << "Keyring find failed: "
<< gnome_keyring_result_to_message(result);
return false;
}
return true;
}
std::string NativeBackendGnome::GetProfileSpecificAppString() const {
return base::StringPrintf("%s-%d", kGnomeKeyringAppString, profile_id_);
}