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

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

Issue 413393003: Blink-in-JS: Implement internal APIs exposed only to private scripts (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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
« no previous file with comments | « Source/bindings/scripts/v8_methods.py ('k') | Source/bindings/templates/interface_base.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 {% extends 'interface_base.cpp' %} 1 {% extends 'interface_base.cpp' %}
2 2
3 3
4 {##############################################################################} 4 {##############################################################################}
5 {% macro attribute_configuration(attribute) %} 5 {% macro attribute_configuration(attribute) %}
6 {% set getter_callback = 6 {% set getter_callback =
7 '%sV8Internal::%sAttributeGetterCallback' % 7 '%sV8Internal::%sAttributeGetterCallback' %
8 (cpp_class, attribute.name) 8 (cpp_class, attribute.name)
9 if not attribute.constructor_type else 9 if not attribute.constructor_type else
10 ('%sV8Internal::%sConstructorGetterCallback' % 10 ('%sV8Internal::%sConstructorGetterCallback' %
(...skipping 11 matching lines...) Expand all
22 if attribute.is_per_world_bindings and 22 if attribute.is_per_world_bindings and
23 (not attribute.is_read_only or attribute.put_forwards) else '0' %} 23 (not attribute.is_read_only or attribute.put_forwards) else '0' %}
24 {% set wrapper_type_info = 24 {% set wrapper_type_info =
25 'const_cast<WrapperTypeInfo*>(&V8%s::wrapperTypeInfo)' % 25 'const_cast<WrapperTypeInfo*>(&V8%s::wrapperTypeInfo)' %
26 attribute.constructor_type 26 attribute.constructor_type
27 if attribute.constructor_type else '0' %} 27 if attribute.constructor_type else '0' %}
28 {% set access_control = 'static_cast<v8::AccessControl>(%s)' % 28 {% set access_control = 'static_cast<v8::AccessControl>(%s)' %
29 ' | '.join(attribute.access_control_list) %} 29 ' | '.join(attribute.access_control_list) %}
30 {% set property_attribute = 'static_cast<v8::PropertyAttribute>(%s)' % 30 {% set property_attribute = 'static_cast<v8::PropertyAttribute>(%s)' %
31 ' | '.join(attribute.property_attributes) %} 31 ' | '.join(attribute.property_attributes) %}
32 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat eScript' if attribute.only_exposed_to_private_script else 'V8DOMConfiguration::E xposedToAllScripts' %}
32 {% set on_prototype = '1 /* on prototype */' 33 {% set on_prototype = '1 /* on prototype */'
33 if interface_name == 'Window' and attribute.idl_type == 'EventHandler' 34 if interface_name == 'Window' and attribute.idl_type == 'EventHandler'
34 else '0 /* on instance */' %} 35 else '0 /* on instance */' %}
35 {% set attribute_configuration_list = [ 36 {% set attribute_configuration_list = [
36 '"%s"' % attribute.name, 37 '"%s"' % attribute.name,
37 getter_callback, 38 getter_callback,
38 setter_callback, 39 setter_callback,
39 getter_callback_for_main_world, 40 getter_callback_for_main_world,
40 setter_callback_for_main_world, 41 setter_callback_for_main_world,
41 wrapper_type_info, 42 wrapper_type_info,
42 access_control, 43 access_control,
43 property_attribute, 44 property_attribute,
45 only_exposed_to_private_script,
44 ] %} 46 ] %}
45 {% if not attribute.is_expose_js_accessors %} 47 {% if not attribute.is_expose_js_accessors %}
46 {% set attribute_configuration_list = attribute_configuration_list 48 {% set attribute_configuration_list = attribute_configuration_list
47 + [on_prototype] %} 49 + [on_prototype] %}
48 {% endif %} 50 {% endif %}
49 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}} 51 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}}
50 {%- endmacro %} 52 {%- endmacro %}
51 53
52 54
53 {##############################################################################} 55 {##############################################################################}
54 {% macro method_configuration(method) %} 56 {% macro method_configuration(method) %}
55 {% set method_callback = 57 {% set method_callback =
56 '%sV8Internal::%sMethodCallback' % (cpp_class, method.name) %} 58 '%sV8Internal::%sMethodCallback' % (cpp_class, method.name) %}
57 {% set method_callback_for_main_world = 59 {% set method_callback_for_main_world =
58 '%sV8Internal::%sMethodCallbackForMainWorld' % (cpp_class, method.name) 60 '%sV8Internal::%sMethodCallbackForMainWorld' % (cpp_class, method.name)
59 if method.is_per_world_bindings else '0' %} 61 if method.is_per_world_bindings else '0' %}
60 {"{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}}, {{m ethod.length}}} 62 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat eScript' if method.only_exposed_to_private_script else 'V8DOMConfiguration::Expo sedToAllScripts' %}
63 {"{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}}, {{m ethod.length}}, {{only_exposed_to_private_script}}}
61 {%- endmacro %} 64 {%- endmacro %}
62 65
63 66
64 {##############################################################################} 67 {##############################################################################}
65 {% block constructor_getter %} 68 {% block constructor_getter %}
66 {% if has_constructor_attributes %} 69 {% if has_constructor_attributes %}
67 static void {{cpp_class}}ConstructorGetter(v8::Local<v8::String>, const v8::Prop ertyCallbackInfo<v8::Value>& info) 70 static void {{cpp_class}}ConstructorGetter(v8::Local<v8::String>, const v8::Prop ertyCallbackInfo<v8::Value>& info)
68 { 71 {
69 v8::Handle<v8::Value> data = info.Data(); 72 v8::Handle<v8::Value> data = info.Data();
70 ASSERT(data->IsExternal()); 73 ASSERT(data->IsExternal());
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 } 723 }
721 724
722 {% endif %} 725 {% endif %}
723 {% endblock %} 726 {% endblock %}
724 727
725 728
726 {##############################################################################} 729 {##############################################################################}
727 {% block shadow_attributes %} 730 {% block shadow_attributes %}
728 {% if interface_name == 'Window' %} 731 {% if interface_name == 'Window' %}
729 static const V8DOMConfiguration::AttributeConfiguration shadowAttributes[] = { 732 static const V8DOMConfiguration::AttributeConfiguration shadowAttributes[] = {
730 {% for attribute in attributes if attribute.is_unforgeable %} 733 {% for attribute in attributes if attribute.is_unforgeable and attribute.sho uld_be_exposed_to_script %}
731 {# FIXME: Expose [OnlyExposedToPrivateScript] attributes to window objects o f private scripts #}
732 {% if not attribute.only_exposed_to_private_script %}
733 {{attribute_configuration(attribute)}}, 734 {{attribute_configuration(attribute)}},
734 {% endif %}
735 {% endfor %} 735 {% endfor %}
736 }; 736 };
737 737
738 {% endif %} 738 {% endif %}
739 {% endblock %} 739 {% endblock %}
740 740
741 741
742 {##############################################################################} 742 {##############################################################################}
743 {% block install_attributes %} 743 {% block install_attributes %}
744 {% if has_attribute_configuration %} 744 {% if has_attribute_configuration %}
745 static const V8DOMConfiguration::AttributeConfiguration {{v8_class}}Attributes[] = { 745 static const V8DOMConfiguration::AttributeConfiguration {{v8_class}}Attributes[] = {
746 {% for attribute in attributes 746 {% for attribute in attributes
747 if not (attribute.is_expose_js_accessors or 747 if not (attribute.is_expose_js_accessors or
748 attribute.is_static or 748 attribute.is_static or
749 attribute.runtime_enabled_function or 749 attribute.runtime_enabled_function or
750 attribute.per_context_enabled_function or 750 attribute.per_context_enabled_function or
751 (interface_name == 'Window' and attribute.is_unforgeable)) %} 751 (interface_name == 'Window' and attribute.is_unforgeable))
752 {# FIXME: Expose [OnlyExposedToPrivateScript] attributes to window objects o f private scripts #} 752 and attribute.should_be_exposed_to_script %}
753 {% if not attribute.only_exposed_to_private_script %}
754 {% filter conditional(attribute.conditional_string) %} 753 {% filter conditional(attribute.conditional_string) %}
755 {{attribute_configuration(attribute)}}, 754 {{attribute_configuration(attribute)}},
756 {% endfilter %} 755 {% endfilter %}
757 {% endif %}
758 {% endfor %} 756 {% endfor %}
759 }; 757 };
760 758
761 {% endif %} 759 {% endif %}
762 {% endblock %} 760 {% endblock %}
763 761
764 762
765 {##############################################################################} 763 {##############################################################################}
766 {% block install_accessors %} 764 {% block install_accessors %}
767 {% if has_accessors %} 765 {% if has_accessors %}
768 static const V8DOMConfiguration::AccessorConfiguration {{v8_class}}Accessors[] = { 766 static const V8DOMConfiguration::AccessorConfiguration {{v8_class}}Accessors[] = {
769 {% for attribute in attributes if attribute.is_expose_js_accessors %} 767 {% for attribute in attributes if attribute.is_expose_js_accessors and attri bute.should_be_exposed_to_script %}
770 {# FIXME: Expose [OnlyExposedToPrivateScript] attributes to window objects o f private scripts #}
771 {% if not attribute.only_exposed_to_private_script %}
772 {{attribute_configuration(attribute)}}, 768 {{attribute_configuration(attribute)}},
773 {% endif %}
774 {% endfor %} 769 {% endfor %}
775 }; 770 };
776 771
777 {% endif %} 772 {% endif %}
778 {% endblock %} 773 {% endblock %}
779 774
780 775
781 {##############################################################################} 776 {##############################################################################}
782 {% block install_methods %} 777 {% block install_methods %}
783 {% if method_configuration_methods %} 778 {% if method_configuration_methods %}
784 static const V8DOMConfiguration::MethodConfiguration {{v8_class}}Methods[] = { 779 static const V8DOMConfiguration::MethodConfiguration {{v8_class}}Methods[] = {
785 {% for method in method_configuration_methods %} 780 {% for method in method_configuration_methods if method.should_be_exposed_to _script %}
786 {# FIXME: Expose [OnlyExposedToPrivateScript] methods to window objects of p rivate scripts #}
787 {% if not method.only_exposed_to_private_script %}
788 {% filter conditional(method.conditional_string) %} 781 {% filter conditional(method.conditional_string) %}
789 {{method_configuration(method)}}, 782 {{method_configuration(method)}},
790 {% endfilter %} 783 {% endfilter %}
791 {% endif %}
792 {% endfor %} 784 {% endfor %}
793 }; 785 };
794 786
795 {% endif %} 787 {% endif %}
796 {% endblock %} 788 {% endblock %}
797 789
798 790
799 {##############################################################################} 791 {##############################################################################}
800 {% block initialize_event %} 792 {% block initialize_event %}
801 {% if has_event_constructor %} 793 {% if has_event_constructor %}
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 {% set setter_callback_for_main_world = '%sForMainWorld' % setter_callback 1045 {% set setter_callback_for_main_world = '%sForMainWorld' % setter_callback
1054 if not method.is_read_only else '0' %} 1046 if not method.is_read_only else '0' %}
1055 {% else %} 1047 {% else %}
1056 {% set getter_callback_for_main_world = '0' %} 1048 {% set getter_callback_for_main_world = '0' %}
1057 {% set setter_callback_for_main_world = '0' %} 1049 {% set setter_callback_for_main_world = '0' %}
1058 {% endif %} 1050 {% endif %}
1059 {% set property_attribute = 1051 {% set property_attribute =
1060 'static_cast<v8::PropertyAttribute>(%s)' % 1052 'static_cast<v8::PropertyAttribute>(%s)' %
1061 ' | '.join(method.property_attributes or ['v8::DontDelete']) %} 1053 ' | '.join(method.property_attributes or ['v8::DontDelete']) %}
1062 static const V8DOMConfiguration::AttributeConfiguration {{method.name}}OriginSaf eAttributeConfiguration = { 1054 static const V8DOMConfiguration::AttributeConfiguration {{method.name}}OriginSaf eAttributeConfiguration = {
1063 "{{method.name}}", {{getter_callback}}, {{setter_callback}}, {{getter_callba ck_for_main_world}}, {{setter_callback_for_main_world}}, &{{v8_class}}::wrapperT ypeInfo, v8::ALL_CAN_READ, {{property_attribute}}, false 1055 "{{method.name}}", {{getter_callback}}, {{setter_callback}}, {{getter_callba ck_for_main_world}}, {{setter_callback_for_main_world}}, &{{v8_class}}::wrapperT ypeInfo, v8::ALL_CAN_READ, {{property_attribute}}, V8DOMConfiguration::ExposedTo AllScripts, false,
1064 }; 1056 };
1065 V8DOMConfiguration::installAttribute({{method.function_template}}, v8::Handle<v8 ::ObjectTemplate>(), {{method.name}}OriginSafeAttributeConfiguration, isolate); 1057 V8DOMConfiguration::installAttribute({{method.function_template}}, v8::Handle<v8 ::ObjectTemplate>(), {{method.name}}OriginSafeAttributeConfiguration, isolate);
1066 {%- endmacro %} 1058 {%- endmacro %}
1067 1059
1068 1060
1069 {######################################} 1061 {######################################}
1070 {% macro install_custom_signature(method) %} 1062 {% macro install_custom_signature(method) %}
1071 {% set method_callback = '%sV8Internal::%sMethodCallback' % (cpp_class, method.n ame) %} 1063 {% set method_callback = '%sV8Internal::%sMethodCallback' % (cpp_class, method.n ame) %}
1072 {% set method_callback_for_main_world = '%sForMainWorld' % method_callback 1064 {% set method_callback_for_main_world = '%sForMainWorld' % method_callback
1073 if method.is_per_world_bindings else '0' %} 1065 if method.is_per_world_bindings else '0' %}
1074 {% set property_attribute = 1066 {% set property_attribute =
1075 'static_cast<v8::PropertyAttribute>(%s)' % ' | '.join(method.property_attribut es) 1067 'static_cast<v8::PropertyAttribute>(%s)' % ' | '.join(method.property_attribut es)
1076 if method.property_attributes else 'v8::None' %} 1068 if method.property_attributes else 'v8::None' %}
1077 static const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfig uration = { 1069 static const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfig uration = {
1078 "{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}}, {{method.length}} 1070 "{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}}, {{method.length}}, V8DOMConfiguration::ExposedToAllScripts,
Jens Widell 2014/07/25 11:09:45 Should we assert somewhere that this code path isn
haraken 2014/07/25 13:22:16 Instead of adding asserts, I just supported [OnlyE
1079 }; 1071 };
1080 V8DOMConfiguration::installMethodCustomSignature({{method.function_template}}, { {method.signature}}, {{property_attribute}}, {{method.name}}MethodConfiguration, isolate); 1072 V8DOMConfiguration::installMethodCustomSignature({{method.function_template}}, { {method.signature}}, {{property_attribute}}, {{method.name}}MethodConfiguration, isolate);
1081 {%- endmacro %} 1073 {%- endmacro %}
1082 1074
1083 1075
1084 {######################################} 1076 {######################################}
1085 {% macro install_constants() %} 1077 {% macro install_constants() %}
1086 {# Normal (always enabled) constants #} 1078 {# Normal (always enabled) constants #}
1087 static const V8DOMConfiguration::ConstantConfiguration {{v8_class}}Constants[] = { 1079 static const V8DOMConfiguration::ConstantConfiguration {{v8_class}}Constants[] = {
1088 {% for constant in constants if not constant.runtime_enabled_function %} 1080 {% for constant in constants if not constant.runtime_enabled_function %}
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
1349 {% endif %} 1341 {% endif %}
1350 } 1342 }
1351 1343
1352 template<> 1344 template<>
1353 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate) 1345 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate)
1354 { 1346 {
1355 return toV8(impl, creationContext, isolate); 1347 return toV8(impl, creationContext, isolate);
1356 } 1348 }
1357 1349
1358 {% endblock %} 1350 {% endblock %}
OLDNEW
« no previous file with comments | « Source/bindings/scripts/v8_methods.py ('k') | Source/bindings/templates/interface_base.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698