blob: 30e27bc5d3ae6285e2fcf0d50e6864631294f5d4 [file] [log] [blame]
[email protected]81fea782013-07-18 23:58:281// Copyright 2013 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]5a991a22013-09-10 09:22:195#ifndef UI_VIEWS_LINUX_UI_STATUS_ICON_LINUX_H_
6#define UI_VIEWS_LINUX_UI_STATUS_ICON_LINUX_H_
[email protected]81fea782013-07-18 23:58:287
Jan Wilken Dörriead587c32021-03-11 14:09:278#include <string>
9
[email protected]81fea782013-07-18 23:58:2810#include "base/strings/string16.h"
[email protected]5a991a22013-09-10 09:22:1911#include "ui/views/views_export.h"
[email protected]81fea782013-07-18 23:58:2812
13namespace gfx {
14class ImageSkia;
15}
16
17namespace ui {
18class MenuModel;
19} // namespace ui
20
[email protected]5a991a22013-09-10 09:22:1921namespace views {
22
[email protected]81fea782013-07-18 23:58:2823// Since liblinux_ui cannot have dependencies on any chrome browser components
24// we cannot inherit from StatusIcon. So we implement the necessary methods
25// and let a wrapper class implement the StatusIcon interface and defer the
[email protected]f528059f2013-08-28 08:23:5926// callbacks to a delegate. For the same reason, do not use StatusIconMenuModel.
[email protected]5a991a22013-09-10 09:22:1927class VIEWS_EXPORT StatusIconLinux {
[email protected]81fea782013-07-18 23:58:2828 public:
29 class Delegate {
30 public:
31 virtual void OnClick() = 0;
[email protected]b6c510aa2013-07-31 23:36:1432 virtual bool HasClickAction() = 0;
[email protected]81fea782013-07-18 23:58:2833
Tom Anderson9cae2892019-06-12 00:15:1934 virtual const gfx::ImageSkia& GetImage() const = 0;
35 virtual const base::string16& GetToolTip() const = 0;
Tom Anderson1dd50612019-06-19 01:36:4136 virtual ui::MenuModel* GetMenuModel() const = 0;
Tom Anderson9cae2892019-06-12 00:15:1937
38 // This should be called at most once by the implementation.
Tom Andersonb1375552019-06-20 20:26:1139 virtual void OnImplInitializationFailed() = 0;
Tom Anderson9cae2892019-06-12 00:15:1940
[email protected]81fea782013-07-18 23:58:2841 protected:
42 virtual ~Delegate();
43 };
44
45 StatusIconLinux();
46 virtual ~StatusIconLinux();
47
Tom Andersonb1375552019-06-20 20:26:1148 virtual void SetIcon(const gfx::ImageSkia& image) = 0;
[email protected]2aadf212013-12-18 20:03:4449 virtual void SetToolTip(const base::string16& tool_tip) = 0;
[email protected]81fea782013-07-18 23:58:2850
51 // Invoked after a call to SetContextMenu() to let the platform-specific
52 // subclass update the native context menu based on the new model. The
53 // subclass should destroy the existing native context menu on this call.
54 virtual void UpdatePlatformContextMenu(ui::MenuModel* model) = 0;
55
[email protected]f528059f2013-08-28 08:23:5956 // Update all the enabled/checked states and the dynamic labels. Some status
57 // icon implementations do not refresh the native menu before showing so we
58 // need to manually refresh it when the menu model changes.
59 virtual void RefreshPlatformContextMenu();
60
Tom Andersonb1375552019-06-20 20:26:1161 virtual void OnSetDelegate();
62
63 void SetDelegate(Delegate* delegate);
64
[email protected]81fea782013-07-18 23:58:2865 Delegate* delegate() { return delegate_; }
[email protected]81fea782013-07-18 23:58:2866
Tom Anderson9cae2892019-06-12 00:15:1967 protected:
Robert Liaoe2d8e0c32019-04-12 20:36:4168 Delegate* delegate_ = nullptr;
[email protected]81fea782013-07-18 23:58:2869};
70
[email protected]5a991a22013-09-10 09:22:1971} // namespace views
72
Robert Liaob8ce5f072019-05-20 17:26:2873#endif // UI_VIEWS_LINUX_UI_STATUS_ICON_LINUX_H_