atom_api_menu_views.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright (c) 2014 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_VIEWS_H_
  5. #define ATOM_BROWSER_API_ATOM_API_MENU_VIEWS_H_
  6. #include <map>
  7. #include <memory>
  8. #include "atom/browser/api/atom_api_menu.h"
  9. #include "base/memory/weak_ptr.h"
  10. #include "ui/display/screen.h"
  11. #include "ui/views/controls/menu/menu_runner.h"
  12. namespace atom {
  13. namespace api {
  14. class MenuViews : public Menu {
  15. public:
  16. MenuViews(v8::Isolate* isolate, v8::Local<v8::Object> wrapper);
  17. ~MenuViews() override;
  18. protected:
  19. void PopupAt(TopLevelWindow* window,
  20. int x,
  21. int y,
  22. int positioning_item,
  23. base::OnceClosure callback) override;
  24. void ClosePopupAt(int32_t window_id) override;
  25. private:
  26. void OnClosed(int32_t window_id, base::OnceClosure callback);
  27. // window ID -> open context menu
  28. std::map<int32_t, std::unique_ptr<views::MenuRunner>> menu_runners_;
  29. base::WeakPtrFactory<MenuViews> weak_factory_;
  30. DISALLOW_COPY_AND_ASSIGN(MenuViews);
  31. };
  32. } // namespace api
  33. } // namespace atom
  34. #endif // ATOM_BROWSER_API_ATOM_API_MENU_VIEWS_H_