Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: chrome/common/extensions/docs/server2/api_list_data_source.py

Issue 375133002: Docserver: Display API features that are available to content scripts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 from data_source import DataSource 5 from data_source import DataSource
6 from future import Future 6 from future import Future
7 from operator import itemgetter 7 from operator import itemgetter
8 from platform_util import GetPlatforms 8 from platform_util import GetPlatforms
9 9
10 from docs_server_utils import MarkLast 10 from docs_server_utils import MarkLast
(...skipping 13 matching lines...) Expand all
24 "extension_types" property where either/both "extension"/"platform_app" 24 "extension_types" property where either/both "extension"/"platform_app"
25 values are present. 25 values are present.
26 """ 26 """
27 def __init__(self, server_instance, _): 27 def __init__(self, server_instance, _):
28 self._platform_bundle = server_instance.platform_bundle 28 self._platform_bundle = server_instance.platform_bundle
29 self._object_store = server_instance.object_store_creator.Create( 29 self._object_store = server_instance.object_store_creator.Create(
30 # Update the model when the API or Features model updates. 30 # Update the model when the API or Features model updates.
31 APIListDataSource, category=self._platform_bundle.GetIdentity()) 31 APIListDataSource, category=self._platform_bundle.GetIdentity())
32 32
33 def _GenerateAPIDict(self): 33 def _GenerateAPIDict(self):
34 def make_list_for_content_scripts():
35 content_scripts_apis = self._platform_bundle.GetAPIModels(
36 'extensions').GetContentScriptsAPIs().Get()
37 content_scripts_apis_list = content_scripts_apis.values()
38 content_scripts_apis_list.sort(key=itemgetter('name'))
39 return content_scripts_apis_list
not at google - send to devlin 2014/07/09 03:03:00 we should filter out undocumented APIs here, much
40
34 def make_dict_for_platform(platform): 41 def make_dict_for_platform(platform):
35 platform_dict = { 42 platform_dict = {
36 'chrome': {'stable': [], 'beta': [], 'dev': [], 'trunk': []}, 43 'chrome': {'stable': [], 'beta': [], 'dev': [], 'trunk': []},
37 } 44 }
38 private_apis = [] 45 private_apis = []
39 experimental_apis = [] 46 experimental_apis = []
40 all_apis = [] 47 all_apis = []
41 for api_name, api_model in self._platform_bundle.GetAPIModels( 48 for api_name, api_model in self._platform_bundle.GetAPIModels(
42 platform).IterModels(): 49 platform).IterModels():
43 if not self._platform_bundle.GetAPICategorizer(platform).IsDocumented( 50 if not self._platform_bundle.GetAPICategorizer(platform).IsDocumented(
(...skipping 26 matching lines...) Expand all
70 platform_dict['chrome'][channel] = apis_by_channel 77 platform_dict['chrome'][channel] = apis_by_channel
71 78
72 for key, apis in (('all', all_apis), 79 for key, apis in (('all', all_apis),
73 ('private', private_apis), 80 ('private', private_apis),
74 ('experimental', experimental_apis)): 81 ('experimental', experimental_apis)):
75 apis.sort(key=itemgetter('name')) 82 apis.sort(key=itemgetter('name'))
76 MarkLast(apis) 83 MarkLast(apis)
77 platform_dict[key] = apis 84 platform_dict[key] = apis
78 85
79 return platform_dict 86 return platform_dict
80 return dict((platform, make_dict_for_platform(platform)) 87 api_dict = dict((platform, make_dict_for_platform(platform))
81 for platform in GetPlatforms()) 88 for platform in GetPlatforms())
89 api_dict['content_scripts'] = make_list_for_content_scripts()
90 return api_dict
82 91
83 def _GetCachedAPIData(self): 92 def _GetCachedAPIData(self):
84 data_future = self._object_store.Get('api_data') 93 data_future = self._object_store.Get('api_data')
85 def resolve(): 94 def resolve():
86 data = data_future.Get() 95 data = data_future.Get()
87 if data is None: 96 if data is None:
88 data = self._GenerateAPIDict() 97 data = self._GenerateAPIDict()
89 self._object_store.Set('api_data', data) 98 self._object_store.Set('api_data', data)
90 return data 99 return data
91 return Future(callback=resolve) 100 return Future(callback=resolve)
92 101
93 def get(self, key): 102 def get(self, key):
94 return self._GetCachedAPIData().Get().get(key) 103 return self._GetCachedAPIData().Get().get(key)
95 104
96 def Cron(self): 105 def Cron(self):
97 return self._GetCachedAPIData() 106 return self._GetCachedAPIData()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698