[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 | |
8 | #include "base/strings/string16.h" | ||||
[email protected] | 5a991a2 | 2013-09-10 09:22:19 | [diff] [blame] | 9 | #include "ui/views/views_export.h" |
[email protected] | 81fea78 | 2013-07-18 23:58:28 | [diff] [blame] | 10 | |
11 | namespace gfx { | ||||
12 | class ImageSkia; | ||||
13 | } | ||||
14 | |||||
15 | namespace ui { | ||||
16 | class MenuModel; | ||||
17 | } // namespace ui | ||||
18 | |||||
[email protected] | 5a991a2 | 2013-09-10 09:22:19 | [diff] [blame] | 19 | namespace views { |
20 | |||||
[email protected] | 81fea78 | 2013-07-18 23:58:28 | [diff] [blame] | 21 | // Since liblinux_ui cannot have dependencies on any chrome browser components |
22 | // we cannot inherit from StatusIcon. So we implement the necessary methods | ||||
23 | // and let a wrapper class implement the StatusIcon interface and defer the | ||||
[email protected] | f528059f | 2013-08-28 08:23:59 | [diff] [blame] | 24 | // callbacks to a delegate. For the same reason, do not use StatusIconMenuModel. |
[email protected] | 5a991a2 | 2013-09-10 09:22:19 | [diff] [blame] | 25 | class VIEWS_EXPORT StatusIconLinux { |
[email protected] | 81fea78 | 2013-07-18 23:58:28 | [diff] [blame] | 26 | public: |
27 | class Delegate { | ||||
28 | public: | ||||
29 | virtual void OnClick() = 0; | ||||
[email protected] | b6c510aa | 2013-07-31 23:36:14 | [diff] [blame] | 30 | virtual bool HasClickAction() = 0; |
[email protected] | 81fea78 | 2013-07-18 23:58:28 | [diff] [blame] | 31 | |
Tom Anderson | 9cae289 | 2019-06-12 00:15:19 | [diff] [blame] | 32 | virtual const gfx::ImageSkia& GetImage() const = 0; |
33 | virtual const base::string16& GetToolTip() const = 0; | ||||
Tom Anderson | 1dd5061 | 2019-06-19 01:36:41 | [diff] [blame] | 34 | virtual ui::MenuModel* GetMenuModel() const = 0; |
Tom Anderson | 9cae289 | 2019-06-12 00:15:19 | [diff] [blame] | 35 | |
36 | // This should be called at most once by the implementation. | ||||
Tom Anderson | b137555 | 2019-06-20 20:26:11 | [diff] [blame^] | 37 | virtual void OnImplInitializationFailed() = 0; |
Tom Anderson | 9cae289 | 2019-06-12 00:15:19 | [diff] [blame] | 38 | |
[email protected] | 81fea78 | 2013-07-18 23:58:28 | [diff] [blame] | 39 | protected: |
40 | virtual ~Delegate(); | ||||
41 | }; | ||||
42 | |||||
43 | StatusIconLinux(); | ||||
44 | virtual ~StatusIconLinux(); | ||||
45 | |||||
Tom Anderson | b137555 | 2019-06-20 20:26:11 | [diff] [blame^] | 46 | virtual void SetIcon(const gfx::ImageSkia& image) = 0; |
[email protected] | 2aadf21 | 2013-12-18 20:03:44 | [diff] [blame] | 47 | virtual void SetToolTip(const base::string16& tool_tip) = 0; |
[email protected] | 81fea78 | 2013-07-18 23:58:28 | [diff] [blame] | 48 | |
49 | // Invoked after a call to SetContextMenu() to let the platform-specific | ||||
50 | // subclass update the native context menu based on the new model. The | ||||
51 | // subclass should destroy the existing native context menu on this call. | ||||
52 | virtual void UpdatePlatformContextMenu(ui::MenuModel* model) = 0; | ||||
53 | |||||
[email protected] | f528059f | 2013-08-28 08:23:59 | [diff] [blame] | 54 | // Update all the enabled/checked states and the dynamic labels. Some status |
55 | // icon implementations do not refresh the native menu before showing so we | ||||
56 | // need to manually refresh it when the menu model changes. | ||||
57 | virtual void RefreshPlatformContextMenu(); | ||||
58 | |||||
Tom Anderson | b137555 | 2019-06-20 20:26:11 | [diff] [blame^] | 59 | virtual void OnSetDelegate(); |
60 | |||||
61 | void SetDelegate(Delegate* delegate); | ||||
62 | |||||
[email protected] | 81fea78 | 2013-07-18 23:58:28 | [diff] [blame] | 63 | Delegate* delegate() { return delegate_; } |
[email protected] | 81fea78 | 2013-07-18 23:58:28 | [diff] [blame] | 64 | |
Tom Anderson | 9cae289 | 2019-06-12 00:15:19 | [diff] [blame] | 65 | protected: |
Robert Liao | e2d8e0c3 | 2019-04-12 20:36:41 | [diff] [blame] | 66 | Delegate* delegate_ = nullptr; |
[email protected] | 81fea78 | 2013-07-18 23:58:28 | [diff] [blame] | 67 | }; |
68 | |||||
[email protected] | 5a991a2 | 2013-09-10 09:22:19 | [diff] [blame] | 69 | } // namespace views |
70 | |||||
Robert Liao | b8ce5f07 | 2019-05-20 17:26:28 | [diff] [blame] | 71 | #endif // UI_VIEWS_LINUX_UI_STATUS_ICON_LINUX_H_ |