summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions
diff options
context:
space:
mode:
authorcduvall@chromium.org <cduvall@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-30 19:37:55 +0000
committercduvall@chromium.org <cduvall@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-30 19:37:55 +0000
commitb1b4faa5dca4bb4e29fb2fdb95f6ebda28a55312 (patch)
treee35c1c9c168be580cc5a884ae467e1b43b030367 /chrome/common/extensions
parent790cc105ca5f6881f9052bcefb8b98d079022053 (diff)
downloadchromium_src-b1b4faa5dca4bb4e29fb2fdb95f6ebda28a55312.zip
chromium_src-b1b4faa5dca4bb4e29fb2fdb95f6ebda28a55312.tar.gz
chromium_src-b1b4faa5dca4bb4e29fb2fdb95f6ebda28a55312.tar.bz2
Extensions Docs Server: Pull info from _permission_features.json
APIDataSource now pulls info from _permission_features.json and displays it in the 'Permissions' section. BUG=131095 Review URL: https://chromiumcodereview.appspot.com/10827063 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149000 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions')
-rw-r--r--chrome/common/extensions/docs/server2/api_data_source.py29
-rwxr-xr-xchrome/common/extensions/docs/server2/api_data_source_test.py1
-rw-r--r--chrome/common/extensions/docs/server2/templates/private/standard_api.html10
3 files changed, 38 insertions, 2 deletions
diff --git a/chrome/common/extensions/docs/server2/api_data_source.py b/chrome/common/extensions/docs/server2/api_data_source.py
index 90858cd..bd8852b 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
diff --git a/chrome/common/extensions/docs/server2/api_data_source_test.py b/chrome/common/extensions/docs/server2/api_data_source_test.py
index dea7061..02e42b6 100755
--- a/chrome/common/extensions/docs/server2/api_data_source_test.py
+++ b/chrome/common/extensions/docs/server2/api_data_source_test.py
@@ -25,6 +25,7 @@ class APIDataSourceTest(unittest.TestCase):
# Take the dict out of the list.
expected = json.loads(self._ReadLocalFile('expected_test_file.json'))
+ expected.update({ 'permissions': None })
self.assertEqual(expected, data_source['test_file'])
self.assertEqual(expected, data_source['testFile'])
self.assertEqual(expected, data_source['testFile.html'])
diff --git a/chrome/common/extensions/docs/server2/templates/private/standard_api.html b/chrome/common/extensions/docs/server2/templates/private/standard_api.html
index 1b73000..15772c3 100644
--- a/chrome/common/extensions/docs/server2/templates/private/standard_api.html
+++ b/chrome/common/extensions/docs/server2/templates/private/standard_api.html
@@ -11,6 +11,16 @@
{{+partials.sidenav}}
<div id="gc-pagecontent">
<h1 class="page_title">chrome.{{api.name}}</h1>
+ {{?api.permissions.dev}}
+ <p class="warning">
+ <em>Warning:</em> This API is still under development. It is only
+ available for Chrome users on the
+ <span>
+ <strong>dev</strong>
+ <a href="http://www.chromium.org/getting-involved/dev-channel">early
+ release channel</a>.</span>
+ </p>
+ {{/api.permissions.dev}}
{{+partials.table_of_contents toc:intro.toc}}
{{- This is unindented because it contains <pre> tags -}}
{{+intro.intro}}