tray_icon_cocoa.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 SHELL_BROWSER_UI_TRAY_ICON_COCOA_H_
  5. #define SHELL_BROWSER_UI_TRAY_ICON_COCOA_H_
  6. #import <Cocoa/Cocoa.h>
  7. #include <string>
  8. #include "base/mac/scoped_nsobject.h"
  9. #include "shell/browser/ui/tray_icon.h"
  10. @class ElectronMenuController;
  11. @class StatusItemView;
  12. namespace electron {
  13. class TrayIconCocoa : public TrayIcon {
  14. public:
  15. TrayIconCocoa();
  16. ~TrayIconCocoa() override;
  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(ElectronMenuModel* menu_model);
  25. void PopUpContextMenu(const gfx::Point& pos,
  26. ElectronMenuModel* menu_model) override;
  27. void CloseContextMenu() override;
  28. void SetContextMenu(ElectronMenuModel* menu_model) override;
  29. gfx::Rect GetBounds() override;
  30. private:
  31. // Electron custom view for NSStatusItem.
  32. base::scoped_nsobject<StatusItemView> status_item_view_;
  33. // Status menu shown when right-clicking the system icon.
  34. base::scoped_nsobject<ElectronMenuController> menu_;
  35. base::WeakPtrFactory<TrayIconCocoa> weak_factory_;
  36. DISALLOW_COPY_AND_ASSIGN(TrayIconCocoa);
  37. };
  38. } // namespace electron
  39. #endif // SHELL_BROWSER_UI_TRAY_ICON_COCOA_H_