[email protected] | 81fea78 | 2013-07-18 23:58:28 | [diff] [blame] | 1 | // 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] | 5a991a2 | 2013-09-10 09:22:19 | [diff] [blame] | 5 | #ifndef UI_VIEWS_LINUX_UI_STATUS_ICON_LINUX_H_ |
6 | #define UI_VIEWS_LINUX_UI_STATUS_ICON_LINUX_H_ | ||||
[email protected] | 81fea78 | 2013-07-18 23:58:28 | [diff] [blame] | 7 | |
Jan Wilken Dörrie | ad587c3 | 2021-03-11 14:09:27 | [diff] [blame^] | 8 | #include <string> |
9 | |||||
[email protected] | 81fea78 | 2013-07-18 23:58:28 | [diff] [blame] | 10 | #include "base/strings/string16.h" |
[email protected] | 5a991a2 | 2013-09-10 09:22:19 | [diff] [blame] | 11 | #include "ui/views/views_export.h" |
[email protected] | 81fea78 | 2013-07-18 23:58:28 | [diff] [blame] | 12 | |
13 | namespace gfx { | ||||
14 | class ImageSkia; | ||||
15 | } | ||||
16 | |||||
17 | namespace ui { | ||||
18 | class MenuModel; | ||||
19 | } // namespace ui | ||||
20 | |||||
[email protected] | 5a991a2 | 2013-09-10 09:22:19 | [diff] [blame] | 21 | namespace views { |
22 | |||||
[email protected] | 81fea78 | 2013-07-18 23:58:28 | [diff] [blame] | 23 | // 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] | f528059f | 2013-08-28 08:23:59 | [diff] [blame] | 26 | // callbacks to a delegate. For the same reason, do not use StatusIconMenuModel. |
[email protected] | 5a991a2 | 2013-09-10 09:22:19 | [diff] [blame] | 27 | class VIEWS_EXPORT StatusIconLinux { |
[email protected] | 81fea78 | 2013-07-18 23:58:28 | [diff] [blame] | 28 | public: |
29 | class Delegate { | ||||
30 | public: | ||||
31 | virtual void OnClick() = 0; | ||||
[email protected] | b6c510aa | 2013-07-31 23:36:14 | [diff] [blame] | 32 | virtual bool HasClickAction() = 0; |
[email protected] | 81fea78 | 2013-07-18 23:58:28 | [diff] [blame] | 33 | |
Tom Anderson | 9cae289 | 2019-06-12 00:15:19 | [diff] [blame] | 34 | virtual const gfx::ImageSkia& GetImage() const = 0; |
35 | virtual const base::string16& GetToolTip() const = 0; | ||||
Tom Anderson | 1dd5061 | 2019-06-19 01:36:41 | [diff] [blame] | 36 | virtual ui::MenuModel* GetMenuModel() const = 0; |
Tom Anderson | 9cae289 | 2019-06-12 00:15:19 | [diff] [blame] | 37 | |
38 | // This should be called at most once by the implementation. | ||||
Tom Anderson | b137555 | 2019-06-20 20:26:11 | [diff] [blame] | 39 | virtual void OnImplInitializationFailed() = 0; |
Tom Anderson | 9cae289 | 2019-06-12 00:15:19 | [diff] [blame] | 40 | |
[email protected] | 81fea78 | 2013-07-18 23:58:28 | [diff] [blame] | 41 | protected: |
42 | virtual ~Delegate(); | ||||
43 | }; | ||||
44 | |||||
45 | StatusIconLinux(); | ||||
46 | virtual ~StatusIconLinux(); | ||||
47 | |||||
Tom Anderson | b137555 | 2019-06-20 20:26:11 | [diff] [blame] | 48 | virtual void SetIcon(const gfx::ImageSkia& image) = 0; |
[email protected] | 2aadf21 | 2013-12-18 20:03:44 | [diff] [blame] | 49 | virtual void SetToolTip(const base::string16& tool_tip) = 0; |
[email protected] | 81fea78 | 2013-07-18 23:58:28 | [diff] [blame] | 50 | |
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] | f528059f | 2013-08-28 08:23:59 | [diff] [blame] | 56 | // 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 Anderson | b137555 | 2019-06-20 20:26:11 | [diff] [blame] | 61 | virtual void OnSetDelegate(); |
62 | |||||
63 | void SetDelegate(Delegate* delegate); | ||||
64 | |||||
[email protected] | 81fea78 | 2013-07-18 23:58:28 | [diff] [blame] | 65 | Delegate* delegate() { return delegate_; } |
[email protected] | 81fea78 | 2013-07-18 23:58:28 | [diff] [blame] | 66 | |
Tom Anderson | 9cae289 | 2019-06-12 00:15:19 | [diff] [blame] | 67 | protected: |
Robert Liao | e2d8e0c3 | 2019-04-12 20:36:41 | [diff] [blame] | 68 | Delegate* delegate_ = nullptr; |
[email protected] | 81fea78 | 2013-07-18 23:58:28 | [diff] [blame] | 69 | }; |
70 | |||||
[email protected] | 5a991a2 | 2013-09-10 09:22:19 | [diff] [blame] | 71 | } // namespace views |
72 | |||||
Robert Liao | b8ce5f07 | 2019-05-20 17:26:28 | [diff] [blame] | 73 | #endif // UI_VIEWS_LINUX_UI_STATUS_ICON_LINUX_H_ |