- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / views / status_icons / status_icon_win.h
1 // Copyright (c) 2012 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_VIEWS_STATUS_ICONS_STATUS_ICON_WIN_H_
6 #define CHROME_BROWSER_UI_VIEWS_STATUS_ICONS_STATUS_ICON_WIN_H_
7
8 #include <windows.h>
9 #include <shellapi.h>
10
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/win/scoped_gdi_object.h"
15 #include "chrome/browser/status_icons/status_icon.h"
16
17 namespace gfx {
18 class Point;
19 }
20
21 namespace views {
22 class MenuRunner;
23 }
24
25 class StatusIconWin : public StatusIcon {
26  public:
27   // Constructor which provides this icon's unique ID and messaging window.
28   StatusIconWin(UINT id, HWND window, UINT message);
29   virtual ~StatusIconWin();
30
31   // Handles a click event from the user - if |left_button_click| is true and
32   // there is a registered observer, passes the click event to the observer,
33   // otherwise displays the context menu if there is one.
34   void HandleClickEvent(const gfx::Point& cursor_pos, bool left_button_click);
35
36   // Handles a click on the balloon from the user.
37   void HandleBalloonClickEvent();
38
39   // Re-creates the status tray icon now after the taskbar has been created.
40   void ResetIcon();
41
42   UINT icon_id() const { return icon_id_; }
43   UINT message_id() const { return message_id_; }
44
45   // Overridden from StatusIcon:
46   virtual void SetImage(const gfx::ImageSkia& image) OVERRIDE;
47   virtual void SetPressedImage(const gfx::ImageSkia& image) OVERRIDE;
48   virtual void SetToolTip(const string16& tool_tip) OVERRIDE;
49   virtual void DisplayBalloon(const gfx::ImageSkia& icon,
50                               const string16& title,
51                               const string16& contents) OVERRIDE;
52
53  protected:
54   // Overridden from StatusIcon:
55   virtual void UpdatePlatformContextMenu(
56       StatusIconMenuModel* menu) OVERRIDE;
57
58  private:
59   void InitIconData(NOTIFYICONDATA* icon_data);
60
61   // The unique ID corresponding to this icon.
62   UINT icon_id_;
63
64   // Window used for processing messages from this icon.
65   HWND window_;
66
67   // The message identifier used for status icon messages.
68   UINT message_id_;
69
70   // The currently-displayed icon for the window.
71   base::win::ScopedHICON icon_;
72
73   // The currently-displayed icon for the notification balloon.
74   base::win::ScopedHICON balloon_icon_;
75
76   // Not owned.
77   ui::MenuModel* menu_model_;
78
79   // Context menu associated with this icon (if any).
80   scoped_ptr<views::MenuRunner> menu_runner_;
81
82   DISALLOW_COPY_AND_ASSIGN(StatusIconWin);
83 };
84
85 // Implements status notifications using Windows 8 metro style notifications.
86 class StatusIconMetro : public StatusIcon {
87  public:
88   // Constructor which provides this icon's unique ID and messaging window.
89   explicit StatusIconMetro(UINT id);
90   virtual ~StatusIconMetro();
91
92   // Overridden from StatusIcon:
93   virtual void SetImage(const gfx::ImageSkia& image) OVERRIDE;
94   virtual void SetPressedImage(const gfx::ImageSkia& image) OVERRIDE;
95   virtual void SetToolTip(const string16& tool_tip) OVERRIDE;
96   virtual void DisplayBalloon(const gfx::ImageSkia& icon,
97                               const string16& title,
98                               const string16& contents) OVERRIDE;
99  protected:
100   virtual void UpdatePlatformContextMenu(
101       StatusIconMenuModel* menu) OVERRIDE;
102
103  private:
104   string16 tool_tip_;
105   const UINT id_;
106
107   DISALLOW_COPY_AND_ASSIGN(StatusIconMetro);
108 };
109
110 #endif  // CHROME_BROWSER_UI_VIEWS_STATUS_ICONS_STATUS_ICON_WIN_H_