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

Side by Side Diff: Source/bindings/templates/interface_base.cpp

Issue 953473002: bindings: Supports [Replaceable] accessors. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Addressed a review comment. Created 5 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file has been auto-generated by {{code_generator}}. DO NOT MODIFY! 5 // This file has been auto-generated by {{code_generator}}. DO NOT MODIFY!
6 6
7 #include "config.h" 7 #include "config.h"
8 {% filter conditional(conditional_string) %} 8 {% filter conditional(conditional_string) %}
9 #include "{{v8_class_or_partial}}.h" 9 #include "{{v8_class_or_partial}}.h"
10 10
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 {% endfor %} 44 {% endfor %}
45 {% endif %} 45 {% endif %}
46 46
47 {# Constants #} 47 {# Constants #}
48 {% from 'constants.cpp' import constant_getter_callback 48 {% from 'constants.cpp' import constant_getter_callback
49 with context %} 49 with context %}
50 {% for constant in special_getter_constants %} 50 {% for constant in special_getter_constants %}
51 {{constant_getter_callback(constant)}} 51 {{constant_getter_callback(constant)}}
52 {% endfor %} 52 {% endfor %}
53 {# Attributes #} 53 {# Attributes #}
54 {% block replaceable_attribute_setter_and_callback %}
55 {% if has_replaceable_attributes or has_constructor_attributes %}
56 template<class CallbackInfo>
57 static void {{cpp_class}}ForceSetAttributeOnThis(v8::Local<v8::String> name, v8: :Local<v8::Value> v8Value, const CallbackInfo& info)
58 {
59 {% if is_check_security %}
60 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
61 v8::String::Utf8Value attributeName(name);
62 ExceptionState exceptionState(ExceptionState::SetterContext, *attributeName, "{{interface_name}}", info.Holder(), info.GetIsolate());
63 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram e(), exceptionState)) {
64 exceptionState.throwIfNeeded();
65 return;
66 }
67 {% endif %}
68 if (info.This()->IsObject())
haraken 2015/02/25 14:27:34 Not related to your CL, I guess this is always tru
Yuki 2015/02/25 14:33:12 Will do.
69 v8::Local<v8::Object>::Cast(info.This())->ForceSet(name, v8Value);
70 }
71
72 {% endif %}
73 {% if has_constructor_attributes %}
74 static void {{cpp_class}}ForceSetAttributeOnThisCallback(v8::Local<v8::String> n ame, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
haraken 2015/02/25 14:27:34 Not related to your CL, do we need this method ind
Yuki 2015/02/25 14:33:12 I'm still studying what constructor attributes are
75 {
76 {{cpp_class_or_partial}}V8Internal::{{cpp_class}}ForceSetAttributeOnThis(nam e, v8Value, info);
77 }
78
79 {% endif %}
80 {% endblock %}
81 {##############################################################################}
54 {% from 'attributes.cpp' import constructor_getter_callback, 82 {% from 'attributes.cpp' import constructor_getter_callback,
55 attribute_getter, attribute_getter_callback, 83 attribute_getter, attribute_getter_callback,
56 attribute_setter, attribute_setter_callback, 84 attribute_setter, attribute_setter_callback,
57 attribute_getter_implemented_in_private_script, 85 attribute_getter_implemented_in_private_script,
58 attribute_setter_implemented_in_private_script 86 attribute_setter_implemented_in_private_script
59 with context %} 87 with context %}
60 {% for attribute in attributes if not attribute.constructor_type %} 88 {% for attribute in attributes if not attribute.constructor_type %}
61 {% if attribute.should_be_exposed_to_script %} 89 {% if attribute.should_be_exposed_to_script %}
62 {% for world_suffix in attribute.world_suffixes %} 90 {% for world_suffix in attribute.world_suffixes %}
63 {% if not attribute.has_custom_getter %} 91 {% if not attribute.has_custom_getter %}
64 {{attribute_getter(attribute, world_suffix)}} 92 {{attribute_getter(attribute, world_suffix)}}
65 {% endif %} 93 {% endif %}
66 {{attribute_getter_callback(attribute, world_suffix)}} 94 {{attribute_getter_callback(attribute, world_suffix)}}
67 {% if not attribute.is_read_only or attribute.put_forwards %} 95 {% if (not attribute.is_read_only or
96 attribute.put_forwards or
97 attribute.is_replaceable) %}
68 {% if not attribute.has_custom_setter %} 98 {% if not attribute.has_custom_setter %}
69 {{attribute_setter(attribute, world_suffix)}} 99 {{attribute_setter(attribute, world_suffix)}}
70 {% endif %} 100 {% endif %}
71 {{attribute_setter_callback(attribute, world_suffix)}} 101 {{attribute_setter_callback(attribute, world_suffix)}}
72 {% endif %} 102 {% endif %}
73 {% endfor %} 103 {% endfor %}
74 {% endif %} 104 {% endif %}
75 {% endfor %} 105 {% endfor %}
76 {##############################################################################} 106 {##############################################################################}
77 {% block constructor_getter %} 107 {% block constructor_getter %}
(...skipping 10 matching lines...) Expand all
88 118
89 {% endif %} 119 {% endif %}
90 {% endblock %} 120 {% endblock %}
91 {##############################################################################} 121 {##############################################################################}
92 {% for attribute in attributes if attribute.needs_constructor_getter_callback %} 122 {% for attribute in attributes if attribute.needs_constructor_getter_callback %}
93 {% for world_suffix in attribute.world_suffixes %} 123 {% for world_suffix in attribute.world_suffixes %}
94 {{constructor_getter_callback(attribute, world_suffix)}} 124 {{constructor_getter_callback(attribute, world_suffix)}}
95 {% endfor %} 125 {% endfor %}
96 {% endfor %} 126 {% endfor %}
97 {##############################################################################} 127 {##############################################################################}
98 {% block replaceable_attribute_setter_and_callback %}
99 {% if has_replaceable_attributes or has_constructor_attributes %}
100 static void {{cpp_class}}ForceSetAttributeOnThis(v8::Local<v8::String> name, v8: :Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
101 {
102 {% if is_check_security %}
103 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
104 v8::String::Utf8Value attributeName(name);
105 ExceptionState exceptionState(ExceptionState::SetterContext, *attributeName, "{{interface_name}}", info.Holder(), info.GetIsolate());
106 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram e(), exceptionState)) {
107 exceptionState.throwIfNeeded();
108 return;
109 }
110 {% endif %}
111 if (info.This()->IsObject())
112 v8::Local<v8::Object>::Cast(info.This())->ForceSet(name, v8Value);
113 }
114
115 static void {{cpp_class}}ForceSetAttributeOnThisCallback(v8::Local<v8::String> n ame, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
116 {
117 {{cpp_class_or_partial}}V8Internal::{{cpp_class}}ForceSetAttributeOnThis(nam e, v8Value, info);
118 }
119
120 {% endif %}
121 {% endblock %}
122 {##############################################################################}
123 {% block security_check_functions %} 128 {% block security_check_functions %}
124 {% if has_access_check_callbacks %} 129 {% if has_access_check_callbacks %}
125 bool indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t index, v8::Access Type type, v8::Local<v8::Value>) 130 bool indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t index, v8::Access Type type, v8::Local<v8::Value>)
126 { 131 {
127 {{cpp_class}}* impl = {{v8_class}}::toImpl(host); 132 {{cpp_class}}* impl = {{v8_class}}::toImpl(host);
128 return BindingSecurity::shouldAllowAccessToFrame(v8::Isolate::GetCurrent(), impl->frame(), DoNotReportSecurityError); 133 return BindingSecurity::shouldAllowAccessToFrame(v8::Isolate::GetCurrent(), impl->frame(), DoNotReportSecurityError);
129 } 134 }
130 135
131 bool namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8 ::AccessType type, v8::Local<v8::Value>) 136 bool namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8 ::AccessType type, v8::Local<v8::Value>)
132 { 137 {
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 {% endfor %} 513 {% endfor %}
509 {% for attribute in attributes if attribute.is_implemented_in_private_script %} 514 {% for attribute in attributes if attribute.is_implemented_in_private_script %}
510 {{attribute_getter_implemented_in_private_script(attribute)}} 515 {{attribute_getter_implemented_in_private_script(attribute)}}
511 {% if not attribute.is_read_only or attribute.put_forwards %} 516 {% if not attribute.is_read_only or attribute.put_forwards %}
512 {{attribute_setter_implemented_in_private_script(attribute)}} 517 {{attribute_setter_implemented_in_private_script(attribute)}}
513 {% endif %} 518 {% endif %}
514 {% endfor %} 519 {% endfor %}
515 {% block partial_interface %}{% endblock %} 520 {% block partial_interface %}{% endblock %}
516 } // namespace blink 521 } // namespace blink
517 {% endfilter %} 522 {% endfilter %}
OLDNEW
« no previous file with comments | « Source/bindings/templates/attributes.cpp ('k') | Source/bindings/tests/idls/core/TestInterfaceCheckSecurity.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698