tray_icon_cocoa.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright (c) 2014 GitHub, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #ifndef ELECTRON_SHELL_BROWSER_UI_TRAY_ICON_COCOA_H_
  5. #define ELECTRON_SHELL_BROWSER_UI_TRAY_ICON_COCOA_H_
  6. #import <Cocoa/Cocoa.h>
  7. #include <string>
  8. #include "shell/browser/ui/tray_icon.h"
  9. @class ElectronMenuController;
  10. @class StatusItemView;
  11. namespace electron {
  12. class TrayIconCocoa : public TrayIcon {
  13. public:
  14. TrayIconCocoa();
  15. ~TrayIconCocoa() override;
  16. // TrayIcon
  17. void SetImage(const gfx::Image& image) override;
  18. void SetPressedImage(const gfx::Image& image) override;
  19. void SetToolTip(const std::string& tool_tip) override;
  20. void SetTitle(const std::string& title, const TitleOptions& options) override;
  21. std::string GetTitle() override;
  22. void SetIgnoreDoubleClickEvents(bool ignore) override;
  23. bool GetIgnoreDoubleClickEvents() override;
  24. void PopUpOnUI(base::WeakPtr<ElectronMenuModel> menu_model);
  25. void PopUpContextMenu(const gfx::Point& pos,
  26. base::WeakPtr<ElectronMenuModel> menu_model) override;
  27. void CloseContextMenu() override;
  28. void SetContextMenu(raw_ptr<ElectronMenuModel> menu_model) override;
  29. gfx::Rect GetBounds() override;
  30. base::WeakPtr<TrayIconCocoa> GetWeakPtr() {
  31. return weak_factory_.GetWeakPtr();
  32. }
  33. private:
  34. // Electron custom view for NSStatusItem.
  35. StatusItemView* __strong status_item_view_;
  36. // Status menu shown when right-clicking the system icon.
  37. ElectronMenuController* __strong menu_;
  38. base::WeakPtrFactory<TrayIconCocoa> weak_factory_{this};
  39. };
  40. } // namespace electron
  41. #endif // ELECTRON_SHELL_BROWSER_UI_TRAY_ICON_COCOA_H_