mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
Revert "feat: expose safestorage backend information on linux (#39107)"
This reverts commit 459fe0e68d.
This commit is contained in:
@@ -8,7 +8,6 @@
|
||||
|
||||
#include "components/os_crypt/sync/os_crypt.h"
|
||||
#include "shell/browser/browser.h"
|
||||
#include "shell/browser/browser_process_impl.h"
|
||||
#include "shell/common/gin_converters/base_converter.h"
|
||||
#include "shell/common/gin_converters/callback_converter.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
@@ -19,7 +18,14 @@ namespace electron::safestorage {
|
||||
|
||||
static const char* kEncryptionVersionPrefixV10 = "v10";
|
||||
static const char* kEncryptionVersionPrefixV11 = "v11";
|
||||
static bool use_password_v10 = false;
|
||||
|
||||
#if DCHECK_IS_ON()
|
||||
static bool electron_crypto_ready = false;
|
||||
|
||||
void SetElectronCryptoReady(bool ready) {
|
||||
electron_crypto_ready = ready;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool IsEncryptionAvailable() {
|
||||
#if BUILDFLAG(IS_LINUX)
|
||||
@@ -28,28 +34,10 @@ bool IsEncryptionAvailable() {
|
||||
// Refs: https://github.com/electron/electron/issues/32206.
|
||||
if (!Browser::Get()->is_ready())
|
||||
return false;
|
||||
return OSCrypt::IsEncryptionAvailable() ||
|
||||
(use_password_v10 &&
|
||||
static_cast<BrowserProcessImpl*>(g_browser_process)
|
||||
->GetLinuxStorageBackend() == "basic_text");
|
||||
#else
|
||||
#endif
|
||||
return OSCrypt::IsEncryptionAvailable();
|
||||
#endif
|
||||
}
|
||||
|
||||
void SetUsePasswordV10(bool use) {
|
||||
use_password_v10 = use;
|
||||
}
|
||||
|
||||
#if BUILDFLAG(IS_LINUX)
|
||||
std::string GetSelectedLinuxBackend() {
|
||||
if (!Browser::Get()->is_ready())
|
||||
return "unknown";
|
||||
return static_cast<BrowserProcessImpl*>(g_browser_process)
|
||||
->GetLinuxStorageBackend();
|
||||
}
|
||||
#endif
|
||||
|
||||
v8::Local<v8::Value> EncryptString(v8::Isolate* isolate,
|
||||
const std::string& plaintext) {
|
||||
if (!IsEncryptionAvailable()) {
|
||||
@@ -59,8 +47,8 @@ v8::Local<v8::Value> EncryptString(v8::Isolate* isolate,
|
||||
return v8::Local<v8::Value>();
|
||||
}
|
||||
gin_helper::ErrorThrower(isolate).ThrowError(
|
||||
"Error while encrypting the text provided to "
|
||||
"safeStorage.encryptString. "
|
||||
"Error while decrypting the ciphertext provided to "
|
||||
"safeStorage.decryptString. "
|
||||
"Encryption is not available.");
|
||||
return v8::Local<v8::Value>();
|
||||
}
|
||||
@@ -140,12 +128,6 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
&electron::safestorage::IsEncryptionAvailable);
|
||||
dict.SetMethod("encryptString", &electron::safestorage::EncryptString);
|
||||
dict.SetMethod("decryptString", &electron::safestorage::DecryptString);
|
||||
dict.SetMethod("setUsePlainTextEncryption",
|
||||
&electron::safestorage::SetUsePasswordV10);
|
||||
#if BUILDFLAG(IS_LINUX)
|
||||
dict.SetMethod("getSelectedStorageBackend",
|
||||
&electron::safestorage::GetSelectedLinuxBackend);
|
||||
#endif
|
||||
}
|
||||
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_safe_storage, Initialize)
|
||||
|
||||
Reference in New Issue
Block a user