2014-10-31 18:17:05 +00:00
|
|
|
// Copyright (c) 2013 GitHub, Inc.
|
2014-04-25 09:49:37 +00:00
|
|
|
// Use of this source code is governed by the MIT license that can be
|
2013-05-06 12:27:09 +00:00
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#ifndef ELECTRON_SHELL_BROWSER_API_ELECTRON_API_MENU_MAC_H_
|
|
|
|
#define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_MENU_MAC_H_
|
2013-05-06 12:27:09 +00:00
|
|
|
|
2019-06-19 20:46:59 +00:00
|
|
|
#include "shell/browser/api/electron_api_menu.h"
|
2013-05-06 12:27:09 +00:00
|
|
|
|
2017-02-16 18:58:02 +00:00
|
|
|
#include <map>
|
2014-03-16 01:13:06 +00:00
|
|
|
|
2019-06-19 20:46:59 +00:00
|
|
|
#import "shell/browser/ui/cocoa/electron_menu_controller.h"
|
2013-05-16 02:54:37 +00:00
|
|
|
|
2017-02-16 18:58:02 +00:00
|
|
|
using base::scoped_nsobject;
|
|
|
|
|
2013-05-06 12:27:09 +00:00
|
|
|
namespace electron {
|
|
|
|
|
|
|
|
namespace api {
|
|
|
|
|
|
|
|
class MenuMac : public Menu {
|
|
|
|
protected:
|
2019-10-15 01:15:23 +00:00
|
|
|
explicit MenuMac(gin::Arguments* args);
|
2018-04-17 23:37:22 +00:00
|
|
|
~MenuMac() override;
|
2014-04-21 15:40:10 +00:00
|
|
|
|
2020-06-29 07:06:20 +00:00
|
|
|
void PopupAt(BaseWindow* window,
|
2018-04-18 01:44:10 +00:00
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int positioning_item,
|
2019-11-20 11:17:39 +00:00
|
|
|
base::OnceClosure callback) override;
|
2017-02-15 19:44:25 +00:00
|
|
|
void PopupOnUI(const base::WeakPtr<NativeWindow>& native_window,
|
2017-09-13 21:13:45 +00:00
|
|
|
int32_t window_id,
|
|
|
|
int x,
|
|
|
|
int y,
|
2018-01-01 07:26:19 +00:00
|
|
|
int positioning_item,
|
2019-11-20 11:17:39 +00:00
|
|
|
base::OnceClosure callback);
|
2017-02-16 18:58:02 +00:00
|
|
|
void ClosePopupAt(int32_t window_id) override;
|
2021-06-02 07:32:48 +00:00
|
|
|
std::u16string GetAcceleratorTextAtForTesting(int index) const override;
|
2013-05-06 12:27:09 +00:00
|
|
|
|
|
|
|
private:
|
2013-05-16 02:54:37 +00:00
|
|
|
friend class Menu;
|
|
|
|
|
2021-06-02 07:32:48 +00:00
|
|
|
void ClosePopupOnUI(int32_t window_id);
|
2019-11-20 11:17:39 +00:00
|
|
|
void OnClosed(int32_t window_id, base::OnceClosure callback);
|
2013-05-16 09:25:02 +00:00
|
|
|
|
2017-02-17 20:16:29 +00:00
|
|
|
scoped_nsobject<ElectronMenuController> menu_controller_;
|
|
|
|
|
|
|
|
// window ID -> open context menu
|
|
|
|
std::map<int32_t, scoped_nsobject<ElectronMenuController>> popup_controllers_;
|
|
|
|
|
2021-01-26 18:16:21 +00:00
|
|
|
base::WeakPtrFactory<MenuMac> weak_factory_{this};
|
2013-05-06 12:27:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace api
|
|
|
|
|
|
|
|
} // namespace electron
|
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#endif // ELECTRON_SHELL_BROWSER_API_ELECTRON_API_MENU_MAC_H_
|