fix: avoid deprecated value apis (#37590)

* fix: use base::Value::Dict:::Remove() instead of RemoveKe()

the latter is deprecated.

* fix: use base::Value::Dict::FindString() instead of base::Value::FindStringKey()

The latter is deprecated.

* chore: make lint happy
This commit is contained in:
Charles Kerr 2023-03-20 09:38:45 -05:00 committed by GitHub
parent e0c348a2f8
commit caa5989eed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 11 deletions

View file

@ -607,13 +607,13 @@ int ImportIntoCertStore(CertificateManagerModel* model, base::Value options) {
net::ScopedCERTCertificateList imported_certs;
int rv = -1;
std::string* cert_path_ptr = options.FindStringKey("certificate");
if (cert_path_ptr)
cert_path = *cert_path_ptr;
if (const base::Value::Dict* dict = options.GetIfDict(); dict != nullptr) {
if (const std::string* str = dict->FindString("certificate"); str)
cert_path = *str;
std::string* pwd = options.FindStringKey("password");
if (pwd)
password = base::UTF8ToUTF16(*pwd);
if (const std::string* str = dict->FindString("password"); str)
password = base::UTF8ToUTF16(*str);
}
if (!cert_path.empty()) {
if (base::ReadFileToString(base::FilePath(cert_path), &file_data)) {

View file

@ -180,7 +180,10 @@ void UsbChooserContext::RevokeObjectPermissionInternal(
const url::Origin& origin,
const base::Value& object,
bool revoked_by_website = false) {
if (object.FindStringKey(kDeviceSerialNumberKey)) {
const base::Value::Dict* object_dict = object.GetIfDict();
DCHECK(object_dict != nullptr);
if (object_dict->FindString(kDeviceSerialNumberKey) != nullptr) {
auto* permission_manager = static_cast<ElectronPermissionManager*>(
browser_context_->GetPermissionControllerDelegate());
permission_manager->RevokeDevicePermission(
@ -188,7 +191,7 @@ void UsbChooserContext::RevokeObjectPermissionInternal(
WebContentsPermissionHelper::PermissionType::USB),
origin, object, browser_context_);
} else {
const std::string* guid = object.FindStringKey(kDeviceIdKey);
const std::string* guid = object_dict->FindString(kDeviceIdKey);
auto it = ephemeral_devices_.find(origin);
if (it != ephemeral_devices_.end()) {
it->second.erase(*guid);

View file

@ -123,10 +123,11 @@ void ZoomLevelDelegate::ExtractPerHostZoomLevels(
// have an empty host.
{
ScopedDictPrefUpdate update(pref_service_, kPartitionPerHostZoomLevels);
base::Value* sanitized_host_zoom_dictionary = update->Find(partition_key_);
base::Value::Dict* sanitized_host_zoom_dictionary =
update->FindDict(partition_key_);
if (sanitized_host_zoom_dictionary) {
for (const std::string& s : keys_to_remove)
sanitized_host_zoom_dictionary->RemoveKey(s);
for (const std::string& key : keys_to_remove)
sanitized_host_zoom_dictionary->Remove(key);
}
}
}