atom_api_menu_mac.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 ATOM_BROWSER_API_ATOM_API_MENU_MAC_H_
  5. #define ATOM_BROWSER_API_ATOM_API_MENU_MAC_H_
  6. #include "atom/browser/api/atom_api_menu.h"
  7. #include <map>
  8. #include <string>
  9. #import "atom/browser/ui/cocoa/atom_menu_controller.h"
  10. using base::scoped_nsobject;
  11. namespace atom {
  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. const base::Closure& 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::Closure callback);
  28. void ClosePopupAt(int32_t window_id) override;
  29. private:
  30. friend class Menu;
  31. void OnClosed(int32_t window_id, base::Closure 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 atom
  40. #endif // ATOM_BROWSER_API_ATOM_API_MENU_MAC_H_