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