summaryrefslogtreecommitdiffstats
path: root/extensions/renderer
diff options
context:
space:
mode:
authorrdevlin.cronin <rdevlin.cronin@chromium.org>2015-10-29 16:41:29 -0700
committerCommit bot <commit-bot@chromium.org>2015-10-29 23:42:31 +0000
commita5ecbc86a598e29ce3a2424c9c5386bfba4e9b74 (patch)
treeb77a653a45eff6098aef9cf9f8a46a2e27aad335 /extensions/renderer
parent6dca6cf96d346d5a8868ab79746ad539e9880e51 (diff)
downloadchromium_src-a5ecbc86a598e29ce3a2424c9c5386bfba4e9b74.zip
chromium_src-a5ecbc86a598e29ce3a2424c9c5386bfba4e9b74.tar.gz
chromium_src-a5ecbc86a598e29ce3a2424c9c5386bfba4e9b74.tar.bz2
[Extensions] Make handler_function a hidden property
Fix the glitch and add a test. BUG=548273 Review URL: https://codereview.chromium.org/1422383003 Cr-Commit-Position: refs/heads/master@{#356985}
Diffstat (limited to 'extensions/renderer')
-rw-r--r--extensions/renderer/object_backed_native_handler.cc14
1 files changed, 9 insertions, 5 deletions
diff --git a/extensions/renderer/object_backed_native_handler.cc b/extensions/renderer/object_backed_native_handler.cc
index 879da23..45d2dd3 100644
--- a/extensions/renderer/object_backed_native_handler.cc
+++ b/extensions/renderer/object_backed_native_handler.cc
@@ -41,7 +41,8 @@ void ObjectBackedNativeHandler::Router(
v8::Local<v8::Object> data = args.Data().As<v8::Object>();
v8::Local<v8::Value> handler_function_value =
- data->Get(v8::String::NewFromUtf8(args.GetIsolate(), kHandlerFunction));
+ data->GetHiddenValue(
+ v8::String::NewFromUtf8(args.GetIsolate(), kHandlerFunction));
// See comment in header file for why we do this.
if (handler_function_value.IsEmpty() ||
handler_function_value->IsUndefined()) {
@@ -51,7 +52,9 @@ void ObjectBackedNativeHandler::Router(
"Extension view no longer exists");
return;
}
- DCHECK(handler_function_value->IsExternal());
+ // This CHECK is *important*. Otherwise, we'll go around happily executing
+ // something random. See crbug.com/548273.
+ CHECK(handler_function_value->IsExternal());
static_cast<HandlerFunction*>(
handler_function_value.As<v8::External>()->Value())->Run(args);
}
@@ -64,7 +67,7 @@ void ObjectBackedNativeHandler::RouteFunction(
v8::Context::Scope context_scope(context_->v8_context());
v8::Local<v8::Object> data = v8::Object::New(isolate);
- data->Set(
+ data->SetHiddenValue(
v8::String::NewFromUtf8(isolate, kHandlerFunction),
v8::External::New(isolate, new HandlerFunction(handler_function)));
v8::Local<v8::FunctionTemplate> function_template =
@@ -86,11 +89,12 @@ void ObjectBackedNativeHandler::Invalidate() {
for (size_t i = 0; i < router_data_.Size(); i++) {
v8::Local<v8::Object> data = router_data_.Get(i);
v8::Local<v8::Value> handler_function_value =
- data->Get(v8::String::NewFromUtf8(isolate, kHandlerFunction));
+ data->GetHiddenValue(
+ v8::String::NewFromUtf8(isolate, kHandlerFunction));
CHECK(!handler_function_value.IsEmpty());
delete static_cast<HandlerFunction*>(
handler_function_value.As<v8::External>()->Value());
- data->Delete(v8::String::NewFromUtf8(isolate, kHandlerFunction));
+ data->DeleteHiddenValue(v8::String::NewFromUtf8(isolate, kHandlerFunction));
}
router_data_.Clear();