blob: d8975a8de4e9d3e678ea19f98e5114fbeb5b8fb7 [file] [log] [blame]
Avi Drissman3e1a26c2022-09-15 20:26:031// Copyright 2013 The Chromium Authors
[email protected]81fea782013-07-18 23:58:282// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Tom Anderson4ee83742022-07-14 20:58:415#ifndef UI_LINUX_STATUS_ICON_LINUX_H_
6#define UI_LINUX_STATUS_ICON_LINUX_H_
[email protected]81fea782013-07-18 23:58:287
Jan Wilken Dörriead587c32021-03-11 14:09:278#include <string>
9
Tom Anderson4ee83742022-07-14 20:58:4110#include "base/component_export.h"
Keishi Hattorif28f4f82022-06-21 11:32:1511#include "base/memory/raw_ptr.h"
[email protected]81fea782013-07-18 23:58:2812
13namespace gfx {
14class ImageSkia;
Tom Anderson513e0162025-01-09 04:09:4415struct VectorIcon;
[email protected]81fea782013-07-18 23:58:2816}
17
18namespace ui {
19class MenuModel;
20} // namespace ui
21
Tom Anderson992d9872022-07-14 21:24:5022namespace ui {
[email protected]5a991a22013-09-10 09:22:1923
Tom Anderson992d9872022-07-14 21:24:5024// Since linux_ui cannot have dependencies on any chrome browser components
[email protected]81fea782013-07-18 23:58:2825// we cannot inherit from StatusIcon. So we implement the necessary methods
26// and let a wrapper class implement the StatusIcon interface and defer the
[email protected]f528059f2013-08-28 08:23:5927// callbacks to a delegate. For the same reason, do not use StatusIconMenuModel.
Tom Anderson4ee83742022-07-14 20:58:4128class COMPONENT_EXPORT(LINUX_UI) StatusIconLinux {
[email protected]81fea782013-07-18 23:58:2829 public:
30 class Delegate {
31 public:
32 virtual void OnClick() = 0;
[email protected]b6c510aa2013-07-31 23:36:1433 virtual bool HasClickAction() = 0;
[email protected]81fea782013-07-18 23:58:2834
Tom Anderson9cae2892019-06-12 00:15:1935 virtual const gfx::ImageSkia& GetImage() const = 0;
Tom Anderson513e0162025-01-09 04:09:4436 virtual const gfx::VectorIcon* GetIcon() const = 0;
Jan Wilken Dörrie52639572021-03-11 16:49:5437 virtual const std::u16string& GetToolTip() const = 0;
Tom Anderson1dd50612019-06-19 01:36:4138 virtual ui::MenuModel* GetMenuModel() const = 0;
Tom Anderson9cae2892019-06-12 00:15:1939
40 // This should be called at most once by the implementation.
Tom Andersonb1375552019-06-20 20:26:1141 virtual void OnImplInitializationFailed() = 0;
Tom Anderson9cae2892019-06-12 00:15:1942
[email protected]81fea782013-07-18 23:58:2843 protected:
44 virtual ~Delegate();
45 };
46
47 StatusIconLinux();
48 virtual ~StatusIconLinux();
49
Tom Anderson513e0162025-01-09 04:09:4450 virtual void SetImage(const gfx::ImageSkia& image) = 0;
51 virtual void SetIcon(const gfx::VectorIcon& icon) = 0;
Jan Wilken Dörrie52639572021-03-11 16:49:5452 virtual void SetToolTip(const std::u16string& tool_tip) = 0;
[email protected]81fea782013-07-18 23:58:2853
54 // Invoked after a call to SetContextMenu() to let the platform-specific
55 // subclass update the native context menu based on the new model. The
56 // subclass should destroy the existing native context menu on this call.
57 virtual void UpdatePlatformContextMenu(ui::MenuModel* model) = 0;
58
[email protected]f528059f2013-08-28 08:23:5959 // Update all the enabled/checked states and the dynamic labels. Some status
60 // icon implementations do not refresh the native menu before showing so we
61 // need to manually refresh it when the menu model changes.
62 virtual void RefreshPlatformContextMenu();
63
Tom Andersonb1375552019-06-20 20:26:1164 virtual void OnSetDelegate();
65
66 void SetDelegate(Delegate* delegate);
67
[email protected]81fea782013-07-18 23:58:2868 Delegate* delegate() { return delegate_; }
[email protected]81fea782013-07-18 23:58:2869
Tom Anderson9cae2892019-06-12 00:15:1970 protected:
Jeffrey Cohenbf846232023-07-11 23:17:4571 raw_ptr<Delegate> delegate_ = nullptr;
[email protected]81fea782013-07-18 23:58:2872};
73
Tom Anderson992d9872022-07-14 21:24:5074} // namespace ui
[email protected]5a991a22013-09-10 09:22:1975
Tom Anderson4ee83742022-07-14 20:58:4176#endif // UI_LINUX_STATUS_ICON_LINUX_H_