diff --git a/shell/browser/electron_browser_context.cc b/shell/browser/electron_browser_context.cc index f58154a7368..71c92731110 100644 --- a/shell/browser/electron_browser_context.cc +++ b/shell/browser/electron_browser_context.cc @@ -329,10 +329,8 @@ void ElectronBrowserContext::InitPrefs() { #endif #if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER) - base::Value::List current_dictionaries = - prefs()->GetList(spellcheck::prefs::kSpellCheckDictionaries).Clone(); // No configured dictionaries, the default will be en-US - if (current_dictionaries.empty()) { + if (prefs()->GetList(spellcheck::prefs::kSpellCheckDictionaries).empty()) { std::string default_code = spellcheck::GetCorrespondingSpellCheckLanguage( base::i18n::GetConfiguredLocale()); if (!default_code.empty()) { diff --git a/shell/browser/mac/dict_util.mm b/shell/browser/mac/dict_util.mm index 1d31185bc5a..dec0d95069e 100644 --- a/shell/browser/mac/dict_util.mm +++ b/shell/browser/mac/dict_util.mm @@ -14,7 +14,7 @@ namespace electron { NSArray* ListValueToNSArray(const base::Value::List& value) { std::string json; - if (!base::JSONWriter::Write(base::Value(value.Clone()), &json)) + if (!base::JSONWriter::Write(base::ValueView{value}, &json)) return nil; NSData* jsonData = [NSData dataWithBytes:json.c_str() length:json.length()]; id obj = [NSJSONSerialization JSONObjectWithData:jsonData @@ -57,7 +57,7 @@ base::Value::List NSArrayToValue(NSArray* arr) { NSDictionary* DictionaryValueToNSDictionary(const base::Value::Dict& value) { std::string json; - if (!base::JSONWriter::Write(base::Value(value.Clone()), &json)) + if (!base::JSONWriter::Write(base::ValueView{value}, &json)) return nil; NSData* jsonData = [NSData dataWithBytes:json.c_str() length:json.length()]; id obj = [NSJSONSerialization JSONObjectWithData:jsonData diff --git a/shell/browser/usb/usb_chooser_context.cc b/shell/browser/usb/usb_chooser_context.cc index 0d4e01141c3..593987ebf6e 100644 --- a/shell/browser/usb/usb_chooser_context.cc +++ b/shell/browser/usb/usb_chooser_context.cc @@ -206,7 +206,7 @@ void UsbChooserContext::RevokeObjectPermissionInternal( v8::HandleScope scope(isolate); gin_helper::Dictionary details = gin_helper::Dictionary::CreateEmpty(isolate); - details.Set("device", object.Clone()); + details.Set("device", object); details.Set("origin", origin.Serialize()); session->Emit("usb-device-revoked", details); } diff --git a/shell/common/gin_converters/extension_converter.cc b/shell/common/gin_converters/extension_converter.cc index 1840aed86b9..7111b17d821 100644 --- a/shell/common/gin_converters/extension_converter.cc +++ b/shell/common/gin_converters/extension_converter.cc @@ -22,7 +22,7 @@ v8::Local Converter::ToV8( dict.Set("path", extension->path()); dict.Set("url", extension->url()); dict.Set("version", extension->VersionString()); - dict.Set("manifest", extension->manifest()->value()->Clone()); + dict.Set("manifest", *extension->manifest()->value()); return gin::ConvertToV8(isolate, dict); } diff --git a/shell/common/gin_converters/value_converter.cc b/shell/common/gin_converters/value_converter.cc index 8510f50a0ef..7954ec1ee5e 100644 --- a/shell/common/gin_converters/value_converter.cc +++ b/shell/common/gin_converters/value_converter.cc @@ -25,14 +25,6 @@ bool Converter::FromV8(v8::Isolate* isolate, } } -v8::Local Converter::ToV8( - v8::Isolate* isolate, - const base::Value::Dict& val) { - base::Value value(val.Clone()); - return content::V8ValueConverter::Create()->ToV8Value( - value, isolate->GetCurrentContext()); -} - bool Converter::FromV8(v8::Isolate* isolate, v8::Local val, base::Value* out) { @@ -47,8 +39,9 @@ bool Converter::FromV8(v8::Isolate* isolate, } } -v8::Local Converter::ToV8(v8::Isolate* isolate, - const base::Value& val) { +v8::Local Converter::ToV8( + v8::Isolate* isolate, + const base::ValueView val) { return content::V8ValueConverter::Create()->ToV8Value( val, isolate->GetCurrentContext()); } @@ -67,12 +60,4 @@ bool Converter::FromV8(v8::Isolate* isolate, } } -v8::Local Converter::ToV8( - v8::Isolate* isolate, - const base::Value::List& val) { - base::Value value(val.Clone()); - return content::V8ValueConverter::Create()->ToV8Value( - value, isolate->GetCurrentContext()); -} - } // namespace gin diff --git a/shell/common/gin_converters/value_converter.h b/shell/common/gin_converters/value_converter.h index a5c7996883d..a3d294f431a 100644 --- a/shell/common/gin_converters/value_converter.h +++ b/shell/common/gin_converters/value_converter.h @@ -10,13 +10,21 @@ namespace gin { +template <> +struct Converter { + static v8::Local ToV8(v8::Isolate* isolate, + const base::ValueView val); +}; + template <> struct Converter { static bool FromV8(v8::Isolate* isolate, v8::Local val, base::Value::Dict* out); static v8::Local ToV8(v8::Isolate* isolate, - const base::Value::Dict& val); + const base::Value::Dict& val) { + return gin::ConvertToV8(isolate, base::ValueView{val}); + } }; template <> @@ -25,7 +33,9 @@ struct Converter { v8::Local val, base::Value* out); static v8::Local ToV8(v8::Isolate* isolate, - const base::Value& val); + const base::Value& val) { + return gin::ConvertToV8(isolate, base::ValueView{val}); + } }; template <> @@ -34,7 +44,9 @@ struct Converter { v8::Local val, base::Value::List* out); static v8::Local ToV8(v8::Isolate* isolate, - const base::Value::List& val); + const base::Value::List& val) { + return gin::ConvertToV8(isolate, base::ValueView{val}); + } }; } // namespace gin