| 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 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 self._permissions_features_path = permissions_features_path | 51 self._permissions_features_path = permissions_features_path |
| 52 self._permissions_json_path = permissions_json_path | 52 self._permissions_json_path = permissions_json_path |
| 53 self._file_system = file_system | 53 self._file_system = file_system |
| 54 self._cache = compiled_fs_factory.Create( | 54 self._cache = compiled_fs_factory.Create( |
| 55 self._CreatePermissionsDataSource, PermissionsDataSource) | 55 self._CreatePermissionsDataSource, PermissionsDataSource) |
| 56 | 56 |
| 57 def SetTemplateDataSource(self, template_data_source_factory): | 57 def SetTemplateDataSource(self, template_data_source_factory): |
| 58 '''Initialize a template data source to be used to render partial templates | 58 '''Initialize a template data source to be used to render partial templates |
| 59 into descriptions for permissions. Must be called before .get | 59 into descriptions for permissions. Must be called before .get |
| 60 ''' | 60 ''' |
| 61 self._template_data_source = template_data_source_factory.Create(None, '') | 61 self._template_data_source = template_data_source_factory.Create( |
| 62 None, '', {}) |
| 62 | 63 |
| 63 def _CreatePermissionsDataSource(self, _, content): | 64 def _CreatePermissionsDataSource(self, _, content): |
| 64 '''Combine the contents of |_permissions_json_path| and | 65 '''Combine the contents of |_permissions_json_path| and |
| 65 |_permissions_features_path|. Filter into lists, one for extensions and | 66 |_permissions_features_path|. Filter into lists, one for extensions and |
| 66 one for apps. | 67 one for apps. |
| 67 ''' | 68 ''' |
| 68 api_features = Parse(self._file_system.ReadSingle(self._api_features_path)) | 69 api_features = Parse(self._file_system.ReadSingle(self._api_features_path)) |
| 69 | 70 |
| 70 def filter_for_platform(permissions, platform): | 71 def filter_for_platform(permissions, platform): |
| 71 return _ListifyPermissions(features.Filtered(permissions, platform)) | 72 return _ListifyPermissions(features.Filtered(permissions, platform)) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 86 del permission['partial'] | 87 del permission['partial'] |
| 87 | 88 |
| 88 return { | 89 return { |
| 89 'declare_apps': filter_for_platform(permission_features, 'app'), | 90 'declare_apps': filter_for_platform(permission_features, 'app'), |
| 90 'declare_extensions': filter_for_platform( | 91 'declare_extensions': filter_for_platform( |
| 91 permission_features, 'extension') | 92 permission_features, 'extension') |
| 92 } | 93 } |
| 93 | 94 |
| 94 def get(self, key): | 95 def get(self, key): |
| 95 return self._cache.GetFromFile(self._permissions_features_path)[key] | 96 return self._cache.GetFromFile(self._permissions_features_path)[key] |
| OLD | NEW |