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

Unified Diff: third_party/WebKit/Source/bindings/templates/interface_base.cpp.tmpl

Issue 2640123006: Use the current context as the creation context for cross-origin objects. (Closed)
Patch Set: Add comment Created 3 years, 11 months 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
Index: third_party/WebKit/Source/bindings/templates/interface_base.cpp.tmpl
diff --git a/third_party/WebKit/Source/bindings/templates/interface_base.cpp.tmpl b/third_party/WebKit/Source/bindings/templates/interface_base.cpp.tmpl
index 16bb616edd9650a10e3230642c7b258e75331c56..83d4bcaad52f1690c2e2e307635c8c316a410a8b 100644
--- a/third_party/WebKit/Source/bindings/templates/interface_base.cpp.tmpl
+++ b/third_party/WebKit/Source/bindings/templates/interface_base.cpp.tmpl
@@ -198,11 +198,12 @@ static void (*{{method.name}}MethodForPartialInterface)(const v8::FunctionCallba
const DOMWindow* targetWindow = V8Window::toImpl(window);
return BindingSecurity::shouldAllowAccessTo(toLocalDOMWindow(toDOMWindow(accessingContext)), targetWindow, BindingSecurity::ErrorReportOption::DoNotReport);
- {% else %}{# if interface_name == 'Window' #}
- {# Not 'Window' means it\'s Location. #}
+ {% elif interface_name == 'Location' %}
{{cpp_class}}* impl = {{v8_class}}::toImpl(accessedObject);
return BindingSecurity::shouldAllowAccessTo(toLocalDOMWindow(toDOMWindow(accessingContext)), impl, BindingSecurity::ErrorReportOption::DoNotReport);
- {% endif %}{# if interface_name == 'Window' #}
+ {% else %}
+ static_assert(false, "Unexpected security check for interface {{interface_name}}");
Yuki 2017/01/26 10:41:54 nit: #error "message" does the trick and it's more
dcheng 2017/01/27 01:31:42 Done.
+ {% endif %}
}
{% if has_cross_origin_named_enumerator %}
@@ -218,7 +219,15 @@ static const struct {
{% for attribute in attributes if attribute.has_cross_origin_getter or attribute.has_cross_origin_setter %}
{
"{{attribute.name}}",
- {%+ if attribute.has_cross_origin_getter %}&{{cpp_class}}V8Internal::{{attribute.name}}AttributeGetter{% else %}nullptr{% endif %},
+ {% if attribute.has_cross_origin_getter %}
+ {% if attribute.has_custom_getter %}
+ {{v8_class}}::{{attribute.name}}AttributeGetterCustom,
+ {% else %}
+ &{{cpp_class}}V8Internal::{{attribute.name}}AttributeGetter,
+ {% endif %}
+ {% else %}
+ nullptr,
+ {% endif %}
{%+ if attribute.has_cross_origin_setter %}&{{cpp_class}}V8Internal::{{attribute.name}}AttributeSetter{% else %}nullptr{% endif %},
},
{% endfor %}
@@ -285,9 +294,11 @@ static const struct {
for (const auto& attribute : kCrossOriginAttributeTable)
names.push_back(attribute.name);
- v8SetReturnValue(
- info,
- ToV8(names, info.Holder(), info.GetIsolate()).As<v8::Array>());
+ // Use the current context as the creation context, as a cross-origin access
+ // may involve an object that does not have a creation context.
+ v8SetReturnValue(info,
+ ToV8(names, info.GetIsolate()->GetCurrentContext()->Global(),
+ info.GetIsolate()).As<v8::Array>());
}
{% endif %}

Powered by Google App Engine
This is Rietveld 408576698