summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjochen <jochen@chromium.org>2015-10-26 16:36:05 -0700
committerCommit bot <commit-bot@chromium.org>2015-10-26 23:37:04 +0000
commite142df2d590699c6a8b38cc56d6a763b3d185686 (patch)
treeb2cf38233557539621eaf94a5f413dcc012638ef
parent3ce04b6e31fdcfe9d0cae5b4c116b57ed0dea81a (diff)
downloadchromium_src-e142df2d590699c6a8b38cc56d6a763b3d185686.zip
chromium_src-e142df2d590699c6a8b38cc56d6a763b3d185686.tar.gz
chromium_src-e142df2d590699c6a8b38cc56d6a763b3d185686.tar.bz2
Use new-style V8 access check callbacks
Next step is to actually do the access check with the passed context. BUG=none R=haraken@chromium.org Review URL: https://codereview.chromium.org/1419013004 Cr-Commit-Position: refs/heads/master@{#356177}
-rw-r--r--third_party/WebKit/Source/bindings/core/v8/WindowProxy.cpp2
-rw-r--r--third_party/WebKit/Source/bindings/core/v8/custom/V8WindowCustom.cpp10
-rw-r--r--third_party/WebKit/Source/bindings/templates/interface.h3
-rw-r--r--third_party/WebKit/Source/bindings/templates/interface_base.cpp13
-rw-r--r--third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceCheckSecurity.cpp13
5 files changed, 13 insertions, 28 deletions
diff --git a/third_party/WebKit/Source/bindings/core/v8/WindowProxy.cpp b/third_party/WebKit/Source/bindings/core/v8/WindowProxy.cpp
index 9accf18..5cef9ae 100644
--- a/third_party/WebKit/Source/bindings/core/v8/WindowProxy.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/WindowProxy.cpp
@@ -273,7 +273,7 @@ namespace {
void configureInnerGlobalObjectTemplate(v8::Local<v8::ObjectTemplate> templ, v8::Isolate* isolate)
{
// Install a security handler with V8.
- templ->SetAccessCheckCallbacks(V8Window::namedSecurityCheckCustom, V8Window::indexedSecurityCheckCustom, v8::External::New(isolate, const_cast<WrapperTypeInfo*>(&V8Window::wrapperTypeInfo)));
+ templ->SetAccessCheckCallback(V8Window::securityCheckCustom, v8::External::New(isolate, const_cast<WrapperTypeInfo*>(&V8Window::wrapperTypeInfo)));
templ->SetInternalFieldCount(V8Window::internalFieldCount);
}
diff --git a/third_party/WebKit/Source/bindings/core/v8/custom/V8WindowCustom.cpp b/third_party/WebKit/Source/bindings/core/v8/custom/V8WindowCustom.cpp
index 37114ff..f8ea4e3 100644
--- a/third_party/WebKit/Source/bindings/core/v8/custom/V8WindowCustom.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/custom/V8WindowCustom.cpp
@@ -385,14 +385,10 @@ static bool securityCheck(v8::Local<v8::Object> host)
return BindingSecurity::shouldAllowAccessToFrame(isolate, target, DoNotReportSecurityError);
}
-bool V8Window::namedSecurityCheckCustom(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8::AccessType type, v8::Local<v8::Value>)
+bool V8Window::securityCheckCustom(v8::Local<v8::Context> accessingContext, v8::Local<v8::Object> accessedObject)
{
- return securityCheck(host);
-}
-
-bool V8Window::indexedSecurityCheckCustom(v8::Local<v8::Object> host, uint32_t index, v8::AccessType type, v8::Local<v8::Value>)
-{
- return securityCheck(host);
+ // TODO(jochen): Take accessingContext into account.
+ return securityCheck(accessedObject);
}
} // namespace blink
diff --git a/third_party/WebKit/Source/bindings/templates/interface.h b/third_party/WebKit/Source/bindings/templates/interface.h
index d3ccb9d..8a7d105 100644
--- a/third_party/WebKit/Source/bindings/templates/interface.h
+++ b/third_party/WebKit/Source/bindings/templates/interface.h
@@ -164,8 +164,7 @@ public:
static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + {{custom_internal_field_counter}};
{# End custom internal fields #}
{% if interface_name == 'Window' %}
- static bool namedSecurityCheckCustom(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8::AccessType, v8::Local<v8::Value> data);
- static bool indexedSecurityCheckCustom(v8::Local<v8::Object> host, uint32_t index, v8::AccessType, v8::Local<v8::Value> data);
+ static bool securityCheckCustom(v8::Local<v8::Context> accessingContext, v8::Local<v8::Object> accessedObject);
{% endif %}
static void installConditionallyEnabledProperties(v8::Local<v8::Object>, v8::Isolate*){% if has_conditional_attributes %};
{% else %} { }
diff --git a/third_party/WebKit/Source/bindings/templates/interface_base.cpp b/third_party/WebKit/Source/bindings/templates/interface_base.cpp
index 9787c87..8739861 100644
--- a/third_party/WebKit/Source/bindings/templates/interface_base.cpp
+++ b/third_party/WebKit/Source/bindings/templates/interface_base.cpp
@@ -128,15 +128,10 @@ static void {{cpp_class}}ConstructorAttributeSetterCallback(v8::Local<v8::Name>,
{##############################################################################}
{% block security_check_functions %}
{% if has_access_check_callbacks %}
-bool indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t index, v8::AccessType type, v8::Local<v8::Value>)
+bool securityCheck(v8::Local<v8::Context> accessingContext, v8::Local<v8::Object> accessedObject)
{
- {{cpp_class}}* impl = {{v8_class}}::toImpl(host);
- return BindingSecurity::shouldAllowAccessToFrame(v8::Isolate::GetCurrent(), impl->frame(), DoNotReportSecurityError);
-}
-
-bool namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8::AccessType type, v8::Local<v8::Value>)
-{
- {{cpp_class}}* impl = {{v8_class}}::toImpl(host);
+ // TODO(jochen): Take accessingContext into account.
+ {{cpp_class}}* impl = {{v8_class}}::toImpl(accessedObject);
return BindingSecurity::shouldAllowAccessToFrame(v8::Isolate::GetCurrent(), impl->frame(), DoNotReportSecurityError);
}
@@ -346,7 +341,7 @@ static void install{{v8_class}}Template(v8::Local<v8::FunctionTemplate> function
ALLOW_UNUSED_LOCAL(context);
{% endif %}
{% if has_access_check_callbacks %}
- instanceTemplate->SetAccessCheckCallbacks({{cpp_class}}V8Internal::namedSecurityCheck, {{cpp_class}}V8Internal::indexedSecurityCheck, v8::External::New(isolate, const_cast<WrapperTypeInfo*>(&{{v8_class}}::wrapperTypeInfo)));
+ instanceTemplate->SetAccessCheckCallback({{cpp_class}}V8Internal::securityCheck, v8::External::New(isolate, const_cast<WrapperTypeInfo*>(&{{v8_class}}::wrapperTypeInfo)));
{% endif %}
{% if has_array_iterator %}
{% filter runtime_enabled('RuntimeEnabledFeatures::iterableCollectionsEnabled') %}
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceCheckSecurity.cpp b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceCheckSecurity.cpp
index b93073a..d840ed5 100644
--- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceCheckSecurity.cpp
+++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceCheckSecurity.cpp
@@ -224,15 +224,10 @@ static void doNotCheckSecurityReplaceableReadonlyLongAttributeAttributeSetterCal
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
-bool indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t index, v8::AccessType type, v8::Local<v8::Value>)
+bool securityCheck(v8::Local<v8::Context> accessingContext, v8::Local<v8::Object> accessedObject)
{
- TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(host);
- return BindingSecurity::shouldAllowAccessToFrame(v8::Isolate::GetCurrent(), impl->frame(), DoNotReportSecurityError);
-}
-
-bool namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8::AccessType type, v8::Local<v8::Value>)
-{
- TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(host);
+ // TODO(jochen): Take accessingContext into account.
+ TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(accessedObject);
return BindingSecurity::shouldAllowAccessToFrame(v8::Isolate::GetCurrent(), impl->frame(), DoNotReportSecurityError);
}
@@ -547,7 +542,7 @@ static void installV8TestInterfaceCheckSecurityTemplate(v8::Local<v8::FunctionTe
ALLOW_UNUSED_LOCAL(prototypeTemplate);
ExecutionContext* context = currentExecutionContext(isolate);
ALLOW_UNUSED_LOCAL(context);
- instanceTemplate->SetAccessCheckCallbacks(TestInterfaceCheckSecurityV8Internal::namedSecurityCheck, TestInterfaceCheckSecurityV8Internal::indexedSecurityCheck, v8::External::New(isolate, const_cast<WrapperTypeInfo*>(&V8TestInterfaceCheckSecurity::wrapperTypeInfo)));
+ instanceTemplate->SetAccessCheckCallback(TestInterfaceCheckSecurityV8Internal::securityCheck, v8::External::New(isolate, const_cast<WrapperTypeInfo*>(&V8TestInterfaceCheckSecurity::wrapperTypeInfo)));
const V8DOMConfiguration::AttributeConfiguration doNotCheckSecurityVoidMethodOriginSafeAttributeConfiguration = {
"doNotCheckSecurityVoidMethod", TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityVoidMethodOriginSafeMethodGetterCallback, TestInterfaceCheckSecurityV8Internal::TestInterfaceCheckSecurityOriginSafeMethodSetterCallback, 0, 0, &V8TestInterfaceCheckSecurity::wrapperTypeInfo, v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder,
};