binding_generating_native_handler.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // 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. #ifndef EXTENSIONS_RENDERER_BINDING_GENERATING_NATIVE_HANDLER_H_
  5. #define EXTENSIONS_RENDERER_BINDING_GENERATING_NATIVE_HANDLER_H_
  6. #include <string>
  7. #include "base/compiler_specific.h"
  8. #include "extensions/renderer/native_handler.h"
  9. #include "v8/include/v8-forward.h"
  10. namespace extensions {
  11. class ScriptContext;
  12. // Generates API bindings based on the JSON/IDL schemas. This is done by
  13. // creating a |Binding| (from binding.js) for the schema and generating the
  14. // bindings from that.
  15. class BindingGeneratingNativeHandler : public NativeHandler {
  16. public:
  17. // Generates binding for |api_name|, and sets the |bind_to| property on the
  18. // Object returned by |NewInstance| to the generated binding.
  19. BindingGeneratingNativeHandler(ScriptContext* context,
  20. const std::string& api_name,
  21. const std::string& bind_to);
  22. void Initialize() final;
  23. bool IsInitialized() final;
  24. v8::Local<v8::Object> NewInstance() override;
  25. private:
  26. ScriptContext* context_;
  27. std::string api_name_;
  28. std::string bind_to_;
  29. };
  30. } // namespace extensions
  31. #endif // EXTENSIONS_RENDERER_BINDING_GENERATING_NATIVE_HANDLER_H_