| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 from itertools import ifilter | 5 from itertools import ifilter |
| 6 from operator import itemgetter | 6 from operator import itemgetter |
| 7 | 7 |
| 8 import features_utility as features | 8 import features_utility as features |
| 9 from third_party.json_schema_compiler.json_parse import Parse | 9 from third_party.json_schema_compiler.json_parse import Parse |
| 10 | 10 |
| 11 def _ListifyPermissions(permissions): | 11 def _ListifyPermissions(permissions): |
| 12 '''Filter out any permissions that do not have a description or with a name | 12 '''Filter out any permissions that do not have a description or with a name |
| 13 that ends with Private then sort permissions features by name into a list. | 13 that ends with Private then sort permissions features by name into a list. |
| 14 ''' | 14 ''' |
| 15 def filter_permissions(perm): | 15 def filter_permissions(perm): |
| 16 return 'description' in perm and not perm['name'].endswith('Private') | 16 return 'description' in perm and not perm['name'].endswith('Private') |
| 17 | 17 |
| 18 return sorted( | 18 return sorted( |
| 19 ifilter(filter_permissions, permissions.values()), | 19 ifilter(filter_permissions, permissions.values()), |
| 20 key=itemgetter('name')) | 20 key=itemgetter('name')) |
| 21 | 21 |
| 22 def _AddDependencyDescriptions(permissions, api_features): | 22 def _AddDependencyDescriptions(permissions, api_features): |
| 23 '''Use |api_features| to determine the dependencies APIs have on permissions. | 23 '''Use |api_features| to determine the dependencies APIs have on permissions. |
| 24 Add descriptions to |permissions| based on those dependencies. | 24 Add descriptions to |permissions| based on those dependencies. |
| 25 ''' | 25 ''' |
| 26 for name, permission in permissions.iteritems(): | 26 for name, permission in permissions.iteritems(): |
| 27 # Don't overwrite the description created by expanding a partial template. | 27 # Don't overwrite the description created by expanding a partial template. |
| 28 if 'description' in permission or not permission['platforms']: | 28 if 'partial' in permission or not permission['platforms']: |
| 29 continue | 29 continue |
| 30 | 30 |
| 31 has_deps = False | 31 has_deps = False |
| 32 if name in api_features: | 32 if name in api_features: |
| 33 for dependency in api_features[name].get('dependencies', ()): | 33 for dependency in api_features[name].get('dependencies', ()): |
| 34 if dependency.startswith('permission:'): | 34 if dependency.startswith('permission:'): |
| 35 has_deps = True | 35 has_deps = True |
| 36 | 36 |
| 37 if has_deps: | 37 if has_deps: |
| 38 permission['partial'] = 'permissions/generic_description' | 38 permission['partial'] = 'permissions/generic_description' |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 del permission['partial'] | 87 del permission['partial'] |
| 88 | 88 |
| 89 return { | 89 return { |
| 90 'declare_apps': filter_for_platform(permission_features, 'app'), | 90 'declare_apps': filter_for_platform(permission_features, 'app'), |
| 91 'declare_extensions': filter_for_platform( | 91 'declare_extensions': filter_for_platform( |
| 92 permission_features, 'extension') | 92 permission_features, 'extension') |
| 93 } | 93 } |
| 94 | 94 |
| 95 def get(self, key): | 95 def get(self, key): |
| 96 return self._cache.GetFromFile(self._permissions_features_path)[key] | 96 return self._cache.GetFromFile(self._permissions_features_path)[key] |
| OLD | NEW |