atom_api_browser_view.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // Copyright (c) 2017 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 ATOM_BROWSER_API_ATOM_API_BROWSER_VIEW_H_
  5. #define ATOM_BROWSER_API_ATOM_API_BROWSER_VIEW_H_
  6. #include <memory>
  7. #include <string>
  8. #include "atom/browser/api/trackable_object.h"
  9. #include "atom/browser/native_browser_view.h"
  10. #include "native_mate/handle.h"
  11. namespace gfx {
  12. class Rect;
  13. }
  14. namespace mate {
  15. class Arguments;
  16. class Dictionary;
  17. } // namespace mate
  18. namespace atom {
  19. class NativeBrowserView;
  20. namespace api {
  21. class WebContents;
  22. class BrowserView : public mate::TrackableObject<BrowserView> {
  23. public:
  24. static mate::WrappableBase* New(mate::Arguments* args);
  25. static void BuildPrototype(v8::Isolate* isolate,
  26. v8::Local<v8::FunctionTemplate> prototype);
  27. WebContents* web_contents() const { return api_web_contents_; }
  28. NativeBrowserView* view() const { return view_.get(); }
  29. int32_t ID() const;
  30. protected:
  31. BrowserView(v8::Isolate* isolate,
  32. v8::Local<v8::Object> wrapper,
  33. const mate::Dictionary& options);
  34. ~BrowserView() override;
  35. private:
  36. void Init(v8::Isolate* isolate,
  37. v8::Local<v8::Object> wrapper,
  38. const mate::Dictionary& options);
  39. void SetAutoResize(AutoResizeFlags flags);
  40. void SetBounds(const gfx::Rect& bounds);
  41. void SetBackgroundColor(const std::string& color_name);
  42. v8::Local<v8::Value> GetWebContents();
  43. v8::Global<v8::Value> web_contents_;
  44. class WebContents* api_web_contents_ = nullptr;
  45. std::unique_ptr<NativeBrowserView> view_;
  46. DISALLOW_COPY_AND_ASSIGN(BrowserView);
  47. };
  48. } // namespace api
  49. } // namespace atom
  50. #endif // ATOM_BROWSER_API_ATOM_API_BROWSER_VIEW_H_