tray_icon_cocoa.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. void SetImage(const gfx::Image& image) override;
  17. void SetPressedImage(const gfx::Image& image) override;
  18. void SetToolTip(const std::string& tool_tip) override;
  19. void SetTitle(const std::string& title, const TitleOptions& options) override;
  20. std::string GetTitle() override;
  21. void SetIgnoreDoubleClickEvents(bool ignore) override;
  22. bool GetIgnoreDoubleClickEvents() override;
  23. void PopUpOnUI(base::WeakPtr<ElectronMenuModel> menu_model);
  24. void PopUpContextMenu(const gfx::Point& pos,
  25. base::WeakPtr<ElectronMenuModel> menu_model) override;
  26. void CloseContextMenu() override;
  27. void SetContextMenu(raw_ptr<ElectronMenuModel> menu_model) override;
  28. gfx::Rect GetBounds() override;
  29. base::WeakPtr<TrayIconCocoa> GetWeakPtr() {
  30. return weak_factory_.GetWeakPtr();
  31. }
  32. private:
  33. // Electron custom view for NSStatusItem.
  34. StatusItemView* __strong status_item_view_;
  35. // Status menu shown when right-clicking the system icon.
  36. ElectronMenuController* __strong menu_;
  37. base::WeakPtrFactory<TrayIconCocoa> weak_factory_{this};
  38. };
  39. } // namespace electron
  40. #endif // ELECTRON_SHELL_BROWSER_UI_TRAY_ICON_COCOA_H_