blob: 6bfa71ac022105ea6e7f8779dfffcf15bc9e1b93 [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
8#include "base/strings/string16.h"
[email protected]5a991a22013-09-10 09:22:199#include "ui/views/views_export.h"
[email protected]81fea782013-07-18 23:58:2810
11namespace gfx {
12class ImageSkia;
13}
14
15namespace ui {
16class MenuModel;
17} // namespace ui
18
[email protected]5a991a22013-09-10 09:22:1919namespace views {
20
[email protected]81fea782013-07-18 23:58:2821// 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]f528059f2013-08-28 08:23:5924// callbacks to a delegate. For the same reason, do not use StatusIconMenuModel.
[email protected]5a991a22013-09-10 09:22:1925class VIEWS_EXPORT StatusIconLinux {
[email protected]81fea782013-07-18 23:58:2826 public:
27 class Delegate {
28 public:
29 virtual void OnClick() = 0;
[email protected]b6c510aa2013-07-31 23:36:1430 virtual bool HasClickAction() = 0;
[email protected]81fea782013-07-18 23:58:2831
Tom Anderson9cae2892019-06-12 00:15:1932 virtual const gfx::ImageSkia& GetImage() const = 0;
33 virtual const base::string16& GetToolTip() const = 0;
Tom Anderson1dd50612019-06-19 01:36:4134 virtual ui::MenuModel* GetMenuModel() const = 0;
Tom Anderson9cae2892019-06-12 00:15:1935
36 // This should be called at most once by the implementation.
Tom Andersonb1375552019-06-20 20:26:1137 virtual void OnImplInitializationFailed() = 0;
Tom Anderson9cae2892019-06-12 00:15:1938
[email protected]81fea782013-07-18 23:58:2839 protected:
40 virtual ~Delegate();
41 };
42
43 StatusIconLinux();
44 virtual ~StatusIconLinux();
45
Tom Andersonb1375552019-06-20 20:26:1146 virtual void SetIcon(const gfx::ImageSkia& image) = 0;
[email protected]2aadf212013-12-18 20:03:4447 virtual void SetToolTip(const base::string16& tool_tip) = 0;
[email protected]81fea782013-07-18 23:58:2848
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]f528059f2013-08-28 08:23:5954 // 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 Andersonb1375552019-06-20 20:26:1159 virtual void OnSetDelegate();
60
61 void SetDelegate(Delegate* delegate);
62
[email protected]81fea782013-07-18 23:58:2863 Delegate* delegate() { return delegate_; }
[email protected]81fea782013-07-18 23:58:2864
Tom Anderson9cae2892019-06-12 00:15:1965 protected:
Robert Liaoe2d8e0c32019-04-12 20:36:4166 Delegate* delegate_ = nullptr;
[email protected]81fea782013-07-18 23:58:2867};
68
[email protected]5a991a22013-09-10 09:22:1969} // namespace views
70
Robert Liaob8ce5f072019-05-20 17:26:2871#endif // UI_VIEWS_LINUX_UI_STATUS_ICON_LINUX_H_