#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "chrome/renderer/trusted_vault_encryption_keys_extension.h"
#include <utility>
#include <vector>
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/metrics/histogram_functions.h"
#include "build/buildflag.h"
#include "chrome/common/trusted_vault_encryption_keys_extension.mojom.h"
#include "chrome/renderer/google_accounts_private_api_util.h"
#include "components/trusted_vault/features.h"
#include "components/trusted_vault/trusted_vault_histograms.h"
#include "components/trusted_vault/trusted_vault_server_constants.h"
#include "content/public/common/isolated_world_ids.h"
#include "content/public/renderer/chrome_object_extensions_utils.h"
#include "content/public/renderer/render_frame.h"
#include "device/fido/features.h"
#include "gin/arguments.h"
#include "gin/function_template.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/scheduler/web_agent_group_scheduler.h"
#include "third_party/blink/public/web/web_local_frame.h"
#include "v8/include/v8-array-buffer.h"
#include "v8/include/v8-context.h"
#include "v8/include/v8-function.h"
#include "v8/include/v8-object.h"
#include "v8/include/v8-primitive.h"
#if !BUILDFLAG(IS_ANDROID)
#include "components/trusted_vault/features.h"
#include "components/trusted_vault/trusted_vault_server_constants.h"
#endif
namespace {
std::vector<uint8_t> ArrayBufferAsBytes(
const v8::Local<v8::ArrayBuffer>& array_buffer) { … }
#if !BUILDFLAG(IS_ANDROID)
std::vector<chrome::mojom::TrustedVaultKeyPtr>
SyncEncryptionKeysToTrustedVaultKeys(
const v8::LocalVector<v8::ArrayBuffer>& encryption_keys,
int32_t last_key_version) { … }
bool ParseTrustedVaultKeyArray(
v8::Local<v8::Context> context,
v8::Local<v8::Array> array,
std::vector<chrome::mojom::TrustedVaultKeyPtr>* trusted_vault_keys) { … }
bool ParseTrustedVaultKeysFromMap(
v8::Local<v8::Context> context,
v8::Local<v8::Map> map,
base::flat_map<std::string, std::vector<chrome::mojom::TrustedVaultKeyPtr>>*
trusted_vault_keys) { … }
#endif
enum ValidArgs { … };
#if !BUILDFLAG(IS_ANDROID)
void RecordCallToSetSyncEncryptionKeysToUma(ValidArgs args) { … }
void RecordCallToSetClientEncryptionKeysToUma(ValidArgs args) { … }
#endif
void RecordCallToAddTrustedSyncEncryptionRecoveryMethodToUma(ValidArgs args) { … }
}
void TrustedVaultEncryptionKeysExtension::Create(content::RenderFrame* frame) { … }
TrustedVaultEncryptionKeysExtension::TrustedVaultEncryptionKeysExtension(
content::RenderFrame* frame)
: … { … }
TrustedVaultEncryptionKeysExtension::~TrustedVaultEncryptionKeysExtension() { … }
void TrustedVaultEncryptionKeysExtension::OnDestruct() { … }
void TrustedVaultEncryptionKeysExtension::DidCreateScriptContext(
v8::Local<v8::Context> v8_context,
int32_t world_id) { … }
void TrustedVaultEncryptionKeysExtension::Install() { … }
#if !BUILDFLAG(IS_ANDROID)
void TrustedVaultEncryptionKeysExtension::SetSyncEncryptionKeys(
gin::Arguments* args) { … }
void TrustedVaultEncryptionKeysExtension::SetClientEncryptionKeys(
gin::Arguments* args) { … }
#endif
void TrustedVaultEncryptionKeysExtension::
AddTrustedSyncEncryptionRecoveryMethod(gin::Arguments* args) { … }
void TrustedVaultEncryptionKeysExtension::RunCompletionCallback(
std::unique_ptr<v8::Global<v8::Function>> callback) { … }