Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / libgtk2ui / app_indicator_icon.h
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
5 #ifndef CHROME_BROWSER_UI_LIBGTK2UI_APP_INDICATOR_ICON_H_
6 #define CHROME_BROWSER_UI_LIBGTK2UI_APP_INDICATOR_ICON_H_
7
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"
13
14 typedef struct _AppIndicator AppIndicator;
15 typedef struct _GtkWidget GtkWidget;
16
17 namespace gfx {
18 class ImageSkia;
19 }
20
21 namespace ui {
22 class MenuModel;
23 }
24
25 namespace libgtk2ui {
26 class AppIndicatorIconMenu;
27
28 // Status icon implementation which uses libappindicator.
29 class AppIndicatorIcon : public views::StatusIconLinux {
30  public:
31   // The id uniquely identifies the new status icon from other chrome status
32   // icons.
33   AppIndicatorIcon(std::string id,
34                    const gfx::ImageSkia& image,
35                    const base::string16& tool_tip);
36   ~AppIndicatorIcon() override;
37
38   // Indicates whether libappindicator so could be opened.
39   static bool CouldOpen();
40
41   // Overridden from views::StatusIconLinux:
42   void SetImage(const gfx::ImageSkia& image) override;
43   void SetToolTip(const base::string16& tool_tip) override;
44   void UpdatePlatformContextMenu(ui::MenuModel* menu) override;
45   void RefreshPlatformContextMenu() override;
46
47  private:
48   void SetImageFromFile(const base::FilePath& icon_file_path);
49   void SetMenu();
50
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();
55
56   // Callback for when the status icon click replacement menu item is activated.
57   void OnClickActionReplacementMenuItemActivated();
58
59   std::string id_;
60   std::string tool_tip_;
61
62   // Whether the user is using KDE.
63   bool using_kde4_;
64
65   // Gtk status icon wrapper
66   AppIndicator* icon_;
67
68   scoped_ptr<AppIndicatorIconMenu> menu_;
69   ui::MenuModel* menu_model_;
70
71   base::FilePath icon_file_path_;
72   int icon_change_count_;
73
74   base::WeakPtrFactory<AppIndicatorIcon> weak_factory_;
75
76   DISALLOW_COPY_AND_ASSIGN(AppIndicatorIcon);
77 };
78
79 }  // namespace libgtk2ui
80
81 #endif  // CHROME_BROWSER_UI_LIBGTK2UI_APP_INDICATOR_ICON_H_