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

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

Issue 2626183003: Switch RemoteWindowProxy to use v8::Context::NewRemoteContext. (Closed)
Patch Set: . Created 3 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
OLDNEW
1 {% from 'utilities.cpp.tmpl' import declare_enum_validation_variable, v8_value_t o_local_cpp_value %} 1 {% from 'utilities.cpp.tmpl' import declare_enum_validation_variable, v8_value_t o_local_cpp_value %}
2 2
3 {##############################################################################} 3 {##############################################################################}
4 {% macro generate_method(method, world_suffix) %} 4 {% macro generate_method(method, world_suffix) %}
5 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info) { 5 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info) {
6 {% filter format_remove_duplicates([ 6 {% filter format_remove_duplicates([
7 'ExceptionState exceptionState', 7 'ExceptionState exceptionState',
8 'ScriptState* scriptState = ']) %} 8 'ScriptState* scriptState = ']) %}
9 {% set define_exception_state -%} 9 {% set define_exception_state -%}
10 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionCont ext, "{{interface_name}}", "{{method.name}}"); 10 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionCont ext, "{{interface_name}}", "{{method.name}}");
11 {%- endset %} 11 {%- endset %}
12 12
13 {% set function_call = func_call_with_prep_of_args(method, world_suffix) %} 13 {% set function_call = func_call_with_prep_of_args(method, world_suffix) %}
14 14
15 {% if 'exceptionState' in function_call or 15 {% if 'exceptionState' in function_call or
16 (method.returns_promise and not method.is_static) %} 16 (method.returns_promise and not method.is_static) %}
17 {{define_exception_state}} 17 {{define_exception_state}}
18 {% if method.returns_promise %} 18 {% if method.returns_promise %}
19 ExceptionToRejectPromiseScope rejectPromiseScope(info, exceptionState); 19 ExceptionToRejectPromiseScope rejectPromiseScope(info, exceptionState);
20 {% endif %} 20 {% endif %}
21 {% endif %} 21 {% endif %}
22 22
23 {% if not method.is_static %} 23 {% if not method.is_static %}
24 {% if method.returns_promise %} 24 {% if method.returns_promise or (interface_name == 'Window' and method.is_cros s_origin) %}
dcheng 2017/02/14 10:02:02 This is needed because a remote context only has a
Yuki 2017/02/14 11:24:37 a) Does HasInstance() return true for RemoteDOMWin
dcheng 2017/02/15 11:08:41 It seems to work in my local testing.
25 // V8DOMConfiguration::DoNotCheckHolder 25 // V8DOMConfiguration::DoNotCheckHolder
26 // Make sure that info.Holder() really points to an instance of the type. 26 // Make sure that info.Holder() really points to an instance of the type.
27 if (!{{v8_class}}::hasInstance(info.Holder(), info.GetIsolate())) { 27 if (!{{v8_class}}::hasInstance(info.Holder(), info.GetIsolate())) {
28 {{throw_type_error(method, '"Illegal invocation"')}} 28 {{throw_type_error(method, '"Illegal invocation"')}}
29 return; 29 return;
30 } 30 }
31 {% endif %} 31 {% endif %}
32 {% set local_dom_window_only = interface_name == 'Window' and not method.is_cr oss_origin %} 32 {% set local_dom_window_only = interface_name == 'Window' and not method.is_cr oss_origin %}
33 {% if local_dom_window_only %} 33 {% if local_dom_window_only %}
34 {% if method.is_check_security_for_receiver %} 34 {% if method.is_check_security_for_receiver %}
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 540
541 {##############################################################################} 541 {##############################################################################}
542 {% macro origin_safe_method_getter(method, world_suffix) %} 542 {% macro origin_safe_method_getter(method, world_suffix) %}
543 {# TODO(dcheng): Currently, bindings must create a function object for each 543 {# TODO(dcheng): Currently, bindings must create a function object for each
544 realm as a hack to support the incumbent realm. Clean this up when Blink 544 realm as a hack to support the incumbent realm. Clean this up when Blink
545 properly supports the incumbent realm. #} 545 properly supports the incumbent realm. #}
546 static void {{method.name}}OriginSafeMethodGetter{{world_suffix}}(const v8::Prop ertyCallbackInfo<v8::Value>& info) { 546 static void {{method.name}}OriginSafeMethodGetter{{world_suffix}}(const v8::Prop ertyCallbackInfo<v8::Value>& info) {
547 static int domTemplateKey; // This address is used for a key to look up the do m template. 547 static int domTemplateKey; // This address is used for a key to look up the do m template.
548 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate()); 548 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate());
549 const DOMWrapperWorld& world = DOMWrapperWorld::world(info.GetIsolate()->GetCu rrentContext()); 549 const DOMWrapperWorld& world = DOMWrapperWorld::world(info.GetIsolate()->GetCu rrentContext());
550 v8::Local<v8::FunctionTemplate> interfaceTemplate = data->findInterfaceTemplat e(world, &{{v8_class}}::wrapperTypeInfo); 550 v8::Local<v8::Signature> signature;
Yuki 2017/02/14 11:24:37 Could you write a comment that we don't set the si
dcheng 2017/02/15 11:08:41 Done.
551 v8::Local<v8::Signature> signature = v8::Signature::New(info.GetIsolate(), int erfaceTemplate);
552 551
553 v8::Local<v8::FunctionTemplate> methodTemplate = data->findOrCreateOperationTe mplate(world, &domTemplateKey, {{v8_class_or_partial}}::{{method.name}}MethodCal lback{{world_suffix}}, v8Undefined(), signature, {{method.length}}); 552 v8::Local<v8::FunctionTemplate> methodTemplate = data->findOrCreateOperationTe mplate(world, &domTemplateKey, {{v8_class_or_partial}}::{{method.name}}MethodCal lback{{world_suffix}}, v8Undefined(), signature, {{method.length}});
554 // Return the function by default, unless the user script has overwritten it. 553 // Return the function by default, unless the user script has overwritten it.
555 v8SetReturnValue(info, methodTemplate->GetFunction(info.GetIsolate()->GetCurre ntContext()).ToLocalChecked()); 554 v8SetReturnValue(info, methodTemplate->GetFunction(info.GetIsolate()->GetCurre ntContext()).ToLocalChecked());
556 555
557 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); 556 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
558 if (!BindingSecurity::shouldAllowAccessTo(currentDOMWindow(info.GetIsolate()), impl, BindingSecurity::ErrorReportOption::DoNotReport)) { 557 if (!BindingSecurity::shouldAllowAccessTo(currentDOMWindow(info.GetIsolate()), impl, BindingSecurity::ErrorReportOption::DoNotReport)) {
559 return; 558 return;
560 } 559 }
561 560
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 if method.overloads else 657 if method.overloads else
659 method.runtime_enabled_feature_name) %} 658 method.runtime_enabled_feature_name) %}
660 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration = {{method_configuration(method)}}; 659 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration = {{method_configuration(method)}};
661 V8DOMConfiguration::installMethod(isolate, world, v8::Local<v8::Object>(), proto typeObject, interfaceObject, signature, {{method.name}}MethodConfiguration); 660 V8DOMConfiguration::installMethod(isolate, world, v8::Local<v8::Object>(), proto typeObject, interfaceObject, signature, {{method.name}}MethodConfiguration);
662 {% endfilter %}{# runtime_enabled() #} 661 {% endfilter %}{# runtime_enabled() #}
663 {% endfilter %}{# exposed() #} 662 {% endfilter %}{# exposed() #}
664 {% endfilter %}{# secure_context() #} 663 {% endfilter %}{# secure_context() #}
665 {% endfor %} 664 {% endfor %}
666 {% endif %} 665 {% endif %}
667 {%- endmacro %} 666 {%- endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698