feat: add support for share menu on macOS (#25629)
This commit is contained in:
parent
89c04b3c6c
commit
6b6ffbdd10
17 changed files with 316 additions and 6 deletions
|
@ -4,10 +4,18 @@
|
|||
|
||||
#include "shell/browser/ui/electron_menu_model.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "base/stl_util.h"
|
||||
|
||||
namespace electron {
|
||||
|
||||
#if defined(OS_MAC)
|
||||
ElectronMenuModel::SharingItem::SharingItem() = default;
|
||||
ElectronMenuModel::SharingItem::SharingItem(SharingItem&&) = default;
|
||||
ElectronMenuModel::SharingItem::~SharingItem() = default;
|
||||
#endif
|
||||
|
||||
bool ElectronMenuModel::Delegate::GetAcceleratorForCommandId(
|
||||
int command_id,
|
||||
ui::Accelerator* accelerator) const {
|
||||
|
@ -79,6 +87,23 @@ bool ElectronMenuModel::WorksWhenHiddenAt(int index) const {
|
|||
return true;
|
||||
}
|
||||
|
||||
#if defined(OS_MAC)
|
||||
bool ElectronMenuModel::GetSharingItemAt(int index, SharingItem* item) const {
|
||||
if (delegate_)
|
||||
return delegate_->GetSharingItemForCommandId(GetCommandIdAt(index), item);
|
||||
return false;
|
||||
}
|
||||
|
||||
void ElectronMenuModel::SetSharingItem(SharingItem item) {
|
||||
sharing_item_.emplace(std::move(item));
|
||||
}
|
||||
|
||||
const base::Optional<ElectronMenuModel::SharingItem>&
|
||||
ElectronMenuModel::GetSharingItem() const {
|
||||
return sharing_item_;
|
||||
}
|
||||
#endif
|
||||
|
||||
void ElectronMenuModel::MenuWillClose() {
|
||||
ui::SimpleMenuModel::MenuWillClose();
|
||||
for (Observer& observer : observers_) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue