Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(463)

Unified Diff: extensions/renderer/v8_helpers.h

Issue 1433293004: [Extensions] Don't allow gin::Define to be overridden (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « extensions/renderer/module_system.cc ('k') | gin/converter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/v8_helpers.h
diff --git a/extensions/renderer/v8_helpers.h b/extensions/renderer/v8_helpers.h
index 2bfeee8a6f3d73909da77a66b5aca5389e48adc2..0c9a47cde958f21d293bab21fd24613edec25304 100644
--- a/extensions/renderer/v8_helpers.h
+++ b/extensions/renderer/v8_helpers.h
@@ -7,6 +7,7 @@
#include <string.h>
+#include "base/strings/string_number_conversions.h"
#include "v8/include/v8.h"
namespace extensions {
@@ -56,19 +57,13 @@ inline bool IsEmptyOrUndefied(v8::Local<v8::Value> value) {
return value.IsEmpty() || value->IsUndefined();
}
-// SetProperty() family wraps V8::Object::Set(). Returns true on success.
+// SetProperty() family wraps V8::Object::DefineOwnProperty().
+// Returns true on success.
inline bool SetProperty(v8::Local<v8::Context> context,
v8::Local<v8::Object> object,
- v8::Local<v8::Value> key,
+ v8::Local<v8::String> key,
v8::Local<v8::Value> value) {
- return IsTrue(object->Set(context, key, value));
-}
-
-inline bool SetProperty(v8::Local<v8::Context> context,
- v8::Local<v8::Object> object,
- uint32_t index,
- v8::Local<v8::Value> value) {
- return IsTrue(object->Set(context, index, value));
+ return IsTrue(object->DefineOwnProperty(context, key, value));
}
inline bool SetProperty(v8::Local<v8::Context> context,
@@ -81,6 +76,13 @@ inline bool SetProperty(v8::Local<v8::Context> context,
return SetProperty(context, object, v8_key, value);
}
+inline bool SetProperty(v8::Local<v8::Context> context,
+ v8::Local<v8::Object> object,
+ uint32_t index,
+ v8::Local<v8::Value> value) {
+ return SetProperty(context, object, base::UintToString(index).c_str(), value);
+}
+
// GetProperty() family calls V8::Object::Get() and extracts a value from
// returned MaybeLocal. Returns true on success.
template <typename Key>
« no previous file with comments | « extensions/renderer/module_system.cc ('k') | gin/converter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698