diff --git a/native_mate/dictionary.h b/native_mate/dictionary.h index 38927c85374f..2eb52922d268 100644 --- a/native_mate/dictionary.h +++ b/native_mate/dictionary.h @@ -93,6 +93,19 @@ class Dictionary { return !result.IsNothing() && result.FromJust(); } + template + bool SetReadOnly(const base::StringPiece& key, T val) { + v8::Local v8_value; + if (!TryConvertToV8(isolate_, val, &v8_value)) + return false; + v8::Maybe result = + GetHandle()->DefineOwnProperty(isolate_->GetCurrentContext(), + StringToV8(isolate_, key), + v8_value, + v8::ReadOnly); + return !result.IsNothing() && result.FromJust(); + } + template bool SetMethod(const base::StringPiece& key, const T& callback) { return GetHandle()->Set(