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