cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / chrome / common / extensions / docs / server2 / api_categorizer.py
blob1daf828635525f5a101272595088784d3d5435dd
1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 import os
6 import posixpath
8 from compiled_file_system import SingleFile
9 from extensions_paths import PUBLIC_TEMPLATES
12 class APICategorizer(object):
13 ''' This class gets api category from documented apis.
14 '''
16 def __init__(self, file_system, compiled_fs_factory, platform):
17 self._file_system = file_system
18 self._cache = compiled_fs_factory.Create(file_system,
19 self._CollectDocumentedAPIs,
20 APICategorizer)
21 self._platform = platform
23 def _GenerateAPICategories(self):
24 return self._cache.GetFromFileListing(
25 posixpath.join(PUBLIC_TEMPLATES, self._platform) + '/').Get()
27 @SingleFile
28 def _CollectDocumentedAPIs(self, base_dir, files):
29 public_templates = []
30 for root, _, files in self._file_system.Walk(base_dir):
31 public_templates.extend(posixpath.join(root, name) for name in files)
32 template_names = set(os.path.splitext(name)[0].replace('_', '.')
33 for name in public_templates)
34 return template_names
36 def GetCategory(self, api_name):
37 '''Return the type of api.'Chrome' means the public apis,
38 private means the api only used by chrome, and experimental means
39 the apis with "experimental" prefix.
40 '''
41 documented_apis = self._GenerateAPICategories()
42 if (api_name.endswith('Private') or
43 api_name not in documented_apis):
44 return 'private'
45 if api_name.startswith('experimental.'):
46 return 'experimental'
47 return 'chrome'
49 def IsDocumented(self, api_name):
50 return (api_name in self._GenerateAPICategories())