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
version: 3-24-0
version: 3-25-0
runtime: python27
api_version: 1
threadsafe: false
......
......@@ -2,4 +2,4 @@ cron:
- description: Repopulates all cached data.
url: /_cron
schedule: every 5 minutes
target: 3-24-0
target: 3-25-0
......@@ -23,10 +23,10 @@ def _GetFeaturePaths(feature_file, *extra_paths):
return paths
def _AddPlatformsFromDependencies(feature,
api_features,
manifest_features,
permission_features):
def _AddPlatformsAndChannelsFromDependencies(feature,
api_features,
manifest_features,
permission_features):
features_map = {
'api': api_features,
'manifest': manifest_features,
......@@ -34,8 +34,9 @@ def _AddPlatformsFromDependencies(feature,
}
dependencies = feature.get('dependencies')
if dependencies is None:
return ['apps', 'extensions']
return
platforms = set()
channel = None
for dependency in dependencies:
dep_type, dep_name = dependency.split(':')
dependency_features = features_map[dep_type]
......@@ -43,9 +44,18 @@ def _AddPlatformsFromDependencies(feature,
# 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)
return
# Import the platforms from the dependency. The logic is a bit odd; if
# |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):
......@@ -126,7 +136,7 @@ class FeaturesBundle(object):
# If we don't store this value before annotating platforms, inter-API
# dependencies will lead to infinite recursion.
for feature in api_features.itervalues():
_AddPlatformsFromDependencies(
_AddPlatformsAndChannelsFromDependencies(
feature, api_features, manifest_features, permission_features)
self._object_store.Set('api_features', api_features)
return api_features
......
......@@ -29,6 +29,12 @@ _TEST_FILESYSTEM = {
'whitelist': ['im not here']
}
],
'inheritsFromDifferentDependencyName': {
'dependencies': ['manifest:inheritsPlatformAndChannelFromDependency']
},
'inheritsPlatformAndChannelFromDependency': {
'dependencies': ['manifest:inheritsPlatformAndChannelFromDependency']
},
'omnibox': {
'dependencies': ['manifest:omnibox'],
'contexts': ['blessed_extension']
......@@ -48,6 +54,13 @@ _TEST_FILESYSTEM = {
'contexts': [
'blessed_extension', 'unblessed_extension', 'content_script']
},
'overridesPlatformAndChannelFromDependency': {
'channel': 'beta',
'dependencies': [
'permission:overridesPlatformAndChannelFromDependency'
],
'extension_types': ['platform_app']
},
'windows': {
'dependencies': ['api:tabs'],
'contexts': ['blessed_extension']
......@@ -64,6 +77,10 @@ _TEST_FILESYSTEM = {
'channel': 'stable',
'extension_types': ['extension', 'legacy_packaged_app', 'hosted_app']
},
'inheritsPlatformAndChannelFromDependency': {
'channel': 'dev',
'extension_types': ['extension']
},
'manifest_version': {
'channel': 'stable',
'extension_types': 'all'
......@@ -87,6 +104,10 @@ _TEST_FILESYSTEM = {
'channel': 'dev',
'extension_types': ['platform_app']
},
'overridesPlatformAndChannelFromDependency': {
'channel': 'stable',
'extension_types': ['extension']
},
'power': {
'channel': 'stable',
'extension_types': [
......@@ -94,7 +115,7 @@ _TEST_FILESYSTEM = {
]
},
'syncFileSystem': {
'channel': 'stable',
'channel': 'beta',
'extension_types': ['platform_app']
},
'tabs': {
......@@ -149,6 +170,11 @@ class FeaturesBundleTest(unittest.TestCase):
'platforms': ['extensions'],
'documentation': 'background_pages.html'
},
'inheritsPlatformAndChannelFromDependency': {
'channel': 'dev',
'name': 'inheritsPlatformAndChannelFromDependency',
'platforms': ['extensions']
},
'manifest_version': {
'name': 'manifest_version',
'channel': 'stable',
......@@ -191,6 +217,11 @@ class FeaturesBundleTest(unittest.TestCase):
'name': 'fakeUnsupportedFeature',
'platforms': []
},
'overridesPlatformAndChannelFromDependency': {
'name': 'overridesPlatformAndChannelFromDependency',
'channel': 'stable',
'platforms': ['extensions']
},
'power': {
'name': 'power',
'channel': 'stable',
......@@ -198,7 +229,7 @@ class FeaturesBundleTest(unittest.TestCase):
},
'syncFileSystem': {
'name': 'syncFileSystem',
'channel': 'stable',
'channel': 'beta',
'platforms': ['apps'],
'partial': 'permissions/sync_file_system.html'
},
......@@ -225,25 +256,49 @@ class FeaturesBundleTest(unittest.TestCase):
'channel': 'stable',
'platforms': ['extensions']
},
'inheritsFromDifferentDependencyName': {
'channel': 'dev',
'name': 'inheritsFromDifferentDependencyName',
'dependencies': ['manifest:inheritsPlatformAndChannelFromDependency'],
'platforms': ['extensions']
},
'inheritsPlatformAndChannelFromDependency': {
'channel': 'dev',
'name': 'inheritsPlatformAndChannelFromDependency',
'dependencies': ['manifest:inheritsPlatformAndChannelFromDependency'],
'platforms': ['extensions']
},
'omnibox': {
'channel': 'stable',
'name': 'omnibox',
'platforms': ['extensions'],
'contexts': ['blessed_extension'],
'dependencies': ['manifest:omnibox']
},
'overridesPlatformAndChannelFromDependency': {
'channel': 'beta',
'name': 'overridesPlatformAndChannelFromDependency',
'dependencies': [
'permission:overridesPlatformAndChannelFromDependency'
],
'platforms': ['apps']
},
'syncFileSystem': {
'channel': 'beta',
'name': 'syncFileSystem',
'platforms': ['apps'],
'contexts': ['blessed_extension'],
'dependencies': ['permission:syncFileSystem']
},
'tabs': {
'channel': 'stable',
'name': 'tabs',
'channel': 'stable',
'platforms': ['extensions'],
'contexts': ['blessed_extension'],
},
'test': {
'channel': 'stable',
'name': 'test',
'channel': 'stable',
'platforms': ['apps', 'extensions'],
......@@ -251,6 +306,7 @@ class FeaturesBundleTest(unittest.TestCase):
'blessed_extension', 'unblessed_extension', 'content_script'],
},
'windows': {
'channel': 'stable',
'name': 'windows',
'platforms': ['extensions'],
'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