fix: base::Value::Dict -> base::DictValue

https://chromium-review.googlesource.com/c/chromium/src/+/7513889
This commit is contained in:
Samuel Maddock
2026-02-02 19:51:38 -05:00
parent 1e0bbc3c08
commit a144b12f49
85 changed files with 323 additions and 331 deletions

View File

@@ -339,7 +339,7 @@ float NativeImage::GetAspectRatio(const std::optional<float> scale_factor) {
}
gin_helper::Handle<NativeImage> NativeImage::Resize(gin::Arguments* args,
base::Value::Dict options) {
base::DictValue options) {
float scale_factor = GetScaleFactorFromOptions(args);
gfx::Size size = GetSize(scale_factor);

View File

@@ -117,7 +117,7 @@ class NativeImage final : public gin_helper::DeprecatedWrappable<NativeImage> {
v8::Local<v8::Value> GetBitmap(gin::Arguments* args);
v8::Local<v8::Value> GetNativeHandle(gin_helper::ErrorThrower thrower);
gin_helper::Handle<NativeImage> Resize(gin::Arguments* args,
base::Value::Dict options);
base::DictValue options);
gin_helper::Handle<NativeImage> Crop(v8::Isolate* isolate,
const gfx::Rect& rect);
std::string ToDataURL(gin::Arguments* args);

View File

@@ -37,16 +37,16 @@ const char kSeparators[] = "\\/";
const char kSeparators[] = "/";
#endif
const base::Value::Dict* GetNodeFromPath(std::string path,
const base::Value::Dict& root);
const base::DictValue* GetNodeFromPath(std::string path,
const base::DictValue& root);
// Gets the "files" from "dir".
const base::Value::Dict* GetFilesNode(const base::Value::Dict& root,
const base::Value::Dict& dir) {
const base::DictValue* GetFilesNode(const base::DictValue& root,
const base::DictValue& dir) {
// Test for symbol linked directory.
const std::string* link = dir.FindString("link");
if (link != nullptr) {
const base::Value::Dict* linked_node = GetNodeFromPath(*link, root);
const base::DictValue* linked_node = GetNodeFromPath(*link, root);
if (!linked_node)
return nullptr;
return linked_node->FindDict("files");
@@ -56,27 +56,27 @@ const base::Value::Dict* GetFilesNode(const base::Value::Dict& root,
}
// Gets sub-file "name" from "dir".
const base::Value::Dict* GetChildNode(const base::Value::Dict& root,
const std::string& name,
const base::Value::Dict& dir) {
const base::DictValue* GetChildNode(const base::DictValue& root,
const std::string& name,
const base::DictValue& dir) {
if (name.empty())
return &root;
const base::Value::Dict* files = GetFilesNode(root, dir);
const base::DictValue* files = GetFilesNode(root, dir);
return files ? files->FindDict(name) : nullptr;
}
// Gets the node of "path" from "root".
const base::Value::Dict* GetNodeFromPath(std::string path,
const base::Value::Dict& root) {
const base::DictValue* GetNodeFromPath(std::string path,
const base::DictValue& root) {
if (path.empty())
return &root;
const base::Value::Dict* dir = &root;
const base::DictValue* dir = &root;
for (size_t delimiter_position = path.find_first_of(kSeparators);
delimiter_position != std::string::npos;
delimiter_position = path.find_first_of(kSeparators)) {
const base::Value::Dict* child =
const base::DictValue* child =
GetChildNode(root, path.substr(0, delimiter_position), *dir);
if (!child)
return nullptr;
@@ -91,7 +91,7 @@ const base::Value::Dict* GetNodeFromPath(std::string path,
bool FillFileInfoWithNode(Archive::FileInfo* info,
uint32_t header_size,
bool load_integrity,
const base::Value::Dict* node) {
const base::DictValue* node) {
if (std::optional<int> size = node->FindInt("size")) {
info->size = static_cast<uint32_t>(*size);
} else {
@@ -120,11 +120,11 @@ bool FillFileInfoWithNode(Archive::FileInfo* info,
#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN)
if (load_integrity &&
electron::fuses::IsEmbeddedAsarIntegrityValidationEnabled()) {
if (const base::Value::Dict* integrity = node->FindDict("integrity")) {
if (const base::DictValue* integrity = node->FindDict("integrity")) {
const std::string* algorithm = integrity->FindString("algorithm");
const std::string* hash = integrity->FindString("hash");
std::optional<int> block_size = integrity->FindInt("blockSize");
const base::Value::List* blocks = integrity->FindList("blocks");
const base::ListValue* blocks = integrity->FindList("blocks");
if (algorithm && hash && block_size && block_size > 0 && blocks) {
IntegrityPayload integrity_payload;
@@ -281,8 +281,7 @@ bool Archive::GetFileInfo(const base::FilePath& path, FileInfo* info) const {
if (!header_)
return false;
const base::Value::Dict* node =
GetNodeFromPath(path.AsUTF8Unsafe(), *header_);
const base::DictValue* node = GetNodeFromPath(path.AsUTF8Unsafe(), *header_);
if (!node)
return false;
@@ -297,8 +296,7 @@ bool Archive::Stat(const base::FilePath& path, Stats* stats) const {
if (!header_)
return false;
const base::Value::Dict* node =
GetNodeFromPath(path.AsUTF8Unsafe(), *header_);
const base::DictValue* node = GetNodeFromPath(path.AsUTF8Unsafe(), *header_);
if (!node)
return false;
@@ -320,12 +318,11 @@ bool Archive::Readdir(const base::FilePath& path,
if (!header_)
return false;
const base::Value::Dict* node =
GetNodeFromPath(path.AsUTF8Unsafe(), *header_);
const base::DictValue* node = GetNodeFromPath(path.AsUTF8Unsafe(), *header_);
if (!node)
return false;
const base::Value::Dict* files_node = GetFilesNode(*header_, *node);
const base::DictValue* files_node = GetFilesNode(*header_, *node);
if (!files_node)
return false;
@@ -339,8 +336,7 @@ bool Archive::Realpath(const base::FilePath& path,
if (!header_)
return false;
const base::Value::Dict* node =
GetNodeFromPath(path.AsUTF8Unsafe(), *header_);
const base::DictValue* node = GetNodeFromPath(path.AsUTF8Unsafe(), *header_);
if (!node)
return false;

View File

@@ -106,7 +106,7 @@ class Archive {
base::File file_{base::File::FILE_OK};
int fd_ = -1;
uint32_t header_size_ = 0;
std::optional<base::Value::Dict> header_;
std::optional<base::DictValue> header_;
// Cached external temporary files.
base::Lock external_files_lock_;

View File

@@ -78,7 +78,7 @@ auto LoadIntegrityConfig() {
LOG(FATAL) << "Invalid integrity config: NOT a valid JSON.";
}
const base::Value::List* file_configs = root.value().GetIfList();
const base::ListValue* file_configs = root.value().GetIfList();
if (!file_configs) {
LOG(FATAL) << "Invalid integrity config: NOT a list.";
}
@@ -87,7 +87,7 @@ auto LoadIntegrityConfig() {
cache.reserve(file_configs->size());
for (size_t i = 0; i < file_configs->size(); i++) {
// Skip invalid file configs
const base::Value::Dict* ele_dict = (*file_configs)[i].GetIfDict();
const base::DictValue* ele_dict = (*file_configs)[i].GetIfDict();
if (!ele_dict) {
LOG(WARNING) << "Skip config " << i << ": NOT a valid dict";
continue;

View File

@@ -19,11 +19,11 @@ struct Converter<device::mojom::HidDeviceInfoPtr> {
v8::Isolate* isolate,
const device::mojom::HidDeviceInfoPtr& device) {
base::Value value = electron::HidChooserContext::DeviceInfoToValue(*device);
base::Value::Dict& dict = value.GetDict();
base::DictValue& dict = value.GetDict();
dict.Set("deviceId",
electron::HidChooserController::PhysicalDeviceIdFromDeviceInfo(
*device));
return gin::Converter<base::Value::Dict>::ToV8(isolate, dict);
return gin::Converter<base::DictValue>::ToV8(isolate, dict);
}
};

View File

@@ -164,16 +164,16 @@ v8::Local<v8::Value> Converter<net::CertPrincipal>::ToV8(
v8::Local<v8::Value> Converter<net::HttpResponseHeaders*>::ToV8(
v8::Isolate* isolate,
net::HttpResponseHeaders* headers) {
base::Value::Dict response_headers;
base::DictValue response_headers;
if (headers) {
size_t iter = 0;
std::string key;
std::string value;
while (headers->EnumerateHeaderLines(&iter, &key, &value)) {
key = base::ToLowerASCII(key);
base::Value::List* values = response_headers.FindList(key);
base::ListValue* values = response_headers.FindList(key);
if (!values)
values = &response_headers.Set(key, base::Value::List())->GetList();
values = &response_headers.Set(key, base::ListValue())->GetList();
values->Append(value);
}
}
@@ -245,7 +245,7 @@ v8::Local<v8::Value> Converter<net::HttpRequestHeaders>::ToV8(
bool Converter<net::HttpRequestHeaders>::FromV8(v8::Isolate* isolate,
v8::Local<v8::Value> val,
net::HttpRequestHeaders* out) {
base::Value::Dict dict;
base::DictValue dict;
if (!ConvertFromV8(isolate, val, &dict))
return false;
for (const auto it : dict) {
@@ -588,12 +588,12 @@ bool Converter<scoped_refptr<network::ResourceRequestBody>>::FromV8(
base::Value list_value;
if (!ConvertFromV8(isolate, val, &list_value) || !list_value.is_list())
return false;
base::Value::List& list = list_value.GetList();
base::ListValue& list = list_value.GetList();
*out = base::MakeRefCounted<network::ResourceRequestBody>();
for (base::Value& dict_value : list) {
if (!dict_value.is_dict())
return false;
base::Value::Dict& dict = dict_value.GetDict();
base::DictValue& dict = dict_value.GetDict();
std::string* type = dict.FindString("type");
if (!type)
return false;

View File

@@ -11,9 +11,9 @@
namespace gin {
bool Converter<base::Value::Dict>::FromV8(v8::Isolate* isolate,
v8::Local<v8::Value> val,
base::Value::Dict* out) {
bool Converter<base::DictValue>::FromV8(v8::Isolate* isolate,
v8::Local<v8::Value> val,
base::DictValue* out) {
std::unique_ptr<base::Value> value =
content::V8ValueConverter::Create()->FromV8Value(
val, isolate->GetCurrentContext());
@@ -46,9 +46,9 @@ v8::Local<v8::Value> Converter<base::ValueView>::ToV8(
val, isolate->GetCurrentContext());
}
bool Converter<base::Value::List>::FromV8(v8::Isolate* isolate,
v8::Local<v8::Value> val,
base::Value::List* out) {
bool Converter<base::ListValue>::FromV8(v8::Isolate* isolate,
v8::Local<v8::Value> val,
base::ListValue* out) {
std::unique_ptr<base::Value> value =
content::V8ValueConverter::Create()->FromV8Value(
val, isolate->GetCurrentContext());

View File

@@ -17,12 +17,12 @@ struct Converter<base::ValueView> {
};
template <>
struct Converter<base::Value::Dict> {
struct Converter<base::DictValue> {
static bool FromV8(v8::Isolate* isolate,
v8::Local<v8::Value> val,
base::Value::Dict* out);
base::DictValue* out);
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
const base::Value::Dict& val) {
const base::DictValue& val) {
return gin::ConvertToV8(isolate, base::ValueView{val});
}
};
@@ -39,12 +39,12 @@ struct Converter<base::Value> {
};
template <>
struct Converter<base::Value::List> {
struct Converter<base::ListValue> {
static bool FromV8(v8::Isolate* isolate,
v8::Local<v8::Value> val,
base::Value::List* out);
base::ListValue* out);
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
const base::Value::List& val) {
const base::ListValue& val) {
return gin::ConvertToV8(isolate, base::ValueView{val});
}
};

View File

@@ -115,7 +115,7 @@ node::Environment* CreateEnvironment(v8::Isolate* isolate,
node::Environment* env = node::CreateEnvironment(isolate_data, context, args,
exec_args, env_flags);
if (auto message = try_catch.Message(); !message.IsEmpty()) {
base::Value::Dict dict;
base::DictValue dict;
if (std::string str; gin::ConvertFromV8(isolate, message->Get(), &str))
dict.Set("message", std::move(str));