Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 191 {% if has_access_check_callbacks and not is_partial %} | 191 {% if has_access_check_callbacks and not is_partial %} |
| 192 {{exported}}bool securityCheck(v8::Local<v8::Context> accessingContext, v8::Loca l<v8::Object> accessedObject, v8::Local<v8::Value> data) { | 192 {{exported}}bool securityCheck(v8::Local<v8::Context> accessingContext, v8::Loca l<v8::Object> accessedObject, v8::Local<v8::Value> data) { |
| 193 {% if interface_name == 'Window' %} | 193 {% if interface_name == 'Window' %} |
| 194 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 194 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 195 v8::Local<v8::Object> window = V8Window::findInstanceInPrototypeChain(accessed Object, isolate); | 195 v8::Local<v8::Object> window = V8Window::findInstanceInPrototypeChain(accessed Object, isolate); |
| 196 if (window.IsEmpty()) | 196 if (window.IsEmpty()) |
| 197 return false; // the frame is gone. | 197 return false; // the frame is gone. |
| 198 | 198 |
| 199 const DOMWindow* targetWindow = V8Window::toImpl(window); | 199 const DOMWindow* targetWindow = V8Window::toImpl(window); |
| 200 return BindingSecurity::shouldAllowAccessTo(toLocalDOMWindow(toDOMWindow(acces singContext)), targetWindow, BindingSecurity::ErrorReportOption::DoNotReport); | 200 return BindingSecurity::shouldAllowAccessTo(toLocalDOMWindow(toDOMWindow(acces singContext)), targetWindow, BindingSecurity::ErrorReportOption::DoNotReport); |
| 201 {% else %}{# if interface_name == 'Window' #} | 201 {% elif interface_name == 'Location' %} |
| 202 {# Not 'Window' means it\'s Location. #} | |
| 203 {{cpp_class}}* impl = {{v8_class}}::toImpl(accessedObject); | 202 {{cpp_class}}* impl = {{v8_class}}::toImpl(accessedObject); |
| 204 return BindingSecurity::shouldAllowAccessTo(toLocalDOMWindow(toDOMWindow(acces singContext)), impl, BindingSecurity::ErrorReportOption::DoNotReport); | 203 return BindingSecurity::shouldAllowAccessTo(toLocalDOMWindow(toDOMWindow(acces singContext)), impl, BindingSecurity::ErrorReportOption::DoNotReport); |
| 205 {% endif %}{# if interface_name == 'Window' #} | 204 {% else %} |
| 205 static_assert(false, "Unexpected security check for interface {{interface_name }}"); | |
|
Yuki
2017/01/26 10:41:54
nit: #error "message" does the trick and it's more
dcheng
2017/01/27 01:31:42
Done.
| |
| 206 {% endif %} | |
| 206 } | 207 } |
| 207 | 208 |
| 208 {% if has_cross_origin_named_enumerator %} | 209 {% if has_cross_origin_named_enumerator %} |
| 209 static const struct { | 210 static const struct { |
| 210 using GetterCallback = void(*)(const v8::PropertyCallbackInfo<v8::Value>&); | 211 using GetterCallback = void(*)(const v8::PropertyCallbackInfo<v8::Value>&); |
| 211 using SetterCallback = void(*)(v8::Local<v8::Value>, const V8CrossOriginSetter Info&); | 212 using SetterCallback = void(*)(v8::Local<v8::Value>, const V8CrossOriginSetter Info&); |
| 212 | 213 |
| 213 const char* const name; | 214 const char* const name; |
| 214 const GetterCallback getter; | 215 const GetterCallback getter; |
| 215 const SetterCallback setter; | 216 const SetterCallback setter; |
| 216 } kCrossOriginAttributeTable[] = { | 217 } kCrossOriginAttributeTable[] = { |
| 217 {##### Cross-origin attributes #####} | 218 {##### Cross-origin attributes #####} |
| 218 {% for attribute in attributes if attribute.has_cross_origin_getter or attribu te.has_cross_origin_setter %} | 219 {% for attribute in attributes if attribute.has_cross_origin_getter or attribu te.has_cross_origin_setter %} |
| 219 { | 220 { |
| 220 "{{attribute.name}}", | 221 "{{attribute.name}}", |
| 221 {%+ if attribute.has_cross_origin_getter %}&{{cpp_class}}V8Internal::{{attri bute.name}}AttributeGetter{% else %}nullptr{% endif %}, | 222 {% if attribute.has_cross_origin_getter %} |
| 223 {% if attribute.has_custom_getter %} | |
| 224 {{v8_class}}::{{attribute.name}}AttributeGetterCustom, | |
| 225 {% else %} | |
| 226 &{{cpp_class}}V8Internal::{{attribute.name}}AttributeGetter, | |
| 227 {% endif %} | |
| 228 {% else %} | |
| 229 nullptr, | |
| 230 {% endif %} | |
| 222 {%+ if attribute.has_cross_origin_setter %}&{{cpp_class}}V8Internal::{{attri bute.name}}AttributeSetter{% else %}nullptr{% endif %}, | 231 {%+ if attribute.has_cross_origin_setter %}&{{cpp_class}}V8Internal::{{attri bute.name}}AttributeSetter{% else %}nullptr{% endif %}, |
| 223 }, | 232 }, |
| 224 {% endfor %} | 233 {% endfor %} |
| 225 {##### Cross-origin methods #####} | 234 {##### Cross-origin methods #####} |
| 226 {% for method in methods if method.is_cross_origin %} | 235 {% for method in methods if method.is_cross_origin %} |
| 227 {"{{method.name}}", &{{cpp_class}}V8Internal::{{method.name}}OriginSafeMethodG etter, nullptr}, | 236 {"{{method.name}}", &{{cpp_class}}V8Internal::{{method.name}}OriginSafeMethodG etter, nullptr}, |
| 228 {% endfor %} | 237 {% endfor %} |
| 229 }; | 238 }; |
| 230 {% endif %} | 239 {% endif %} |
| 231 | 240 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 278 {{v8_class}}::toImpl(info.Holder())->frame()); | 287 {{v8_class}}::toImpl(info.Holder())->frame()); |
| 279 } | 288 } |
| 280 {% endif %} | 289 {% endif %} |
| 281 | 290 |
| 282 {% if has_cross_origin_named_enumerator %} | 291 {% if has_cross_origin_named_enumerator %} |
| 283 {{exported}}void crossOriginNamedEnumerator(const v8::PropertyCallbackInfo<v8::A rray>& info) { | 292 {{exported}}void crossOriginNamedEnumerator(const v8::PropertyCallbackInfo<v8::A rray>& info) { |
| 284 Vector<String> names; | 293 Vector<String> names; |
| 285 for (const auto& attribute : kCrossOriginAttributeTable) | 294 for (const auto& attribute : kCrossOriginAttributeTable) |
| 286 names.push_back(attribute.name); | 295 names.push_back(attribute.name); |
| 287 | 296 |
| 288 v8SetReturnValue( | 297 // Use the current context as the creation context, as a cross-origin access |
| 289 info, | 298 // may involve an object that does not have a creation context. |
| 290 ToV8(names, info.Holder(), info.GetIsolate()).As<v8::Array>()); | 299 v8SetReturnValue(info, |
| 300 ToV8(names, info.GetIsolate()->GetCurrentContext()->Global(), | |
| 301 info.GetIsolate()).As<v8::Array>()); | |
| 291 } | 302 } |
| 292 {% endif %} | 303 {% endif %} |
| 293 | 304 |
| 294 {% if has_cross_origin_indexed_getter %} | 305 {% if has_cross_origin_indexed_getter %} |
| 295 {{exported}}void crossOriginIndexedGetter(uint32_t index, const v8::PropertyCall backInfo<v8::Value>& info) { | 306 {{exported}}void crossOriginIndexedGetter(uint32_t index, const v8::PropertyCall backInfo<v8::Value>& info) { |
| 296 {% if indexed_property_getter.is_custom %} | 307 {% if indexed_property_getter.is_custom %} |
| 297 {{v8_class}}::indexedPropertyGetterCustom(index, info); | 308 {{v8_class}}::indexedPropertyGetterCustom(index, info); |
| 298 {% else %} | 309 {% else %} |
| 299 {{cpp_class}}V8Internal::indexedPropertyGetter(index, info); | 310 {{cpp_class}}V8Internal::indexedPropertyGetter(index, info); |
| 300 {% endif %} | 311 {% endif %} |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 654 {% block has_instance %}{% endblock %} | 665 {% block has_instance %}{% endblock %} |
| 655 {% block to_impl %}{% endblock %} | 666 {% block to_impl %}{% endblock %} |
| 656 {% block to_impl_with_type_check %}{% endblock %} | 667 {% block to_impl_with_type_check %}{% endblock %} |
| 657 {##############################################################################} | 668 {##############################################################################} |
| 658 {% block prepare_prototype_and_interface_object %}{% endblock %} | 669 {% block prepare_prototype_and_interface_object %}{% endblock %} |
| 659 {##############################################################################} | 670 {##############################################################################} |
| 660 {% block partial_interface %}{% endblock %} | 671 {% block partial_interface %}{% endblock %} |
| 661 } // namespace blink | 672 } // namespace blink |
| 662 | 673 |
| 663 {% endfilter %}{# format_blink_cpp_source_code #} | 674 {% endfilter %}{# format_blink_cpp_source_code #} |
| OLD | NEW |