#include "components/os_crypt/sync/key_storage_linux.h"
#include <memory>
#include "base/environment.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
#include "base/nix/xdg_util.h"
#include "base/no_destructor.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/sequenced_task_runner.h"
#include "base/threading/thread_restrictions.h"
#include "build/branding_buildflags.h"
#include "components/os_crypt/sync/key_storage_config_linux.h"
#if defined(USE_LIBSECRET)
#include "components/os_crypt/sync/key_storage_libsecret.h"
#endif
#if defined(USE_KWALLET)
#include "components/os_crypt/sync/key_storage_kwallet.h"
#endif
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
const char KeyStorageLinux::kFolderName[] = "Chrome Keys";
const char KeyStorageLinux::kKey[] = "Chrome Safe Storage";
#else
const char KeyStorageLinux::kFolderName[] = …;
const char KeyStorageLinux::kKey[] = …;
#endif
namespace {
enum class BackendUsage { … };
constexpr BackendUsage SelectedBackendToMetric(
os_crypt::SelectedLinuxBackend selection,
bool used) { … }
const char* SelectedLinuxBackendToString(
os_crypt::SelectedLinuxBackend selection) { … }
}
std::unique_ptr<KeyStorageLinux> KeyStorageLinux::CreateService(
const os_crypt::Config& config) { … }
#if defined(USE_LIBSECRET) || defined(USE_KWALLET)
std::unique_ptr<KeyStorageLinux> KeyStorageLinux::CreateServiceInternal(
os_crypt::SelectedLinuxBackend selected_backend,
const os_crypt::Config& config) { … }
#endif
bool KeyStorageLinux::WaitForInitOnTaskRunner() { … }
std::optional<std::string> KeyStorageLinux::GetKey() { … }
base::SequencedTaskRunner* KeyStorageLinux::GetTaskRunner() { … }
void KeyStorageLinux::BlockOnGetKeyImplThenSignal(
base::WaitableEvent* on_password_received,
std::optional<std::string>* password) { … }
void KeyStorageLinux::BlockOnInitThenSignal(base::WaitableEvent* on_inited,
bool* success) { … }