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..bd8852bdba978b9835daa556af2bf9ce7da8cc42 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,28 @@ 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): |
+ # Remove 'experimental_' from path name to match the keys in |
+ # _permissions_features.json. |
+ path = path.replace('experimental_', '') |
+ 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 +63,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 |