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

Unified Diff: third_party/WebKit/Source/bindings/templates/methods.cpp

Issue 1417023006: bindings: Refactors BindingSecurity::shouldAllowAccessToXXX. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed the assertion condition. 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
Index: third_party/WebKit/Source/bindings/templates/methods.cpp
diff --git a/third_party/WebKit/Source/bindings/templates/methods.cpp b/third_party/WebKit/Source/bindings/templates/methods.cpp
index 0a18d9b849480d0c7da1346fbf8d339776f008ad..33c828609622cc2a0d9add39acff3b9503f8e381 100644
--- a/third_party/WebKit/Source/bindings/templates/methods.cpp
+++ b/third_party/WebKit/Source/bindings/templates/methods.cpp
@@ -27,23 +27,17 @@ static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const
CustomElementProcessingStack::CallbackDeliveryScope deliveryScope;
{% endif %}
{# Security checks #}
- {% if method.is_check_security_for_window %}
- if (LocalDOMWindow* window = impl->toDOMWindow()) {
- if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), callingDOMWindow(info.GetIsolate()), window->frame(), exceptionState)) {
- {{propagate_error_with_exception_state(method) | indent(12)}}
- }
- if (!window->document())
- return;
- }
- {% elif method.is_check_security_for_frame %}
- if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), callingDOMWindow(info.GetIsolate()), impl->frame(), exceptionState)) {
- {{propagate_error_with_exception_state(method) | indent(8)}}
- }
- {% endif %}
- {% if method.is_check_security_for_node %}
- if (!BindingSecurity::shouldAllowAccessToNode(info.GetIsolate(), callingDOMWindow(info.GetIsolate()), impl->{{method.name}}(exceptionState), exceptionState)) {
+ {% if method.is_check_security_for_window or
+ method.is_check_security_for_frame or
+ method.is_check_security_for_node %}
+ if (!BindingSecurity::shouldAllowAccessTo(info.GetIsolate(), callingDOMWindow(info.GetIsolate()), {{method.cpp_value if method.is_check_security_for_node else 'impl'}}, exceptionState)) {
+ {% if method.is_check_security_for_node %}
v8SetReturnValueNull(info);
- {{propagate_error_with_exception_state(method) | indent(8)}}
+ {% endif %}
+ {% if not method.returns_promise %}
+ exceptionState.throwIfNeeded();
+ {% endif %}
+ return;
}
{% endif %}
{# Call method #}
@@ -536,7 +530,7 @@ static void {{method.name}}OriginSafeMethodGetter{{world_suffix}}(const v8::Prop
return;
}
{{cpp_class}}* impl = {{v8_class}}::toImpl(holder);
- if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), callingDOMWindow(info.GetIsolate()), impl->frame(), DoNotReportSecurityError)) {
+ if (!BindingSecurity::shouldAllowAccessTo(info.GetIsolate(), callingDOMWindow(info.GetIsolate()), impl, DoNotReportSecurityError)) {
v8SetReturnValue(info, domTemplate->GetFunction(info.GetIsolate()->GetCurrentContext()).ToLocalChecked());
return;
}

Powered by Google App Engine
This is Rietveld 408576698