electron_api_view.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Copyright (c) 2018 GitHub, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #ifndef ELECTRON_SHELL_BROWSER_API_ELECTRON_API_VIEW_H_
  5. #define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_VIEW_H_
  6. #include "gin/handle.h"
  7. #include "shell/common/gin_helper/wrappable.h"
  8. #include "ui/views/view.h"
  9. namespace electron::api {
  10. class View : public gin_helper::Wrappable<View> {
  11. public:
  12. static gin_helper::WrappableBase* New(gin::Arguments* args);
  13. static void BuildPrototype(v8::Isolate* isolate,
  14. v8::Local<v8::FunctionTemplate> prototype);
  15. views::View* view() const { return view_; }
  16. // disable copy
  17. View(const View&) = delete;
  18. View& operator=(const View&) = delete;
  19. protected:
  20. explicit View(views::View* view);
  21. View();
  22. ~View() override;
  23. // Should delete the |view_| in destructor.
  24. void set_delete_view(bool should) { delete_view_ = should; }
  25. private:
  26. bool delete_view_ = true;
  27. views::View* view_ = nullptr;
  28. };
  29. } // namespace electron::api
  30. #endif // ELECTRON_SHELL_BROWSER_API_ELECTRON_API_VIEW_H_