Commit 309ce01c authored by kalman@chromium.org's avatar kalman@chromium.org

Docserver: Make API features inherit 'channel' from their dependencies

(manifest or permission features). This fixes the availability data on
accessibilityFeatures and bluetoothLowEnergy, among others; anywhere the API
and dependency name differ.

BUG=375615
R=rockot@chromium.org
NOTRY=true

Review URL: https://codereview.chromium.org/302143003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@273935 0039d316-1c4b-4281-b951-d872f2087c98
parent b2cfd20a
application: chrome-apps-doc application: chrome-apps-doc
version: 3-24-0 version: 3-25-0
runtime: python27 runtime: python27
api_version: 1 api_version: 1
threadsafe: false threadsafe: false
......
...@@ -2,4 +2,4 @@ cron: ...@@ -2,4 +2,4 @@ cron:
- description: Repopulates all cached data. - description: Repopulates all cached data.
url: /_cron url: /_cron
schedule: every 5 minutes schedule: every 5 minutes
target: 3-24-0 target: 3-25-0
...@@ -23,10 +23,10 @@ def _GetFeaturePaths(feature_file, *extra_paths): ...@@ -23,10 +23,10 @@ def _GetFeaturePaths(feature_file, *extra_paths):
return paths return paths
def _AddPlatformsFromDependencies(feature, def _AddPlatformsAndChannelsFromDependencies(feature,
api_features, api_features,
manifest_features, manifest_features,
permission_features): permission_features):
features_map = { features_map = {
'api': api_features, 'api': api_features,
'manifest': manifest_features, 'manifest': manifest_features,
...@@ -34,8 +34,9 @@ def _AddPlatformsFromDependencies(feature, ...@@ -34,8 +34,9 @@ def _AddPlatformsFromDependencies(feature,
} }
dependencies = feature.get('dependencies') dependencies = feature.get('dependencies')
if dependencies is None: if dependencies is None:
return ['apps', 'extensions'] return
platforms = set() platforms = set()
channel = None
for dependency in dependencies: for dependency in dependencies:
dep_type, dep_name = dependency.split(':') dep_type, dep_name = dependency.split(':')
dependency_features = features_map[dep_type] dependency_features = features_map[dep_type]
...@@ -43,9 +44,18 @@ def _AddPlatformsFromDependencies(feature, ...@@ -43,9 +44,18 @@ def _AddPlatformsFromDependencies(feature,
# If the dependency can't be resolved, it is inaccessible and therefore # If the dependency can't be resolved, it is inaccessible and therefore
# so is this feature. # so is this feature.
if dependency_feature is None: if dependency_feature is None:
return [] return
platforms = platforms.union(dependency_feature['platforms']) # Import the platforms from the dependency. The logic is a bit odd; if
feature['platforms'] = list(platforms) # |feature| specifies platforms the it's considered an override. If not,
# we form the union of all dependency's platforms.
# TODO(kalman): Fix this (see http://crbug.com/322094).
platforms.update(dependency_feature.get('platforms', set()))
# Import the channel from the dependency.
channel = dependency_feature.get('channel', channel)
if platforms and not feature.get('platforms'):
feature['platforms'] = list(platforms)
if channel and not feature.get('channel'):
feature['channel'] = channel
class _FeaturesCache(object): class _FeaturesCache(object):
...@@ -126,7 +136,7 @@ class FeaturesBundle(object): ...@@ -126,7 +136,7 @@ class FeaturesBundle(object):
# If we don't store this value before annotating platforms, inter-API # If we don't store this value before annotating platforms, inter-API
# dependencies will lead to infinite recursion. # dependencies will lead to infinite recursion.
for feature in api_features.itervalues(): for feature in api_features.itervalues():
_AddPlatformsFromDependencies( _AddPlatformsAndChannelsFromDependencies(
feature, api_features, manifest_features, permission_features) feature, api_features, manifest_features, permission_features)
self._object_store.Set('api_features', api_features) self._object_store.Set('api_features', api_features)
return api_features return api_features
......
...@@ -29,6 +29,12 @@ _TEST_FILESYSTEM = { ...@@ -29,6 +29,12 @@ _TEST_FILESYSTEM = {
'whitelist': ['im not here'] 'whitelist': ['im not here']
} }
], ],
'inheritsFromDifferentDependencyName': {
'dependencies': ['manifest:inheritsPlatformAndChannelFromDependency']
},
'inheritsPlatformAndChannelFromDependency': {
'dependencies': ['manifest:inheritsPlatformAndChannelFromDependency']
},
'omnibox': { 'omnibox': {
'dependencies': ['manifest:omnibox'], 'dependencies': ['manifest:omnibox'],
'contexts': ['blessed_extension'] 'contexts': ['blessed_extension']
...@@ -48,6 +54,13 @@ _TEST_FILESYSTEM = { ...@@ -48,6 +54,13 @@ _TEST_FILESYSTEM = {
'contexts': [ 'contexts': [
'blessed_extension', 'unblessed_extension', 'content_script'] 'blessed_extension', 'unblessed_extension', 'content_script']
}, },
'overridesPlatformAndChannelFromDependency': {
'channel': 'beta',
'dependencies': [
'permission:overridesPlatformAndChannelFromDependency'
],
'extension_types': ['platform_app']
},
'windows': { 'windows': {
'dependencies': ['api:tabs'], 'dependencies': ['api:tabs'],
'contexts': ['blessed_extension'] 'contexts': ['blessed_extension']
...@@ -64,6 +77,10 @@ _TEST_FILESYSTEM = { ...@@ -64,6 +77,10 @@ _TEST_FILESYSTEM = {
'channel': 'stable', 'channel': 'stable',
'extension_types': ['extension', 'legacy_packaged_app', 'hosted_app'] 'extension_types': ['extension', 'legacy_packaged_app', 'hosted_app']
}, },
'inheritsPlatformAndChannelFromDependency': {
'channel': 'dev',
'extension_types': ['extension']
},
'manifest_version': { 'manifest_version': {
'channel': 'stable', 'channel': 'stable',
'extension_types': 'all' 'extension_types': 'all'
...@@ -87,6 +104,10 @@ _TEST_FILESYSTEM = { ...@@ -87,6 +104,10 @@ _TEST_FILESYSTEM = {
'channel': 'dev', 'channel': 'dev',
'extension_types': ['platform_app'] 'extension_types': ['platform_app']
}, },
'overridesPlatformAndChannelFromDependency': {
'channel': 'stable',
'extension_types': ['extension']
},
'power': { 'power': {
'channel': 'stable', 'channel': 'stable',
'extension_types': [ 'extension_types': [
...@@ -94,7 +115,7 @@ _TEST_FILESYSTEM = { ...@@ -94,7 +115,7 @@ _TEST_FILESYSTEM = {
] ]
}, },
'syncFileSystem': { 'syncFileSystem': {
'channel': 'stable', 'channel': 'beta',
'extension_types': ['platform_app'] 'extension_types': ['platform_app']
}, },
'tabs': { 'tabs': {
...@@ -149,6 +170,11 @@ class FeaturesBundleTest(unittest.TestCase): ...@@ -149,6 +170,11 @@ class FeaturesBundleTest(unittest.TestCase):
'platforms': ['extensions'], 'platforms': ['extensions'],
'documentation': 'background_pages.html' 'documentation': 'background_pages.html'
}, },
'inheritsPlatformAndChannelFromDependency': {
'channel': 'dev',
'name': 'inheritsPlatformAndChannelFromDependency',
'platforms': ['extensions']
},
'manifest_version': { 'manifest_version': {
'name': 'manifest_version', 'name': 'manifest_version',
'channel': 'stable', 'channel': 'stable',
...@@ -191,6 +217,11 @@ class FeaturesBundleTest(unittest.TestCase): ...@@ -191,6 +217,11 @@ class FeaturesBundleTest(unittest.TestCase):
'name': 'fakeUnsupportedFeature', 'name': 'fakeUnsupportedFeature',
'platforms': [] 'platforms': []
}, },
'overridesPlatformAndChannelFromDependency': {
'name': 'overridesPlatformAndChannelFromDependency',
'channel': 'stable',
'platforms': ['extensions']
},
'power': { 'power': {
'name': 'power', 'name': 'power',
'channel': 'stable', 'channel': 'stable',
...@@ -198,7 +229,7 @@ class FeaturesBundleTest(unittest.TestCase): ...@@ -198,7 +229,7 @@ class FeaturesBundleTest(unittest.TestCase):
}, },
'syncFileSystem': { 'syncFileSystem': {
'name': 'syncFileSystem', 'name': 'syncFileSystem',
'channel': 'stable', 'channel': 'beta',
'platforms': ['apps'], 'platforms': ['apps'],
'partial': 'permissions/sync_file_system.html' 'partial': 'permissions/sync_file_system.html'
}, },
...@@ -225,25 +256,49 @@ class FeaturesBundleTest(unittest.TestCase): ...@@ -225,25 +256,49 @@ class FeaturesBundleTest(unittest.TestCase):
'channel': 'stable', 'channel': 'stable',
'platforms': ['extensions'] 'platforms': ['extensions']
}, },
'inheritsFromDifferentDependencyName': {
'channel': 'dev',
'name': 'inheritsFromDifferentDependencyName',
'dependencies': ['manifest:inheritsPlatformAndChannelFromDependency'],
'platforms': ['extensions']
},
'inheritsPlatformAndChannelFromDependency': {
'channel': 'dev',
'name': 'inheritsPlatformAndChannelFromDependency',
'dependencies': ['manifest:inheritsPlatformAndChannelFromDependency'],
'platforms': ['extensions']
},
'omnibox': { 'omnibox': {
'channel': 'stable',
'name': 'omnibox', 'name': 'omnibox',
'platforms': ['extensions'], 'platforms': ['extensions'],
'contexts': ['blessed_extension'], 'contexts': ['blessed_extension'],
'dependencies': ['manifest:omnibox'] 'dependencies': ['manifest:omnibox']
}, },
'overridesPlatformAndChannelFromDependency': {
'channel': 'beta',
'name': 'overridesPlatformAndChannelFromDependency',
'dependencies': [
'permission:overridesPlatformAndChannelFromDependency'
],
'platforms': ['apps']
},
'syncFileSystem': { 'syncFileSystem': {
'channel': 'beta',
'name': 'syncFileSystem', 'name': 'syncFileSystem',
'platforms': ['apps'], 'platforms': ['apps'],
'contexts': ['blessed_extension'], 'contexts': ['blessed_extension'],
'dependencies': ['permission:syncFileSystem'] 'dependencies': ['permission:syncFileSystem']
}, },
'tabs': { 'tabs': {
'channel': 'stable',
'name': 'tabs', 'name': 'tabs',
'channel': 'stable', 'channel': 'stable',
'platforms': ['extensions'], 'platforms': ['extensions'],
'contexts': ['blessed_extension'], 'contexts': ['blessed_extension'],
}, },
'test': { 'test': {
'channel': 'stable',
'name': 'test', 'name': 'test',
'channel': 'stable', 'channel': 'stable',
'platforms': ['apps', 'extensions'], 'platforms': ['apps', 'extensions'],
...@@ -251,6 +306,7 @@ class FeaturesBundleTest(unittest.TestCase): ...@@ -251,6 +306,7 @@ class FeaturesBundleTest(unittest.TestCase):
'blessed_extension', 'unblessed_extension', 'content_script'], 'blessed_extension', 'unblessed_extension', 'content_script'],
}, },
'windows': { 'windows': {
'channel': 'stable',
'name': 'windows', 'name': 'windows',
'platforms': ['extensions'], 'platforms': ['extensions'],
'contexts': ['blessed_extension'], 'contexts': ['blessed_extension'],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment