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

Unified Diff: chrome/common/extensions/docs/server2/api_data_source.py

Issue 10827063: Extensions Docs Server: Pull info from _permission_features.json (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clean up Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/common/extensions/docs/server2/api_data_source_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | chrome/common/extensions/docs/server2/api_data_source_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698