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

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

Issue 2640123006: Use the current context as the creation context for cross-origin objects. (Closed)
Patch Set: rebase 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 {% 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 using SetterCallback = void(*)(v8::Local<v8::Value>, const V8CrossOriginSetter Info&); 155 using SetterCallback = void(*)(v8::Local<v8::Value>, const V8CrossOriginSetter Info&);
156 156
157 const char* const name; 157 const char* const name;
158 const GetterCallback getter; 158 const GetterCallback getter;
159 const SetterCallback setter; 159 const SetterCallback setter;
160 } kCrossOriginAttributeTable[] = { 160 } kCrossOriginAttributeTable[] = {
161 {##### Cross-origin attributes #####} 161 {##### Cross-origin attributes #####}
162 {% for attribute in attributes if attribute.has_cross_origin_getter or attribu te.has_cross_origin_setter %} 162 {% for attribute in attributes if attribute.has_cross_origin_getter or attribu te.has_cross_origin_setter %}
163 { 163 {
164 "{{attribute.name}}", 164 "{{attribute.name}}",
165 {%+ if attribute.has_cross_origin_getter %}&{{cpp_class}}V8Internal::{{attri bute.name}}AttributeGetter{% else %}nullptr{% endif %}, 165 {% if attribute.has_cross_origin_getter %}
166 {% if attribute.has_custom_getter %}
167 {{v8_class}}::{{attribute.name}}AttributeGetterCustom,
168 {% else %}
169 &{{cpp_class}}V8Internal::{{attribute.name}}AttributeGetter,
170 {% endif %}
171 {% else %}
172 nullptr,
173 {% endif %}
166 {%+ if attribute.has_cross_origin_setter %}&{{cpp_class}}V8Internal::{{attri bute.name}}AttributeSetter{% else %}nullptr{% endif %}, 174 {%+ if attribute.has_cross_origin_setter %}&{{cpp_class}}V8Internal::{{attri bute.name}}AttributeSetter{% else %}nullptr{% endif %},
167 }, 175 },
168 {% endfor %} 176 {% endfor %}
169 {##### Cross-origin methods #####} 177 {##### Cross-origin methods #####}
170 {% for method in methods if method.is_cross_origin %} 178 {% for method in methods if method.is_cross_origin %}
171 {"{{method.name}}", &{{cpp_class}}V8Internal::{{method.name}}OriginSafeMethodG etter, nullptr}, 179 {"{{method.name}}", &{{cpp_class}}V8Internal::{{method.name}}OriginSafeMethodG etter, nullptr},
172 {% endfor %} 180 {% endfor %}
173 }; 181 };
174 {% endif %} 182 {% endif %}
175 {##############################################################################} 183 {##############################################################################}
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 {% if has_access_check_callbacks and not is_partial %} 247 {% if has_access_check_callbacks and not is_partial %}
240 bool {{v8_class_or_partial}}::securityCheck(v8::Local<v8::Context> accessingCont ext, v8::Local<v8::Object> accessedObject, v8::Local<v8::Value> data) { 248 bool {{v8_class_or_partial}}::securityCheck(v8::Local<v8::Context> accessingCont ext, v8::Local<v8::Object> accessedObject, v8::Local<v8::Value> data) {
241 {% if interface_name == 'Window' %} 249 {% if interface_name == 'Window' %}
242 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 250 v8::Isolate* isolate = v8::Isolate::GetCurrent();
243 v8::Local<v8::Object> window = V8Window::findInstanceInPrototypeChain(accessed Object, isolate); 251 v8::Local<v8::Object> window = V8Window::findInstanceInPrototypeChain(accessed Object, isolate);
244 if (window.IsEmpty()) 252 if (window.IsEmpty())
245 return false; // the frame is gone. 253 return false; // the frame is gone.
246 254
247 const DOMWindow* targetWindow = V8Window::toImpl(window); 255 const DOMWindow* targetWindow = V8Window::toImpl(window);
248 return BindingSecurity::shouldAllowAccessTo(toLocalDOMWindow(toDOMWindow(acces singContext)), targetWindow, BindingSecurity::ErrorReportOption::DoNotReport); 256 return BindingSecurity::shouldAllowAccessTo(toLocalDOMWindow(toDOMWindow(acces singContext)), targetWindow, BindingSecurity::ErrorReportOption::DoNotReport);
249 {% else %}{# if interface_name == 'Window' #} 257 {% elif interface_name == 'Location' %}
250 {# Not 'Window' means it\'s Location. #}
251 {{cpp_class}}* impl = {{v8_class}}::toImpl(accessedObject); 258 {{cpp_class}}* impl = {{v8_class}}::toImpl(accessedObject);
252 return BindingSecurity::shouldAllowAccessTo(toLocalDOMWindow(toDOMWindow(acces singContext)), impl, BindingSecurity::ErrorReportOption::DoNotReport); 259 return BindingSecurity::shouldAllowAccessTo(toLocalDOMWindow(toDOMWindow(acces singContext)), impl, BindingSecurity::ErrorReportOption::DoNotReport);
253 {% endif %}{# if interface_name == 'Window' #} 260 {% else %}
261 #error "Unexpected security check for interface {{interface_name}}"
262 {% endif %}
254 } 263 }
255 264
256 {% if has_cross_origin_named_getter %} 265 {% if has_cross_origin_named_getter %}
257 void {{v8_class_or_partial}}::crossOriginNamedGetter(v8::Local<v8::Name> name, c onst v8::PropertyCallbackInfo<v8::Value>& info) { 266 void {{v8_class_or_partial}}::crossOriginNamedGetter(v8::Local<v8::Name> name, c onst v8::PropertyCallbackInfo<v8::Value>& info) {
258 if (!name->IsString()) 267 if (!name->IsString())
259 return; 268 return;
260 const AtomicString& propertyName = toCoreAtomicString(name.As<v8::String>()); 269 const AtomicString& propertyName = toCoreAtomicString(name.As<v8::String>());
261 270
262 for (const auto& attribute : {{cpp_class_or_partial}}V8Internal::kCrossOriginA ttributeTable) { 271 for (const auto& attribute : {{cpp_class_or_partial}}V8Internal::kCrossOriginA ttributeTable) {
263 if (propertyName == attribute.name && attribute.getter) { 272 if (propertyName == attribute.name && attribute.getter) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 {{v8_class}}::toImpl(info.Holder())->frame()); 311 {{v8_class}}::toImpl(info.Holder())->frame());
303 } 312 }
304 {% endif %} 313 {% endif %}
305 314
306 {% if has_cross_origin_named_enumerator %} 315 {% if has_cross_origin_named_enumerator %}
307 void {{v8_class_or_partial}}::crossOriginNamedEnumerator(const v8::PropertyCallb ackInfo<v8::Array>& info) { 316 void {{v8_class_or_partial}}::crossOriginNamedEnumerator(const v8::PropertyCallb ackInfo<v8::Array>& info) {
308 Vector<String> names; 317 Vector<String> names;
309 for (const auto& attribute : {{cpp_class_or_partial}}V8Internal::kCrossOriginA ttributeTable) 318 for (const auto& attribute : {{cpp_class_or_partial}}V8Internal::kCrossOriginA ttributeTable)
310 names.push_back(attribute.name); 319 names.push_back(attribute.name);
311 320
312 v8SetReturnValue( 321 // Use the current context as the creation context, as a cross-origin access
313 info, 322 // may involve an object that does not have a creation context.
314 ToV8(names, info.Holder(), info.GetIsolate()).As<v8::Array>()); 323 v8SetReturnValue(info,
324 ToV8(names, info.GetIsolate()->GetCurrentContext()->Global(),
325 info.GetIsolate()).As<v8::Array>());
315 } 326 }
316 {% endif %} 327 {% endif %}
317 328
318 {% if has_cross_origin_indexed_getter %} 329 {% if has_cross_origin_indexed_getter %}
319 void {{v8_class_or_partial}}::crossOriginIndexedGetter(uint32_t index, const v8: :PropertyCallbackInfo<v8::Value>& info) { 330 void {{v8_class_or_partial}}::crossOriginIndexedGetter(uint32_t index, const v8: :PropertyCallbackInfo<v8::Value>& info) {
320 {% if indexed_property_getter.is_custom %} 331 {% if indexed_property_getter.is_custom %}
321 {{v8_class}}::indexedPropertyGetterCustom(index, info); 332 {{v8_class}}::indexedPropertyGetterCustom(index, info);
322 {% else %} 333 {% else %}
323 {{cpp_class}}V8Internal::indexedPropertyGetter(index, info); 334 {{cpp_class}}V8Internal::indexedPropertyGetter(index, info);
324 {% endif %} 335 {% endif %}
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 {% block has_instance %}{% endblock %} 685 {% block has_instance %}{% endblock %}
675 {% block to_impl %}{% endblock %} 686 {% block to_impl %}{% endblock %}
676 {% block to_impl_with_type_check %}{% endblock %} 687 {% block to_impl_with_type_check %}{% endblock %}
677 {##############################################################################} 688 {##############################################################################}
678 {% block prepare_prototype_and_interface_object %}{% endblock %} 689 {% block prepare_prototype_and_interface_object %}{% endblock %}
679 {##############################################################################} 690 {##############################################################################}
680 {% block partial_interface %}{% endblock %} 691 {% block partial_interface %}{% endblock %}
681 } // namespace blink 692 } // namespace blink
682 693
683 {% endfilter %}{# format_blink_cpp_source_code #} 694 {% endfilter %}{# format_blink_cpp_source_code #}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698