extensions_api_provider.h 2.1 KB

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