Chromium Code Reviews| Index: chrome/common/extensions/docs/server2/api_data_source.py |
| diff --git a/chrome/common/extensions/docs/server2/api_data_source.py b/chrome/common/extensions/docs/server2/api_data_source.py |
| index 90858cd50740f8e64f94a11c25ffaa8548953f5f..ad5d924b083837fe5c5fe9171b03301339b0cff3 100644 |
| --- a/chrome/common/extensions/docs/server2/api_data_source.py |
| +++ b/chrome/common/extensions/docs/server2/api_data_source.py |
| @@ -19,6 +19,7 @@ class APIDataSource(object): |
| def __init__(self, cache_builder, base_path): |
| self._json_cache = cache_builder.build(self._LoadJsonAPI) |
| self._idl_cache = cache_builder.build(self._LoadIdlAPI) |
| + self._permissions_cache = cache_builder.build(self._LoadPermissions) |
| self._base_path = base_path |
| def _LoadJsonAPI(self, api): |
| @@ -31,6 +32,26 @@ class APIDataSource(object): |
| generator = HandlebarDictGenerator(idl_schema.IDLSchema(idl).process()[0]) |
| return generator.Generate() |
| + def _LoadPermissions(self, perms_json): |
| + return json.loads(json_comment_eater.Nom(perms_json)) |
| + |
| + def _GetFeature(self, path): |
| + path = path.replace('experimental_', '') |
|
not at google - send to devlin
2012/07/30 19:24:33
why delete the "experimental" references? add comm
cduvall
2012/07/30 19:37:37
Done.
|
| + try: |
| + perms = self._permissions_cache.GetFromFile( |
| + self._base_path + '/_permission_features.json') |
| + api_perms = perms.get(path, None) |
| + if api_perms['channel'] == 'dev': |
| + api_perms['dev'] = True |
| + return api_perms |
| + except Exception: |
| + return None |
| + |
| + def _AddPermissionsDict(self, api_dict, path): |
| + return_dict = { 'permissions': self._GetFeature(path) } |
| + return_dict.update(api_dict) |
| + return return_dict |
| + |
| def __getitem__(self, key): |
| return self.get(key) |
| @@ -40,10 +61,12 @@ class APIDataSource(object): |
| json_path = unix_name + '.json' |
| idl_path = unix_name + '.idl' |
| try: |
| - return self._json_cache.GetFromFile(self._base_path + '/' + json_path) |
| + return self._AddPermissionsDict(self._json_cache.GetFromFile( |
| + self._base_path + '/' + json_path), path) |
| except Exception: |
| try: |
| - return self._idl_cache.GetFromFile(self._base_path + '/' + idl_path) |
| + return self._AddPermissionsDict(self._idl_cache.GetFromFile( |
| + self._base_path + '/' + idl_path), path) |
| except Exception as e: |
| logging.warn(e) |
| return None |