key_storage_util_linux.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. #ifndef COMPONENTS_OS_CRYPT_KEY_STORAGE_UTIL_LINUX_H_
  5. #define COMPONENTS_OS_CRYPT_KEY_STORAGE_UTIL_LINUX_H_
  6. #include <string>
  7. #include "base/component_export.h"
  8. #include "base/nix/xdg_util.h"
  9. namespace base {
  10. class FilePath;
  11. }
  12. namespace os_crypt {
  13. // The supported Linux backends for storing passwords.
  14. enum class SelectedLinuxBackend {
  15. DEFER, // No selection
  16. BASIC_TEXT,
  17. GNOME_ANY, // GNOME_KEYRING or GNOME_LIBSECRET, whichever is available.
  18. GNOME_KEYRING,
  19. GNOME_LIBSECRET,
  20. KWALLET,
  21. KWALLET5,
  22. };
  23. // Decide which backend to target. |type| is checked first. If it does not
  24. // match a supported backend and |use_backend| is true, |desktop_env| will be
  25. // used to decide.
  26. // TODO(crbug/571003): This is exposed as a utility only for password manager to
  27. // use. It should be merged into key_storage_linux, once no longer needed in
  28. // password manager.
  29. SelectedLinuxBackend COMPONENT_EXPORT(OS_CRYPT)
  30. SelectBackend(const std::string& type,
  31. bool use_backend,
  32. base::nix::DesktopEnvironment desktop_env);
  33. // Set the setting that disables using OS-level encryption. If |use| is true,
  34. // a backend will be used.
  35. bool COMPONENT_EXPORT(OS_CRYPT)
  36. WriteBackendUse(const base::FilePath& user_data_dir, bool use);
  37. // Decide whether the backend should be used based on the setting.
  38. bool COMPONENT_EXPORT(OS_CRYPT)
  39. GetBackendUse(const base::FilePath& user_data_dir);
  40. } // namespace os_crypt
  41. #endif // COMPONENTS_OS_CRYPT_KEY_STORAGE_UTIL_LINUX_H_