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

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

Issue 2880713002: Support combination of [OriginTrialEnabled] and [SecureContext] (Closed)
Patch Set: Remove workarounds Created 3 years, 7 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
OLDNEW
1 {% filter format_blink_cpp_source_code %} 1 {% filter format_blink_cpp_source_code %}
2 2
3 {% include 'copyright_block.txt' %} 3 {% include 'copyright_block.txt' %}
4 #include "{{v8_class_or_partial}}.h" 4 #include "{{v8_class_or_partial}}.h"
5 5
6 {% for filename in cpp_includes if filename != '%s.h' % cpp_class_or_partial %} 6 {% for filename in cpp_includes if filename != '%s.h' % cpp_class_or_partial %}
7 #include "{{filename}}" 7 #include "{{filename}}"
8 {% endfor %} 8 {% endfor %}
9 9
10 namespace blink { 10 namespace blink {
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 with context %} 697 with context %}
698 {% from 'constants.cpp.tmpl' import constant_configuration with context %} 698 {% from 'constants.cpp.tmpl' import constant_configuration with context %}
699 {% from 'methods.cpp.tmpl' import method_configuration with context %} 699 {% from 'methods.cpp.tmpl' import method_configuration with context %}
700 {% for feature in origin_trial_features %} 700 {% for feature in origin_trial_features %}
701 void {{v8_class_or_partial}}::install{{feature.name}}(v8::Isolate* isolate, cons t DOMWrapperWorld& world, v8::Local<v8::Object> instance, v8::Local<v8::Object> prototype, v8::Local<v8::Function> interface) { 701 void {{v8_class_or_partial}}::install{{feature.name}}(v8::Isolate* isolate, cons t DOMWrapperWorld& world, v8::Local<v8::Object> instance, v8::Local<v8::Object> prototype, v8::Local<v8::Function> interface) {
702 {% if feature.attributes or feature.methods %} 702 {% if feature.attributes or feature.methods %}
703 v8::Local<v8::FunctionTemplate> interfaceTemplate = {{v8_class}}::wrapperTypeI nfo.domTemplate(isolate, world); 703 v8::Local<v8::FunctionTemplate> interfaceTemplate = {{v8_class}}::wrapperTypeI nfo.domTemplate(isolate, world);
704 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interfaceTemp late); 704 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interfaceTemp late);
705 ALLOW_UNUSED_LOCAL(signature); 705 ALLOW_UNUSED_LOCAL(signature);
706 {% endif %} 706 {% endif %}
707 {% if feature.needs_secure_context %}
708 ExecutionContext* executionContext = ToExecutionContext(isolate->GetCurrentCon text());
709 bool isSecureContext = (executionContext && executionContext->IsSecureContext( ));
710 {% endif %}{# needs secure context #}
707 {# Origin-Trial-enabled attributes #} 711 {# Origin-Trial-enabled attributes #}
708 {% for attribute in feature.attributes %} 712 {% for attribute in feature.attributes %}
713 {% filter secure_context_cached(attribute.secure_context_test) %}
709 {% if attribute.is_data_type_property %} 714 {% if attribute.is_data_type_property %}
710 static const V8DOMConfiguration::AttributeConfiguration attribute{{attribute.n ame}}Configuration[] = { 715 static const V8DOMConfiguration::AttributeConfiguration attribute{{attribute.n ame}}Configuration[] = {
711 {{attribute_configuration(attribute) | indent(2)}} 716 {{attribute_configuration(attribute) | indent(2)}}
712 }; 717 };
713 for (const auto& attributeConfig : attribute{{attribute.name}}Configuration) 718 for (const auto& attributeConfig : attribute{{attribute.name}}Configuration)
714 V8DOMConfiguration::InstallAttribute(isolate, world, instance, prototype, at tributeConfig); 719 V8DOMConfiguration::InstallAttribute(isolate, world, instance, prototype, at tributeConfig);
715 {% else %} 720 {% else %}
716 static const V8DOMConfiguration::AccessorConfiguration accessor{{attribute.nam e}}Configuration[] = { 721 static const V8DOMConfiguration::AccessorConfiguration accessor{{attribute.nam e}}Configuration[] = {
717 {{accessor_configuration(attribute) | indent(2)}} 722 {{accessor_configuration(attribute) | indent(2)}}
718 }; 723 };
719 for (const auto& accessorConfig : accessor{{attribute.name}}Configuration) 724 for (const auto& accessorConfig : accessor{{attribute.name}}Configuration)
720 V8DOMConfiguration::InstallAccessor(isolate, world, instance, prototype, int erface, signature, accessorConfig); 725 V8DOMConfiguration::InstallAccessor(isolate, world, instance, prototype, int erface, signature, accessorConfig);
721 {% endif %} 726 {% endif %}
727 {% endfilter %}{# secure_context #}
Yuki 2017/05/12 09:10:05 nit: secure_context_cached
chasej 2017/05/16 02:21:39 Removed secure_context_cached (as suggested above)
722 {% endfor %} 728 {% endfor %}
723 {# Origin-Trial-enabled constants #} 729 {# Origin-Trial-enabled constants #}
724 {% for constant in feature.constants %} 730 {% for constant in feature.constants %}
725 {% set constant_name = constant.name.title().replace('_', '') %} 731 {% set constant_name = constant.name.title().replace('_', '') %}
726 const V8DOMConfiguration::ConstantConfiguration constant{{constant_name}}Confi guration = {{constant_configuration(constant)}}; 732 const V8DOMConfiguration::ConstantConfiguration constant{{constant_name}}Confi guration = {{constant_configuration(constant)}};
727 V8DOMConfiguration::InstallConstant(isolate, interface, prototype, constant{{c onstant_name}}Configuration); 733 V8DOMConfiguration::InstallConstant(isolate, interface, prototype, constant{{c onstant_name}}Configuration);
728 {% endfor %} 734 {% endfor %}
729 {# Origin-Trial-enabled methods (no overloads) #} 735 {# Origin-Trial-enabled methods (no overloads) #}
730 {% for method in feature.methods %} 736 {% for method in feature.methods %}
737 {% filter secure_context_cached(method.secure_context_test) %}
731 {% set method_name = method.name.title().replace('_', '') %} 738 {% set method_name = method.name.title().replace('_', '') %}
732 static const V8DOMConfiguration::MethodConfiguration method{{method_name}}Conf iguration[] = { 739 static const V8DOMConfiguration::MethodConfiguration method{{method_name}}Conf iguration[] = {
733 {{method_configuration(method) | indent(2)}} 740 {{method_configuration(method) | indent(2)}}
734 }; 741 };
735 for (const auto& methodConfig : method{{method_name}}Configuration) 742 for (const auto& methodConfig : method{{method_name}}Configuration)
736 V8DOMConfiguration::InstallMethod(isolate, world, instance, prototype, inter face, signature, methodConfig); 743 V8DOMConfiguration::InstallMethod(isolate, world, instance, prototype, inter face, signature, methodConfig);
744 {% endfilter %}{# secure_context #}
Yuki 2017/05/12 09:10:05 nit: secure_context_cached
chasej 2017/05/16 02:21:39 Removed secure_context_cached (as suggested above)
737 {% endfor %} 745 {% endfor %}
738 } 746 }
739 747
740 void {{v8_class_or_partial}}::install{{feature.name}}(ScriptState* scriptState, v8::Local<v8::Object> instance) { 748 void {{v8_class_or_partial}}::install{{feature.name}}(ScriptState* scriptState, v8::Local<v8::Object> instance) {
741 V8PerContextData* perContextData = V8PerContextData::From(scriptState->GetCont ext()); 749 V8PerContextData* perContextData = V8PerContextData::From(scriptState->GetCont ext());
742 v8::Local<v8::Object> prototype = perContextData->PrototypeForType(&{{v8_class }}::wrapperTypeInfo); 750 v8::Local<v8::Object> prototype = perContextData->PrototypeForType(&{{v8_class }}::wrapperTypeInfo);
743 v8::Local<v8::Function> interface = perContextData->ConstructorForType(&{{v8_c lass}}::wrapperTypeInfo); 751 v8::Local<v8::Function> interface = perContextData->ConstructorForType(&{{v8_c lass}}::wrapperTypeInfo);
744 ALLOW_UNUSED_LOCAL(interface); 752 ALLOW_UNUSED_LOCAL(interface);
745 install{{feature.name}}(scriptState->GetIsolate(), scriptState->World(), insta nce, prototype, interface); 753 install{{feature.name}}(scriptState->GetIsolate(), scriptState->World(), insta nce, prototype, interface);
746 } 754 }
(...skipping 17 matching lines...) Expand all
764 {% block prepare_prototype_and_interface_object %} 772 {% block prepare_prototype_and_interface_object %}
765 {% from 'attributes.cpp.tmpl' import install_conditionally_enabled_attributes_on _prototype with context %} 773 {% from 'attributes.cpp.tmpl' import install_conditionally_enabled_attributes_on _prototype with context %}
766 {% from 'methods.cpp.tmpl' import install_conditionally_enabled_methods with con text %} 774 {% from 'methods.cpp.tmpl' import install_conditionally_enabled_methods with con text %}
767 {% if prepare_prototype_and_interface_object_func %} 775 {% if prepare_prototype_and_interface_object_func %}
768 void {{v8_class_or_partial}}::preparePrototypeAndInterfaceObject(v8::Local<v8::C ontext> context, const DOMWrapperWorld& world, v8::Local<v8::Object> prototypeOb ject, v8::Local<v8::Function> interfaceObject, v8::Local<v8::FunctionTemplate> i nterfaceTemplate) { 776 void {{v8_class_or_partial}}::preparePrototypeAndInterfaceObject(v8::Local<v8::C ontext> context, const DOMWrapperWorld& world, v8::Local<v8::Object> prototypeOb ject, v8::Local<v8::Function> interfaceObject, v8::Local<v8::FunctionTemplate> i nterfaceTemplate) {
769 {% if is_partial %} 777 {% if is_partial %}
770 {{v8_class}}::preparePrototypeAndInterfaceObject(context, world, prototypeObje ct, interfaceObject, interfaceTemplate); 778 {{v8_class}}::preparePrototypeAndInterfaceObject(context, world, prototypeObje ct, interfaceObject, interfaceTemplate);
771 {% endif %} 779 {% endif %}
772 780
773 v8::Isolate* isolate = context->GetIsolate(); 781 v8::Isolate* isolate = context->GetIsolate();
774 {% if has_conditional_attributes_on_prototype or methods | conditionally_expos ed(is_partial) %} 782 {% if has_conditional_attributes_on_prototype or has_conditional_methods %}
775 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interfaceTemp late); 783 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interfaceTemp late);
776 ExecutionContext* executionContext = ToExecutionContext(context); 784 ExecutionContext* executionContext = ToExecutionContext(context);
777 DCHECK(executionContext); 785 DCHECK(executionContext);
778 {% endif %} 786 {% endif %}
779 787
780 {% if unscopables %} 788 {% if unscopables %}
781 v8::Local<v8::Name> unscopablesSymbol(v8::Symbol::GetUnscopables(isolate)); 789 v8::Local<v8::Name> unscopablesSymbol(v8::Symbol::GetUnscopables(isolate));
782 v8::Local<v8::Object> unscopables; 790 v8::Local<v8::Object> unscopables;
783 if (V8CallBoolean(prototypeObject->HasOwnProperty(context, unscopablesSymbol)) ) 791 if (V8CallBoolean(prototypeObject->HasOwnProperty(context, unscopablesSymbol)) )
784 unscopables = prototypeObject->Get(context, unscopablesSymbol).ToLocalChecke d().As<v8::Object>(); 792 unscopables = prototypeObject->Get(context, unscopablesSymbol).ToLocalChecke d().As<v8::Object>();
785 else 793 else
786 unscopables = v8::Object::New(isolate); 794 unscopables = v8::Object::New(isolate);
787 {% for name, runtime_enabled_feature_name in unscopables %} 795 {% for name, runtime_enabled_feature_name in unscopables %}
788 {% filter runtime_enabled(runtime_enabled_feature_name) %} 796 {% filter runtime_enabled(runtime_enabled_feature_name) %}
789 unscopables->CreateDataProperty(context, V8AtomicString(isolate, "{{name}}"), v8::True(isolate)).FromJust(); 797 unscopables->CreateDataProperty(context, V8AtomicString(isolate, "{{name}}"), v8::True(isolate)).FromJust();
790 {% endfilter %} 798 {% endfilter %}
791 {% endfor %} 799 {% endfor %}
792 prototypeObject->CreateDataProperty(context, unscopablesSymbol, unscopables).F romJust(); 800 prototypeObject->CreateDataProperty(context, unscopablesSymbol, unscopables).F romJust();
793 {% endif %}{# unscopables #} 801 {% endif %}{# unscopables #}
794 {% if has_conditional_attributes_on_prototype %} 802 {% if has_conditional_attributes_on_prototype %}
795 {{install_conditionally_enabled_attributes_on_prototype() | indent(2)}} 803 {{install_conditionally_enabled_attributes_on_prototype() | indent(2)}}
796 {% endif %} 804 {% endif %}
797 {% if methods | conditionally_exposed(is_partial) %} 805 {% if has_conditional_methods %}
798 {{install_conditionally_enabled_methods() | indent(2)}} 806 {{install_conditionally_enabled_methods() | indent(2)}}
799 {% endif %} 807 {% endif %}
800 } 808 }
801 {% endif %} 809 {% endif %}
802 810
803 {% endblock %} 811 {% endblock %}
804 {##############################################################################} 812 {##############################################################################}
805 {% block partial_interface %}{% endblock %} 813 {% block partial_interface %}{% endblock %}
806 } // namespace blink 814 } // namespace blink
807 815
808 {% endfilter %}{# format_blink_cpp_source_code #} 816 {% endfilter %}{# format_blink_cpp_source_code #}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698