chore: modernize base::Value usage in WebRequest (#34667)
This commit is contained in:
parent
140c8d0d0a
commit
ad7aab8338
1 changed files with 6 additions and 5 deletions
|
@ -115,13 +115,12 @@ bool MatchesFilterCondition(extensions::WebRequestInfo* info,
|
||||||
// to pass the original keys.
|
// to pass the original keys.
|
||||||
v8::Local<v8::Value> HttpResponseHeadersToV8(
|
v8::Local<v8::Value> HttpResponseHeadersToV8(
|
||||||
net::HttpResponseHeaders* headers) {
|
net::HttpResponseHeaders* headers) {
|
||||||
base::DictionaryValue response_headers;
|
base::Value::Dict response_headers;
|
||||||
if (headers) {
|
if (headers) {
|
||||||
size_t iter = 0;
|
size_t iter = 0;
|
||||||
std::string key;
|
std::string key;
|
||||||
std::string value;
|
std::string value;
|
||||||
while (headers->EnumerateHeaderLines(&iter, &key, &value)) {
|
while (headers->EnumerateHeaderLines(&iter, &key, &value)) {
|
||||||
base::Value* values = response_headers.FindListKey(key);
|
|
||||||
// Note that Web servers not developed with nodejs allow non-utf8
|
// Note that Web servers not developed with nodejs allow non-utf8
|
||||||
// characters in content-disposition's filename field. Use Chromium's
|
// characters in content-disposition's filename field. Use Chromium's
|
||||||
// HttpContentDisposition class to decode the correct encoding instead of
|
// HttpContentDisposition class to decode the correct encoding instead of
|
||||||
|
@ -138,12 +137,14 @@ v8::Local<v8::Value> HttpResponseHeadersToV8(
|
||||||
std::string filename = "\"" + header.filename() + "\"";
|
std::string filename = "\"" + header.filename() + "\"";
|
||||||
value = decodedFilename + "; filename=" + filename;
|
value = decodedFilename + "; filename=" + filename;
|
||||||
}
|
}
|
||||||
|
base::Value::List* values = response_headers.FindList(key);
|
||||||
if (!values)
|
if (!values)
|
||||||
values = response_headers.SetKey(key, base::ListValue());
|
values = &response_headers.Set(key, base::Value::List())->GetList();
|
||||||
values->Append(value);
|
values->Append(base::Value(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return gin::ConvertToV8(v8::Isolate::GetCurrent(), response_headers);
|
return gin::ConvertToV8(v8::Isolate::GetCurrent(),
|
||||||
|
base::Value(std::move(response_headers)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Overloaded by multiple types to fill the |details| object.
|
// Overloaded by multiple types to fill the |details| object.
|
||||||
|
|
Loading…
Reference in a new issue