2014-10-31 12:17:05 -06:00
|
|
|
// Copyright (c) 2014 GitHub, Inc.
|
2014-05-29 20:31:27 -06:00
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2021-11-22 00:34:31 -07:00
|
|
|
#ifndef ELECTRON_SHELL_BROWSER_UI_TRAY_ICON_COCOA_H_
|
|
|
|
#define ELECTRON_SHELL_BROWSER_UI_TRAY_ICON_COCOA_H_
|
2014-05-29 20:31:27 -06:00
|
|
|
|
2014-05-30 00:37:53 -06:00
|
|
|
#import <Cocoa/Cocoa.h>
|
|
|
|
|
2014-05-29 20:31:27 -06:00
|
|
|
#include <string>
|
|
|
|
|
2019-06-19 14:46:59 -06:00
|
|
|
#include "shell/browser/ui/tray_icon.h"
|
2014-05-30 00:37:53 -06:00
|
|
|
|
2020-02-04 13:19:40 -07:00
|
|
|
@class ElectronMenuController;
|
2015-07-15 04:26:39 -06:00
|
|
|
@class StatusItemView;
|
2014-05-29 20:31:27 -06:00
|
|
|
|
2019-06-19 15:23:04 -06:00
|
|
|
namespace electron {
|
2014-05-29 20:31:27 -06:00
|
|
|
|
2019-07-31 11:52:50 -06:00
|
|
|
class TrayIconCocoa : public TrayIcon {
|
2014-05-29 20:31:27 -06:00
|
|
|
public:
|
2014-05-30 09:57:54 -06:00
|
|
|
TrayIconCocoa();
|
2018-04-17 17:03:51 -06:00
|
|
|
~TrayIconCocoa() override;
|
2014-05-30 09:57:54 -06:00
|
|
|
|
2015-01-09 18:24:36 -07:00
|
|
|
void SetImage(const gfx::Image& image) override;
|
|
|
|
void SetPressedImage(const gfx::Image& image) override;
|
|
|
|
void SetToolTip(const std::string& tool_tip) override;
|
2020-08-23 15:39:29 -06:00
|
|
|
void SetTitle(const std::string& title, const TitleOptions& options) override;
|
2019-03-18 13:40:34 -06:00
|
|
|
std::string GetTitle() override;
|
2018-04-01 19:07:26 -06:00
|
|
|
void SetIgnoreDoubleClickEvents(bool ignore) override;
|
2018-05-03 01:43:46 -06:00
|
|
|
bool GetIgnoreDoubleClickEvents() override;
|
2023-08-01 00:07:30 -06:00
|
|
|
void PopUpOnUI(base::WeakPtr<ElectronMenuModel> menu_model);
|
2015-12-02 03:43:11 -07:00
|
|
|
void PopUpContextMenu(const gfx::Point& pos,
|
2023-08-01 00:07:30 -06:00
|
|
|
base::WeakPtr<ElectronMenuModel> menu_model) override;
|
2020-01-22 16:25:17 -07:00
|
|
|
void CloseContextMenu() override;
|
2023-08-01 00:07:30 -06:00
|
|
|
void SetContextMenu(raw_ptr<ElectronMenuModel> menu_model) override;
|
2016-06-21 00:40:30 -06:00
|
|
|
gfx::Rect GetBounds() override;
|
2014-05-29 20:31:27 -06:00
|
|
|
|
2023-12-11 13:58:26 -07:00
|
|
|
base::WeakPtr<TrayIconCocoa> GetWeakPtr() {
|
|
|
|
return weak_factory_.GetWeakPtr();
|
|
|
|
}
|
|
|
|
|
2014-05-29 20:31:27 -06:00
|
|
|
private:
|
2019-07-31 11:52:50 -06:00
|
|
|
// Electron custom view for NSStatusItem.
|
2023-07-18 16:26:27 -06:00
|
|
|
StatusItemView* __strong status_item_view_;
|
2014-06-01 21:28:23 -06:00
|
|
|
|
2014-05-30 00:37:53 -06:00
|
|
|
// Status menu shown when right-clicking the system icon.
|
2023-07-18 16:26:27 -06:00
|
|
|
ElectronMenuController* __strong menu_;
|
2014-05-30 00:37:53 -06:00
|
|
|
|
2021-01-26 11:16:21 -07:00
|
|
|
base::WeakPtrFactory<TrayIconCocoa> weak_factory_{this};
|
2014-05-29 20:31:27 -06:00
|
|
|
};
|
|
|
|
|
2019-06-19 15:23:04 -06:00
|
|
|
} // namespace electron
|
2014-05-29 20:31:27 -06:00
|
|
|
|
2021-11-22 00:34:31 -07:00
|
|
|
#endif // ELECTRON_SHELL_BROWSER_UI_TRAY_ICON_COCOA_H_
|