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

Side by Side Diff: lib/html/scripts/systemnative.py

Issue 11175014: Use CheckSecurityForNode to filter out insecure calls (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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 | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
3 # for details. All rights reserved. Use of this source code is governed by a 3 # for details. All rights reserved. Use of this source code is governed by a
4 # BSD-style license that can be found in the LICENSE file. 4 # BSD-style license that can be found in the LICENSE file.
5 5
6 """This module provides shared functionality for the systems to generate 6 """This module provides shared functionality for the systems to generate
7 native binding from the IDL database.""" 7 native binding from the IDL database."""
8 8
9 import emitter 9 import emitter
10 import os 10 import os
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 WEBCORE_INCLUDES=webcore_includes, 267 WEBCORE_INCLUDES=webcore_includes,
268 WEBCORE_CLASS_NAME=self._interface_type_info.native_type(), 268 WEBCORE_CLASS_NAME=self._interface_type_info.native_type(),
269 DECLARATIONS=self._cpp_declarations_emitter.Fragments(), 269 DECLARATIONS=self._cpp_declarations_emitter.Fragments(),
270 IS_NODE=TypeCheckHelper(is_node_test), 270 IS_NODE=TypeCheckHelper(is_node_test),
271 IS_ACTIVE=TypeCheckHelper(is_active_test), 271 IS_ACTIVE=TypeCheckHelper(is_active_test),
272 IS_EVENT_TARGET=TypeCheckHelper(is_event_target_test), 272 IS_EVENT_TARGET=TypeCheckHelper(is_event_target_test),
273 TO_NATIVE=to_native_emitter.Fragments(), 273 TO_NATIVE=to_native_emitter.Fragments(),
274 TO_DART=to_dart_emitter.Fragments()) 274 TO_DART=to_dart_emitter.Fragments())
275 275
276 def AddAttribute(self, attribute, html_name, read_only): 276 def AddAttribute(self, attribute, html_name, read_only):
277 if 'CheckSecurityForNode' in attribute.ext_attrs:
278 # FIXME: exclude from interface as well.
279 return
280
281 self._AddGetter(attribute, html_name) 277 self._AddGetter(attribute, html_name)
282 if not read_only: 278 if not read_only:
283 self._AddSetter(attribute, html_name) 279 self._AddSetter(attribute, html_name)
284 280
285 def _AddGetter(self, attr, html_name): 281 def _AddGetter(self, attr, html_name):
286 type_info = self._TypeInfo(attr.type.id) 282 type_info = self._TypeInfo(attr.type.id)
287 dart_declaration = '%s get %s' % (SecureOutputType(self, attr.type.id), html _name) 283 dart_declaration = '%s get %s' % (SecureOutputType(self, attr.type.id), html _name)
288 is_custom = 'Custom' in attr.ext_attrs or 'CustomGetter' in attr.ext_attrs 284 is_custom = 'Custom' in attr.ext_attrs or 'CustomGetter' in attr.ext_attrs
289 cpp_callback_name = self._GenerateNativeBinding(attr.id, 1, 285 cpp_callback_name = self._GenerateNativeBinding(attr.id, 1,
290 dart_declaration, 'Getter', is_custom) 286 dart_declaration, 'Getter', is_custom)
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 'Callback', True) 434 'Callback', True)
439 435
440 def AddOperation(self, info, html_name): 436 def AddOperation(self, info, html_name):
441 """ 437 """
442 Arguments: 438 Arguments:
443 info: An OperationInfo object. 439 info: An OperationInfo object.
444 """ 440 """
445 441
446 operation = info.operations[0] 442 operation = info.operations[0]
447 443
448 if 'CheckSecurityForNode' in operation.ext_attrs:
449 # FIXME: exclude from interface as well.
450 return
451
452 is_custom = 'Custom' in operation.ext_attrs 444 is_custom = 'Custom' in operation.ext_attrs
453 has_optional_arguments = any(self._IsArgumentOptionalInWebCore(operation, ar gument) for argument in operation.arguments) 445 has_optional_arguments = any(self._IsArgumentOptionalInWebCore(operation, ar gument) for argument in operation.arguments)
454 needs_dispatcher = not is_custom and (len(info.operations) > 1 or has_option al_arguments) 446 needs_dispatcher = not is_custom and (len(info.operations) > 1 or has_option al_arguments)
455 447
456 dart_declaration = '%s%s %s(%s)' % ( 448 dart_declaration = '%s%s %s(%s)' % (
457 'static ' if info.IsStatic() else '', 449 'static ' if info.IsStatic() else '',
458 SecureOutputType(self, info.type_name), 450 SecureOutputType(self, info.type_name),
459 html_name, 451 html_name,
460 info.ParametersDeclaration( 452 info.ParametersDeclaration(
461 (lambda x: 'Dynamic') if needs_dispatcher else self._DartType)) 453 (lambda x: 'Dynamic') if needs_dispatcher else self._DartType))
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 def EmitResolver(self, template, output_dir): 856 def EmitResolver(self, template, output_dir):
865 file_path = os.path.join(output_dir, 'DartResolver.cpp') 857 file_path = os.path.join(output_dir, 'DartResolver.cpp')
866 includes_emitter, body_emitter = self._emitters.FileEmitter(file_path).Emit( template) 858 includes_emitter, body_emitter = self._emitters.FileEmitter(file_path).Emit( template)
867 for header_file in self._headers_list: 859 for header_file in self._headers_list:
868 path = os.path.relpath(header_file, output_dir) 860 path = os.path.relpath(header_file, output_dir)
869 includes_emitter.Emit('#include "$PATH"\n', PATH=path) 861 includes_emitter.Emit('#include "$PATH"\n', PATH=path)
870 body_emitter.Emit( 862 body_emitter.Emit(
871 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argume ntCount))\n' 863 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argume ntCount))\n'
872 ' return func;\n', 864 ' return func;\n',
873 CLASS_NAME=os.path.splitext(os.path.basename(path))[0]) 865 CLASS_NAME=os.path.splitext(os.path.basename(path))[0])
OLDNEW
« lib/html/scripts/htmlrenamer.py ('K') | « lib/html/scripts/systemhtml.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698