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

Side by Side Diff: third_party/WebKit/Source/bindings/scripts/v8_interface.py

Issue 2880713002: Support combination of [OriginTrialEnabled] and [SecureContext] (Closed)
Patch Set: Rebase 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 # Copyright (C) 2013 Google Inc. All rights reserved. 1 # Copyright (C) 2013 Google Inc. All rights reserved.
2 # coding=utf-8 2 # coding=utf-8
3 # 3 #
4 # Redistribution and use in source and binary forms, with or without 4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are 5 # modification, are permitted provided that the following conditions are
6 # met: 6 # met:
7 # 7 #
8 # * Redistributions of source code must retain the above copyright 8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer. 9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above 10 # * Redistributions in binary form must reproduce the above
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 return sorted([member for member in members if member.get(KEY) and not m ember.get('exposed_test')]) 114 return sorted([member for member in members if member.get(KEY) and not m ember.get('exposed_test')])
115 115
116 def member_filter_by_name(members, name): 116 def member_filter_by_name(members, name):
117 return [member for member in members if member[KEY] == name] 117 return [member for member in members if member[KEY] == name]
118 118
119 # Collect all members visible on this interface with a defined origin trial 119 # Collect all members visible on this interface with a defined origin trial
120 origin_trial_constants = member_filter(constants) 120 origin_trial_constants = member_filter(constants)
121 origin_trial_attributes = member_filter(attributes) 121 origin_trial_attributes = member_filter(attributes)
122 origin_trial_methods = member_filter([method for method in methods 122 origin_trial_methods = member_filter([method for method in methods
123 if v8_methods.method_is_visible(method , interface.is_partial) and 123 if v8_methods.method_is_visible(method , interface.is_partial) and
124 not v8_methods.conditionally_exposed(m ethod) and
125 not v8_methods.custom_registration(met hod)]) 124 not v8_methods.custom_registration(met hod)])
126 125
127 feature_names = set([member[KEY] for member in origin_trial_constants + orig in_trial_attributes + origin_trial_methods]) 126 feature_names = set([member[KEY] for member in origin_trial_constants + orig in_trial_attributes + origin_trial_methods])
128 127
129 # Construct the list of dictionaries. 'needs_instance' will be true if any 128 # Construct the list of dictionaries. 'needs_instance' will be true if any
130 # member for the feature has 'on_instance' defined as true. 129 # member for the feature has 'on_instance' defined as true.
131 features = [{'name': name, 130 features = [{'name': name,
132 'constants': member_filter_by_name(origin_trial_constants, name ), 131 'constants': member_filter_by_name(origin_trial_constants, name ),
133 'attributes': member_filter_by_name(origin_trial_attributes, na me), 132 'attributes': member_filter_by_name(origin_trial_attributes, na me),
134 'methods': member_filter_by_name(origin_trial_methods, name)} 133 'methods': member_filter_by_name(origin_trial_methods, name)}
135 for name in feature_names] 134 for name in feature_names]
136 for feature in features: 135 for feature in features:
137 members = feature['constants'] + feature['attributes'] + feature['method s'] 136 members = feature['constants'] + feature['attributes'] + feature['method s']
138 feature['needs_instance'] = reduce(or_, (member.get('on_instance', False ) for member in members)) 137 feature['needs_instance'] = any(member.get('on_instance', False) for mem ber in members)
138 # TODO(chasej): Need to handle method overloads? e.g.
139 # (method['overloads']['secure_context_test_all'] if 'overloads' in meth od else method['secure_context_test'])
140 feature['needs_secure_context'] = any(member.get('secure_context_test', False) for member in members)
139 141
140 if features: 142 if features:
141 includes.add('platform/bindings/ScriptState.h') 143 includes.add('platform/bindings/ScriptState.h')
142 includes.add('core/origin_trials/OriginTrials.h') 144 includes.add('core/origin_trials/OriginTrials.h')
143 return sorted(features) 145 return sorted(features)
144 146
145 147
146 def interface_context(interface, interfaces): 148 def interface_context(interface, interfaces):
147 """Creates a Jinja template context for an interface. 149 """Creates a Jinja template context for an interface.
148 150
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 }) 346 })
345 347
346 # Constants 348 # Constants
347 context.update({ 349 context.update({
348 'constants': [constant_context(constant, interface) for constant in inte rface.constants], 350 'constants': [constant_context(constant, interface) for constant in inte rface.constants],
349 'do_not_check_constants': 'DoNotCheckConstants' in extended_attributes, 351 'do_not_check_constants': 'DoNotCheckConstants' in extended_attributes,
350 }) 352 })
351 353
352 # Attributes 354 # Attributes
353 attributes = attributes_context(interface, interfaces) 355 attributes = attributes_context(interface, interfaces)
356
354 context.update({ 357 context.update({
355 'attributes': attributes, 358 'attributes': attributes,
356 # Elements in attributes are broken in following members. 359 # Elements in attributes are broken in following members.
357 'accessors': v8_attributes.filter_accessors(attributes), 360 'accessors': v8_attributes.filter_accessors(attributes),
358 'data_attributes': v8_attributes.filter_data_attributes(attributes), 361 'data_attributes': v8_attributes.filter_data_attributes(attributes),
359 'lazy_data_attributes': v8_attributes.filter_lazy_data_attributes(attrib utes), 362 'lazy_data_attributes': v8_attributes.filter_lazy_data_attributes(attrib utes),
360 'origin_trial_attributes': v8_attributes.filter_origin_trial_enabled(att ributes),
361 'runtime_enabled_attributes': v8_attributes.filter_runtime_enabled(attri butes), 363 'runtime_enabled_attributes': v8_attributes.filter_runtime_enabled(attri butes),
362 }) 364 })
363 365
366 # Conditionally enabled attributes
367 conditional_enabled_attributes = v8_attributes.filter_conditionally_enabled( attributes)
368 has_conditional_attributes_on_prototype = any( # pylint: disable=invalid-na me
369 attribute['on_prototype'] for attribute in conditional_enabled_attribute s)
370 context.update({
371 'has_conditional_attributes_on_prototype':
372 has_conditional_attributes_on_prototype,
373 'conditionally_enabled_attributes': conditional_enabled_attributes,
374 })
375
364 # Methods 376 # Methods
365 methods, iterator_method = methods_context(interface) 377 methods, iterator_method = methods_context(interface)
366 context.update({ 378 context.update({
367 'has_origin_safe_method_setter': any(method['is_cross_origin'] and not m ethod['is_unforgeable'] 379 'has_origin_safe_method_setter': any(method['is_cross_origin'] and not m ethod['is_unforgeable']
368 for method in methods), 380 for method in methods),
369 'iterator_method': iterator_method, 381 'iterator_method': iterator_method,
370 'methods': methods, 382 'methods': methods,
383 'conditionally_enabled_methods': v8_methods.filter_conditionally_enabled (methods, interface.is_partial),
371 }) 384 })
372 385
373 # Window.idl in Blink has indexed properties, but the spec says Window 386 # Window.idl in Blink has indexed properties, but the spec says Window
374 # interface doesn't have indexed properties, instead the WindowProxy exotic 387 # interface doesn't have indexed properties, instead the WindowProxy exotic
375 # object has indexed properties. Thus, Window interface must not support 388 # object has indexed properties. Thus, Window interface must not support
376 # iterators. 389 # iterators.
377 has_array_iterator = (not interface.is_partial and 390 has_array_iterator = (not interface.is_partial and
378 interface.has_indexed_elements and 391 interface.has_indexed_elements and
379 interface.name != 'Window') 392 interface.name != 'Window')
380 context.update({ 393 context.update({
381 'has_array_iterator': has_array_iterator, 394 'has_array_iterator': has_array_iterator,
382 'iterable': interface.iterable, 395 'iterable': interface.iterable,
383 }) 396 })
384 397
385 # Conditionally enabled members 398 # Conditionally enabled members
386 has_conditional_attributes_on_prototype = any( # pylint: disable=invalid-na me
387 (attribute['exposed_test'] or attribute['secure_context_test']) and attr ibute['on_prototype']
388 for attribute in attributes)
389 context.update({
390 'has_conditional_attributes_on_prototype':
391 has_conditional_attributes_on_prototype,
392 })
393
394 prepare_prototype_and_interface_object_func = None # pylint: disable=invali d-name 399 prepare_prototype_and_interface_object_func = None # pylint: disable=invali d-name
395 if (unscopables or has_conditional_attributes_on_prototype or 400 if (unscopables or has_conditional_attributes_on_prototype or
396 v8_methods.filter_conditionally_exposed(methods, interface.is_partia l)): 401 context['conditionally_enabled_methods']):
397 prepare_prototype_and_interface_object_func = '%s::preparePrototypeAndIn terfaceObject' % v8_class_name_or_partial # pylint: disable=invalid-name 402 prepare_prototype_and_interface_object_func = '%s::preparePrototypeAndIn terfaceObject' % v8_class_name_or_partial # pylint: disable=invalid-name
398 403
399 context.update({ 404 context.update({
400 'prepare_prototype_and_interface_object_func': prepare_prototype_and_int erface_object_func, 405 'prepare_prototype_and_interface_object_func': prepare_prototype_and_int erface_object_func,
401 }) 406 })
402 407
403 context.update({ 408 context.update({
404 'legacy_caller': legacy_caller(interface.legacy_caller, interface), 409 'legacy_caller': legacy_caller(interface.legacy_caller, interface),
405 'indexed_property_getter': property_getter(interface.indexed_property_ge tter, ['index']), 410 'indexed_property_getter': property_getter(interface.indexed_property_ge tter, ['index']),
406 'indexed_property_setter': property_setter(interface.indexed_property_se tter, interface), 411 'indexed_property_setter': property_setter(interface.indexed_property_se tter, interface),
(...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after
1409 extended_attributes = deleter.extended_attributes 1414 extended_attributes = deleter.extended_attributes
1410 is_call_with_script_state = v8_utilities.has_extended_attribute_value(delete r, 'CallWith', 'ScriptState') 1415 is_call_with_script_state = v8_utilities.has_extended_attribute_value(delete r, 'CallWith', 'ScriptState')
1411 is_ce_reactions = 'CEReactions' in extended_attributes 1416 is_ce_reactions = 'CEReactions' in extended_attributes
1412 return { 1417 return {
1413 'is_call_with_script_state': is_call_with_script_state, 1418 'is_call_with_script_state': is_call_with_script_state,
1414 'is_ce_reactions': is_ce_reactions, 1419 'is_ce_reactions': is_ce_reactions,
1415 'is_custom': 'Custom' in extended_attributes, 1420 'is_custom': 'Custom' in extended_attributes,
1416 'is_raises_exception': 'RaisesException' in extended_attributes, 1421 'is_raises_exception': 'RaisesException' in extended_attributes,
1417 'name': cpp_name(deleter), 1422 'name': cpp_name(deleter),
1418 } 1423 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/scripts/v8_attributes.py ('k') | third_party/WebKit/Source/bindings/scripts/v8_methods.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698