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..706eb8cd664183052c0434138635d4a64711a50e 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. |
@@ -22,7 +22,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 +36,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) |
@@ -79,3 +78,32 @@ def MergedWith(features, other): |
features[key]['platforms'] = [] |
return features |
+ |
+def GetPlatformsForExtensionTypes(extension_types): |
not at google - send to devlin
2013/10/01 16:34:34
this can be private?
Ken Rockot(use gerrit already)
2013/10/01 22:18:16
Done.
|
+ 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 AddPlatformsFromDependencies(feature, features_bundle): |
not at google - send to devlin
2013/10/01 16:34:34
as I mentioned earlier - you can put this in featu
Ken Rockot(use gerrit already)
2013/10/01 22:18:16
Done.
|
+ features_map = { |
+ 'api': features_bundle.GetAPIFeatures(), |
+ 'manifest': features_bundle.GetManifestFeatures(), |
+ 'permission': features_bundle.GetPermissionFeatures() |
+ } |
+ dependencies = feature.get('dependencies') |
+ if dependencies is None: |
+ return ['apps', 'extensions'] |
+ platforms = set() |
+ for dependency in dependencies: |
+ dep_type, dep_name = dependency.split(':') |
+ dependency_features = features_map[dep_type] |
+ dependency_feature = dependency_features.get(dep_name) |
+ # If the dependency can't be resolved, it is inaccessible and therefore |
+ # so is this feature. |
+ if dependency_feature is None: |
+ return [] |
+ platforms = platforms.union(dependency_feature['platforms']) |
+ feature['platforms'] = list(platforms) |