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