tray_icon_cocoa.h 1.5 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 ATOM_BROWSER_UI_TRAY_ICON_COCOA_H_
  5. #define ATOM_BROWSER_UI_TRAY_ICON_COCOA_H_
  6. #import <Cocoa/Cocoa.h>
  7. #include <string>
  8. #include "atom/browser/ui/tray_icon.h"
  9. #include "base/mac/scoped_nsobject.h"
  10. @class AtomMenuController;
  11. @class StatusItemView;
  12. namespace atom {
  13. class TrayIconCocoa : public TrayIcon,
  14. public AtomMenuModel::Observer {
  15. public:
  16. TrayIconCocoa();
  17. virtual ~TrayIconCocoa();
  18. void SetImage(const gfx::Image& image) override;
  19. void SetPressedImage(const gfx::Image& image) override;
  20. void SetToolTip(const std::string& tool_tip) override;
  21. void SetTitle(const std::string& title) override;
  22. void SetHighlightMode(TrayIcon::HighlightMode mode) override;
  23. void PopUpContextMenu(const gfx::Point& pos,
  24. AtomMenuModel* menu_model) override;
  25. void SetContextMenu(AtomMenuModel* menu_model) override;
  26. gfx::Rect GetBounds() override;
  27. protected:
  28. // AtomMenuModel::Observer:
  29. void OnMenuWillClose() override;
  30. private:
  31. // Atom 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<AtomMenuController> menu_;
  35. // Used for unregistering observer.
  36. AtomMenuModel* menu_model_; // weak ref.
  37. DISALLOW_COPY_AND_ASSIGN(TrayIconCocoa);
  38. };
  39. } // namespace atom
  40. #endif // ATOM_BROWSER_UI_TRAY_ICON_COCOA_H_