1// Copyright 2018 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#ifndef EXTENSIONS_COMMON_EXTENSIONS_API_PROVIDER_H_
6#define EXTENSIONS_COMMON_EXTENSIONS_API_PROVIDER_H_
7
8#include <string>
9
10#include "base/macros.h"
11#include "base/strings/string_piece_forward.h"
12
13namespace extensions {
14class FeatureProvider;
15class JSONFeatureProviderSource;
16class PermissionsInfo;
17
18// A class to provide API-specific bits and bobs to the extensions system.
19// This allows for composition of multiple providers, so that we can easily
20// selectively add features in different configurations.
21class ExtensionsAPIProvider {
22 public:
23 ExtensionsAPIProvider() {}
24 virtual ~ExtensionsAPIProvider() {}
25
26 // Adds feature definitions to the given |provider| of the specified type.
27 virtual void AddAPIFeatures(FeatureProvider* provider) = 0;
28 virtual void AddManifestFeatures(FeatureProvider* provider) = 0;
29 virtual void AddPermissionFeatures(FeatureProvider* provider) = 0;
30 virtual void AddBehaviorFeatures(FeatureProvider* provider) = 0;
31
32 // Adds resources containing the JSON API definitions.
33 virtual void AddAPIJSONSources(JSONFeatureProviderSource* json_source) = 0;
34
35 // Returns true if this provider knows about a generated schema for the given
36 // api |name|.
37 virtual bool IsAPISchemaGenerated(const std::string& name) = 0;
38
39 // Returns a the contents of the generated schema for the given api |name|,
40 // or an empty string if this provider doesn't know of the generated API.
41 virtual base::StringPiece GetAPISchema(const std::string& name) = 0;
42
43 // Registers permissions for any associated API features.
44 virtual void RegisterPermissions(PermissionsInfo* permissions_info) = 0;
45
46 // Registers manifest handlers for any associated API features.
47 virtual void RegisterManifestHandlers() = 0;
48
49 private:
50 DISALLOW_COPY_AND_ASSIGN(ExtensionsAPIProvider);
51};
52
53} // namespace extensions
54
55#endif // EXTENSIONS_COMMON_EXTENSIONS_API_PROVIDER_H_
56