blob: 2f2d553a3f76f799b7748b5035416f6429a5f66b [file] [log] [blame]
[email protected]701a94e2014-04-17 04:37:371// Copyright 2014 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.
4
5#include "extensions/renderer/api_definitions_natives.h"
6
[email protected]701a94e2014-04-17 04:37:377#include "extensions/common/features/feature.h"
8#include "extensions/common/features/feature_provider.h"
[email protected]e6893672014-05-01 17:29:139#include "extensions/renderer/dispatcher.h"
[email protected]701a94e2014-04-17 04:37:3710#include "extensions/renderer/script_context.h"
11
12namespace extensions {
13
14ApiDefinitionsNatives::ApiDefinitionsNatives(Dispatcher* dispatcher,
15 ScriptContext* context)
16 : ObjectBackedNativeHandler(context), dispatcher_(dispatcher) {
17 RouteFunction(
rdevlin.croninc0569cc2016-04-15 21:51:2118 "GetExtensionAPIDefinitionsForTest", "test",
[email protected]701a94e2014-04-17 04:37:3719 base::Bind(&ApiDefinitionsNatives::GetExtensionAPIDefinitionsForTest,
20 base::Unretained(this)));
21}
22
23void ApiDefinitionsNatives::GetExtensionAPIDefinitionsForTest(
24 const v8::FunctionCallbackInfo<v8::Value>& args) {
25 std::vector<std::string> apis;
[email protected]bc495a182014-05-22 04:27:3726 const FeatureProvider* feature_provider = FeatureProvider::GetAPIFeatures();
limasdf8477b572016-03-08 03:04:1527 for (const auto& map_entry : feature_provider->GetAllFeatures()) {
Devlin Cronin8432a8f32017-08-10 22:24:5328 if (!feature_provider->GetParent(*map_entry.second) &&
limasdf8477b572016-03-08 03:04:1529 context()->GetAvailability(map_entry.first).is_available()) {
30 apis.push_back(map_entry.first);
[email protected]701a94e2014-04-17 04:37:3731 }
32 }
33 args.GetReturnValue().Set(
34 dispatcher_->v8_schema_registry()->GetSchemas(apis));
35}
36
37} // namespace extensions