refactor: replace deprecated base::Value::Set<Type>Key usage (#37570)
Co-authored-by: Milan Burda <miburda@microsoft.com>
This commit is contained in:
parent
061e2e5e73
commit
6dc46e5bcf
5 changed files with 52 additions and 62 deletions
|
@ -70,23 +70,23 @@ bool HidChooserContext::CanStorePersistentEntry(
|
||||||
// static
|
// static
|
||||||
base::Value HidChooserContext::DeviceInfoToValue(
|
base::Value HidChooserContext::DeviceInfoToValue(
|
||||||
const device::mojom::HidDeviceInfo& device) {
|
const device::mojom::HidDeviceInfo& device) {
|
||||||
base::Value value(base::Value::Type::DICT);
|
base::Value::Dict value;
|
||||||
value.SetStringKey(
|
value.Set(
|
||||||
kHidDeviceNameKey,
|
kHidDeviceNameKey,
|
||||||
base::UTF16ToUTF8(HidChooserContext::DisplayNameFromDeviceInfo(device)));
|
base::UTF16ToUTF8(HidChooserContext::DisplayNameFromDeviceInfo(device)));
|
||||||
value.SetIntKey(kDeviceVendorIdKey, device.vendor_id);
|
value.Set(kDeviceVendorIdKey, device.vendor_id);
|
||||||
value.SetIntKey(kDeviceProductIdKey, device.product_id);
|
value.Set(kDeviceProductIdKey, device.product_id);
|
||||||
if (HidChooserContext::CanStorePersistentEntry(device)) {
|
if (HidChooserContext::CanStorePersistentEntry(device)) {
|
||||||
// Use the USB serial number as a persistent identifier. If it is
|
// Use the USB serial number as a persistent identifier. If it is
|
||||||
// unavailable, only ephemeral permissions may be granted.
|
// unavailable, only ephemeral permissions may be granted.
|
||||||
value.SetStringKey(kDeviceSerialNumberKey, device.serial_number);
|
value.Set(kDeviceSerialNumberKey, device.serial_number);
|
||||||
} else {
|
} else {
|
||||||
// The GUID is a temporary ID created on connection that remains valid until
|
// The GUID is a temporary ID created on connection that remains valid until
|
||||||
// the device is disconnected. Ephemeral permissions are keyed by this ID
|
// the device is disconnected. Ephemeral permissions are keyed by this ID
|
||||||
// and must be granted again each time the device is connected.
|
// and must be granted again each time the device is connected.
|
||||||
value.SetStringKey(kHidGuidKey, device.guid);
|
value.Set(kHidGuidKey, device.guid);
|
||||||
}
|
}
|
||||||
return value;
|
return base::Value(std::move(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
void HidChooserContext::GrantDevicePermission(
|
void HidChooserContext::GrantDevicePermission(
|
||||||
|
|
|
@ -97,12 +97,12 @@ const size_t kMaxMessageChunkSize = IPC::Channel::kMaximumMessageSize / 4;
|
||||||
InspectableWebContents::List g_web_contents_instances_;
|
InspectableWebContents::List g_web_contents_instances_;
|
||||||
|
|
||||||
base::Value RectToDictionary(const gfx::Rect& bounds) {
|
base::Value RectToDictionary(const gfx::Rect& bounds) {
|
||||||
base::Value dict(base::Value::Type::DICT);
|
base::Value::Dict dict;
|
||||||
dict.SetKey("x", base::Value(bounds.x()));
|
dict.Set("x", bounds.x());
|
||||||
dict.SetKey("y", base::Value(bounds.y()));
|
dict.Set("y", bounds.y());
|
||||||
dict.SetKey("width", base::Value(bounds.width()));
|
dict.Set("width", bounds.width());
|
||||||
dict.SetKey("height", base::Value(bounds.height()));
|
dict.Set("height", bounds.height());
|
||||||
return dict;
|
return base::Value(std::move(dict));
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::Rect DictionaryToRect(const base::Value::Dict& dict) {
|
gfx::Rect DictionaryToRect(const base::Value::Dict& dict) {
|
||||||
|
@ -895,7 +895,7 @@ void InspectableWebContents::ClearPreferences() {
|
||||||
|
|
||||||
void InspectableWebContents::GetSyncInformation(DispatchCallback callback) {
|
void InspectableWebContents::GetSyncInformation(DispatchCallback callback) {
|
||||||
base::Value result(base::Value::Type::DICT);
|
base::Value result(base::Value::Type::DICT);
|
||||||
result.SetBoolKey("isSyncActive", false);
|
result.GetDict().Set("isSyncActive", false);
|
||||||
std::move(callback).Run(&result);
|
std::move(callback).Run(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,40 +82,35 @@ UsbChooserContext::UsbChooserContext(ElectronBrowserContext* context)
|
||||||
// static
|
// static
|
||||||
base::Value UsbChooserContext::DeviceInfoToValue(
|
base::Value UsbChooserContext::DeviceInfoToValue(
|
||||||
const device::mojom::UsbDeviceInfo& device_info) {
|
const device::mojom::UsbDeviceInfo& device_info) {
|
||||||
base::Value device_value(base::Value::Type::DICT);
|
base::Value::Dict device_value;
|
||||||
device_value.SetStringKey(kDeviceNameKey, device_info.product_name
|
device_value.Set(kDeviceNameKey, device_info.product_name
|
||||||
? *device_info.product_name
|
? *device_info.product_name
|
||||||
: base::StringPiece16());
|
: base::StringPiece16());
|
||||||
device_value.SetIntKey(kDeviceVendorIdKey, device_info.vendor_id);
|
device_value.Set(kDeviceVendorIdKey, device_info.vendor_id);
|
||||||
device_value.SetIntKey(kDeviceProductIdKey, device_info.product_id);
|
device_value.Set(kDeviceProductIdKey, device_info.product_id);
|
||||||
|
|
||||||
if (device_info.manufacturer_name) {
|
if (device_info.manufacturer_name) {
|
||||||
device_value.SetStringKey("manufacturerName",
|
device_value.Set("manufacturerName", *device_info.manufacturer_name);
|
||||||
*device_info.manufacturer_name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CanStorePersistentEntry checks if |device_info.serial_number| is not empty.
|
// CanStorePersistentEntry checks if |device_info.serial_number| is not empty.
|
||||||
if (CanStorePersistentEntry(device_info)) {
|
if (CanStorePersistentEntry(device_info)) {
|
||||||
device_value.SetStringKey(kDeviceSerialNumberKey,
|
device_value.Set(kDeviceSerialNumberKey, *device_info.serial_number);
|
||||||
*device_info.serial_number);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
device_value.SetStringKey(kDeviceIdKey, device_info.guid);
|
device_value.Set(kDeviceIdKey, device_info.guid);
|
||||||
|
|
||||||
device_value.SetIntKey("usbVersionMajor", device_info.usb_version_major);
|
device_value.Set("usbVersionMajor", device_info.usb_version_major);
|
||||||
device_value.SetIntKey("usbVersionMinor", device_info.usb_version_minor);
|
device_value.Set("usbVersionMinor", device_info.usb_version_minor);
|
||||||
device_value.SetIntKey("usbVersionSubminor",
|
device_value.Set("usbVersionSubminor", device_info.usb_version_subminor);
|
||||||
device_info.usb_version_subminor);
|
device_value.Set("deviceClass", device_info.class_code);
|
||||||
device_value.SetIntKey("deviceClass", device_info.class_code);
|
device_value.Set("deviceSubclass", device_info.subclass_code);
|
||||||
device_value.SetIntKey("deviceSubclass", device_info.subclass_code);
|
device_value.Set("deviceProtocol", device_info.protocol_code);
|
||||||
device_value.SetIntKey("deviceProtocol", device_info.protocol_code);
|
device_value.Set("deviceVersionMajor", device_info.device_version_major);
|
||||||
device_value.SetIntKey("deviceVersionMajor",
|
device_value.Set("deviceVersionMinor", device_info.device_version_minor);
|
||||||
device_info.device_version_major);
|
device_value.Set("deviceVersionSubminor",
|
||||||
device_value.SetIntKey("deviceVersionMinor",
|
|
||||||
device_info.device_version_minor);
|
|
||||||
device_value.SetIntKey("deviceVersionSubminor",
|
|
||||||
device_info.device_version_subminor);
|
device_info.device_version_subminor);
|
||||||
return device_value;
|
return base::Value(std::move(device_value));
|
||||||
}
|
}
|
||||||
|
|
||||||
void UsbChooserContext::InitDeviceList(
|
void UsbChooserContext::InitDeviceList(
|
||||||
|
|
|
@ -389,28 +389,23 @@ void WebContentsPreferences::AppendCommandLineSwitches(
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContentsPreferences::SaveLastPreferences() {
|
void WebContentsPreferences::SaveLastPreferences() {
|
||||||
last_web_preferences_ = base::Value(base::Value::Type::DICT);
|
base::Value::Dict dict;
|
||||||
last_web_preferences_.SetKey(options::kNodeIntegration,
|
dict.Set(options::kNodeIntegration, node_integration_);
|
||||||
base::Value(node_integration_));
|
dict.Set(options::kNodeIntegrationInSubFrames,
|
||||||
last_web_preferences_.SetKey(options::kNodeIntegrationInSubFrames,
|
node_integration_in_sub_frames_);
|
||||||
base::Value(node_integration_in_sub_frames_));
|
dict.Set(options::kSandbox, IsSandboxed());
|
||||||
last_web_preferences_.SetKey(options::kSandbox, base::Value(IsSandboxed()));
|
dict.Set(options::kContextIsolation, context_isolation_);
|
||||||
last_web_preferences_.SetKey(options::kContextIsolation,
|
dict.Set(options::kJavaScript, javascript_);
|
||||||
base::Value(context_isolation_));
|
dict.Set(options::kEnableWebSQL, enable_websql_);
|
||||||
last_web_preferences_.SetKey(options::kJavaScript, base::Value(javascript_));
|
dict.Set(options::kWebviewTag, webview_tag_);
|
||||||
last_web_preferences_.SetKey(options::kEnableWebSQL,
|
dict.Set("disablePopups", disable_popups_);
|
||||||
base::Value(enable_websql_));
|
dict.Set(options::kWebSecurity, web_security_);
|
||||||
last_web_preferences_.SetKey(options::kWebviewTag, base::Value(webview_tag_));
|
dict.Set(options::kAllowRunningInsecureContent,
|
||||||
last_web_preferences_.SetKey("disablePopups", base::Value(disable_popups_));
|
allow_running_insecure_content_);
|
||||||
last_web_preferences_.SetKey(options::kWebSecurity,
|
dict.Set(options::kExperimentalFeatures, experimental_features_);
|
||||||
base::Value(web_security_));
|
dict.Set(options::kEnableBlinkFeatures, enable_blink_features_.value_or(""));
|
||||||
last_web_preferences_.SetKey(options::kAllowRunningInsecureContent,
|
|
||||||
base::Value(allow_running_insecure_content_));
|
last_web_preferences_ = base::Value(std::move(dict));
|
||||||
last_web_preferences_.SetKey(options::kExperimentalFeatures,
|
|
||||||
base::Value(experimental_features_));
|
|
||||||
last_web_preferences_.SetKey(
|
|
||||||
options::kEnableBlinkFeatures,
|
|
||||||
base::Value(enable_blink_features_.value_or("")));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContentsPreferences::OverrideWebkitPrefs(
|
void WebContentsPreferences::OverrideWebkitPrefs(
|
||||||
|
|
|
@ -18,7 +18,7 @@ struct Converter<device::mojom::HidDeviceInfoPtr> {
|
||||||
v8::Isolate* isolate,
|
v8::Isolate* isolate,
|
||||||
const device::mojom::HidDeviceInfoPtr& device) {
|
const device::mojom::HidDeviceInfoPtr& device) {
|
||||||
base::Value value = electron::HidChooserContext::DeviceInfoToValue(*device);
|
base::Value value = electron::HidChooserContext::DeviceInfoToValue(*device);
|
||||||
value.SetStringKey(
|
value.GetDict().Set(
|
||||||
"deviceId",
|
"deviceId",
|
||||||
electron::HidChooserController::PhysicalDeviceIdFromDeviceInfo(
|
electron::HidChooserController::PhysicalDeviceIdFromDeviceInfo(
|
||||||
*device));
|
*device));
|
||||||
|
|
Loading…
Reference in a new issue