atom_api_menu_mac.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright (c) 2013 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 SHELL_BROWSER_API_ATOM_API_MENU_MAC_H_
  5. #define SHELL_BROWSER_API_ATOM_API_MENU_MAC_H_
  6. #include "shell/browser/api/atom_api_menu.h"
  7. #include <map>
  8. #include <string>
  9. #import "shell/browser/ui/cocoa/atom_menu_controller.h"
  10. using base::scoped_nsobject;
  11. namespace electron {
  12. namespace api {
  13. class MenuMac : public Menu {
  14. protected:
  15. MenuMac(v8::Isolate* isolate, v8::Local<v8::Object> wrapper);
  16. ~MenuMac() override;
  17. void PopupAt(TopLevelWindow* window,
  18. int x,
  19. int y,
  20. int positioning_item,
  21. base::OnceClosure callback) override;
  22. void PopupOnUI(const base::WeakPtr<NativeWindow>& native_window,
  23. int32_t window_id,
  24. int x,
  25. int y,
  26. int positioning_item,
  27. base::OnceClosure callback);
  28. void ClosePopupAt(int32_t window_id) override;
  29. private:
  30. friend class Menu;
  31. void OnClosed(int32_t window_id, base::OnceClosure callback);
  32. scoped_nsobject<AtomMenuController> menu_controller_;
  33. // window ID -> open context menu
  34. std::map<int32_t, scoped_nsobject<AtomMenuController>> popup_controllers_;
  35. base::WeakPtrFactory<MenuMac> weak_factory_;
  36. DISALLOW_COPY_AND_ASSIGN(MenuMac);
  37. };
  38. } // namespace api
  39. } // namespace electron
  40. #endif // SHELL_BROWSER_API_ATOM_API_MENU_MAC_H_