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.
5 #ifndef CHROME_BROWSER_UI_LIBGTK2UI_APP_INDICATOR_ICON_H_
6 #define CHROME_BROWSER_UI_LIBGTK2UI_APP_INDICATOR_ICON_H_
8 #include "base/files/file_path.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h"
11 #include "chrome/browser/ui/libgtk2ui/gtk2_signal.h"
12 #include "ui/views/linux_ui/status_icon_linux.h"
14 typedef struct _AppIndicator AppIndicator;
15 typedef struct _GtkWidget GtkWidget;
26 class AppIndicatorIconMenu;
28 // Status icon implementation which uses libappindicator.
29 class AppIndicatorIcon : public views::StatusIconLinux {
31 // The id uniquely identifies the new status icon from other chrome status
33 AppIndicatorIcon(std::string id,
34 const gfx::ImageSkia& image,
35 const base::string16& tool_tip);
36 virtual ~AppIndicatorIcon();
38 // Indicates whether libappindicator so could be opened.
39 static bool CouldOpen();
41 // Overridden from views::StatusIconLinux:
42 virtual void SetImage(const gfx::ImageSkia& image) OVERRIDE;
43 virtual void SetToolTip(const base::string16& tool_tip) OVERRIDE;
44 virtual void UpdatePlatformContextMenu(ui::MenuModel* menu) OVERRIDE;
45 virtual void RefreshPlatformContextMenu() OVERRIDE;
48 void SetImageFromFile(const base::FilePath& icon_file_path);
51 // Sets a menu item at the top of the menu as a replacement for the status
52 // icon click action. Clicking on this menu item should simulate a status icon
53 // click by despatching a click event.
54 void UpdateClickActionReplacementMenuItem();
56 // Callback for when the status icon click replacement menu item is activated.
57 void OnClickActionReplacementMenuItemActivated();
60 std::string tool_tip_;
62 // Whether the user is using KDE.
65 // Gtk status icon wrapper
68 scoped_ptr<AppIndicatorIconMenu> menu_;
69 ui::MenuModel* menu_model_;
71 base::FilePath icon_file_path_;
72 int icon_change_count_;
74 base::WeakPtrFactory<AppIndicatorIcon> weak_factory_;
76 DISALLOW_COPY_AND_ASSIGN(AppIndicatorIcon);
79 } // namespace libgtk2ui
81 #endif // CHROME_BROWSER_UI_LIBGTK2UI_APP_INDICATOR_ICON_H_