diff options
author | kalman <kalman@chromium.org> | 2015-08-03 10:37:54 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-03 17:39:13 +0000 |
commit | 68c06a78f74212907faafd985b0bdee67a6d4120 (patch) | |
tree | c464355b5949866920710d8436140059e08cdda4 /extensions/renderer/v8_helpers.h | |
parent | 3e2da6cc92da25757ec456d56c0ce4d84531ed1a (diff) | |
download | chromium_src-68c06a78f74212907faafd985b0bdee67a6d4120.zip chromium_src-68c06a78f74212907faafd985b0bdee67a6d4120.tar.gz chromium_src-68c06a78f74212907faafd985b0bdee67a6d4120.tar.bz2 |
Convert extensions::SafeBuiltins from a v8::Extension to a NativeHandler.
This removes the last v8::Extension in extensions code. It's also needed to
support extension bindings in worker contexts, which don't support registering
v8::Extensions.
BUG=383974, 501569
R=rdevlin.cronin@chromium.org, jochen@chromium.org
Review URL: https://codereview.chromium.org/1262983003
Cr-Commit-Position: refs/heads/master@{#341545}
Diffstat (limited to 'extensions/renderer/v8_helpers.h')
-rw-r--r-- | extensions/renderer/v8_helpers.h | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/extensions/renderer/v8_helpers.h b/extensions/renderer/v8_helpers.h index 2bfeee8..e9ac61c 100644 --- a/extensions/renderer/v8_helpers.h +++ b/extensions/renderer/v8_helpers.h @@ -52,7 +52,7 @@ inline bool IsTrue(v8::Maybe<bool> maybe) { } // Returns true if |value| is empty or undefined. -inline bool IsEmptyOrUndefied(v8::Local<v8::Value> value) { +inline bool IsEmptyOrUndefined(v8::Local<v8::Value> value) { return value.IsEmpty() || value->IsUndefined(); } @@ -119,6 +119,24 @@ inline v8::Local<v8::Value> GetPropertyUnsafe( .ToLocalChecked(); } +// DeletePropertyUnsafe() family wraps v8::Object::Delete(). They crash when an +// exception is thrown. +inline bool DeletePropertyUnsafe(v8::Local<v8::Context> context, + v8::Local<v8::Object> object, + v8::Local<v8::Value> key) { + return object->Delete(context, key).FromJust(); +} + +inline bool DeletePropertyUnsafe( + v8::Local<v8::Context> context, + v8::Local<v8::Object> object, + const char* key, + v8::NewStringType string_type = v8::NewStringType::kNormal) { + return object->Delete(context, ToV8StringUnsafe(context->GetIsolate(), key, + string_type)) + .FromJust(); +} + // Wraps v8::Function::Call(). Returns true on success. inline bool CallFunction(v8::Local<v8::Context> context, v8::Local<v8::Function> function, |