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

Unified Diff: third_party/WebKit/Source/bindings/templates/attributes.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/attributes.cpp
diff --git a/third_party/WebKit/Source/bindings/templates/attributes.cpp b/third_party/WebKit/Source/bindings/templates/attributes.cpp
index e7a68af775f6b25de70d3500118aaeb2b0810c1d..29533d7f4ecc25c231a3ef42814637d9c3b900d3 100644
--- a/third_party/WebKit/Source/bindings/templates/attributes.cpp
+++ b/third_party/WebKit/Source/bindings/templates/attributes.cpp
@@ -77,31 +77,16 @@ const v8::FunctionCallbackInfo<v8::Value>& info
{% endif %}
{# Security checks #}
{% if not attribute.is_data_type_property %}
- {% if attribute.is_check_security_for_window %}
- if (LocalDOMWindow* window = impl->toDOMWindow()) {
- if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), callingDOMWindow(info.GetIsolate()), window->frame(), exceptionState)) {
- v8SetReturnValueNull(info);
- exceptionState.throwIfNeeded();
- return;
- }
- if (!window->document())
- return;
- }
- {% elif attribute.is_check_security_for_frame %}
- if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), callingDOMWindow(info.GetIsolate()), impl->frame(), exceptionState)) {
+ {% if attribute.is_check_security_for_window or
+ attribute.is_check_security_for_frame or
+ attribute.is_check_security_for_node %}
+ if (!BindingSecurity::shouldAllowAccessTo(info.GetIsolate(), callingDOMWindow(info.GetIsolate()), {{attribute.cpp_value if attribute.is_check_security_for_node else 'impl'}}, exceptionState)) {
v8SetReturnValueNull(info);
exceptionState.throwIfNeeded();
return;
}
{% endif %}
{% endif %}
- {% if attribute.is_check_security_for_node %}
- if (!BindingSecurity::shouldAllowAccessToNode(info.GetIsolate(), callingDOMWindow(info.GetIsolate()), {{attribute.cpp_value}}, exceptionState)) {
- v8SetReturnValueNull(info);
- exceptionState.throwIfNeeded();
- return;
- }
- {% endif %}
{% if attribute.reflect_only %}
{{release_only_check(attribute.reflect_only, attribute.reflect_missing,
attribute.reflect_invalid, attribute.reflect_empty,
@@ -298,31 +283,16 @@ v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info
{% if not attribute.is_replaceable and
not attribute.constructor_type %}
{% if not attribute.is_data_type_property %}
- {% if attribute.is_check_security_for_window %}
- if (LocalDOMWindow* window = impl->toDOMWindow()) {
- if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), callingDOMWindow(info.GetIsolate()), window->frame(), exceptionState)) {
- v8SetReturnValue(info, v8Value);
- exceptionState.throwIfNeeded();
- return;
- }
- if (!window->document())
- return;
- }
- {% elif attribute.is_check_security_for_frame %}
- if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), callingDOMWindow(info.GetIsolate()), impl->frame(), exceptionState)) {
+ {% if attribute.is_check_security_for_window or
+ attribute.is_check_security_for_frame or
+ attribute.is_check_security_for_node %}
+ if (!BindingSecurity::shouldAllowAccessTo(info.GetIsolate(), callingDOMWindow(info.GetIsolate()), {{attribute.cpp_value if attribute.is_check_security_for_node else 'impl'}}, exceptionState)) {
v8SetReturnValue(info, v8Value);
exceptionState.throwIfNeeded();
return;
}
{% endif %}
{% endif %}
- {% if attribute.is_check_security_for_node %}
- if (!BindingSecurity::shouldAllowAccessToNode(info.GetIsolate(), callingDOMWindow(info.GetIsolate()), {{attribute.cpp_value}}, exceptionState)) {
- v8SetReturnValue(info, v8Value);
- exceptionState.throwIfNeeded();
- return;
- }
- {% endif %}
{% endif %}{# not attribute.is_replaceable and
not attribute.constructor_type #}
{# Convert JS value to C++ value #}

Powered by Google App Engine
This is Rietveld 408576698