Index: chrome/common/extensions/docs/server2/features_utility.py |
diff --git a/chrome/common/extensions/docs/server2/features_utility.py b/chrome/common/extensions/docs/server2/features_utility.py |
index f9626914811c32a81cfb047bf03454637d763161..d8ca3e7dd1056861182e583cae515067cb5e95e5 100644 |
--- a/chrome/common/extensions/docs/server2/features_utility.py |
+++ b/chrome/common/extensions/docs/server2/features_utility.py |
@@ -7,7 +7,7 @@ Utility functions for working with the Feature abstraction. Features are grouped |
into a dictionary by name. Each Feature is guaranteed to have the following two |
keys: |
name - a string, the name of the feature |
- platform - a list containing 'app' or 'extension', both, or neither. |
+ platform - a list containing 'apps' or 'extensions', both, or neither. |
A Feature may have other keys from a _features.json file as well. Features with |
a whitelist are ignored as they are only useful to specific apps or extensions. |
@@ -15,6 +15,14 @@ a whitelist are ignored as they are only useful to specific apps or extensions. |
from copy import deepcopy |
+def _GetPlatformsForExtensionTypes(extension_types): |
+ platforms = [] |
+ if extension_types == 'all' or 'platform_app' in extension_types: |
+ platforms.append('apps') |
+ if extension_types == 'all' or 'extension' in extension_types: |
+ platforms.append('extensions') |
+ return platforms |
+ |
def Parse(features_json): |
'''Process JSON from a _features.json file, standardizing it into a dictionary |
of Features. |
@@ -22,7 +30,7 @@ def Parse(features_json): |
features = {} |
for name, value in deepcopy(features_json).iteritems(): |
- # Some feature names corrispond to a list; force a list down to a single |
+ # Some feature names correspond to a list; force a list down to a single |
# feature by removing entries that have a 'whitelist'. |
if isinstance(value, list): |
values = [subvalue for subvalue in value if not 'whitelist' in subvalue] |
@@ -36,11 +44,10 @@ def Parse(features_json): |
features[name] = { 'platforms': [] } |
- platforms = value.pop('extension_types') |
- if platforms == 'all' or 'platform_app' in platforms: |
- features[name]['platforms'].append('app') |
- if platforms == 'all' or 'extension' in platforms: |
- features[name]['platforms'].append('extension') |
+ extension_types = value.pop('extension_types', None) |
+ if extension_types is not None: |
+ features[name]['platforms'] = _GetPlatformsForExtensionTypes( |
+ extension_types) |
features[name]['name'] = name |
features[name].update(value) |