status_icon_win.h revision ddb351dbec246cf1fab5ec20d2d5520909041de1
1// Copyright (c) 2011 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#pragma once
8
9#include <windows.h>
10#include <shellapi.h>
11
12#include "base/memory/scoped_ptr.h"
13#include "base/win/scoped_gdi_object.h"
14#include "chrome/browser/status_icons/status_icon.h"
15
16namespace views {
17class Menu2;
18}
19
20class StatusIconWin : public StatusIcon {
21 public:
22  // Constructor which provides this icon's unique ID and messaging window.
23  StatusIconWin(UINT id, HWND window, UINT message);
24  virtual ~StatusIconWin();
25
26  // Overridden from StatusIcon:
27  virtual void SetImage(const SkBitmap& image);
28  virtual void SetPressedImage(const SkBitmap& image);
29  virtual void SetToolTip(const string16& tool_tip);
30  virtual void DisplayBalloon(const string16& title, const string16& contents);
31
32  UINT icon_id() const { return icon_id_; }
33
34  UINT message_id() const { return message_id_; }
35
36  // Handles a click event from the user - if |left_button_click| is true and
37  // there is a registered observer, passes the click event to the observer,
38  // otherwise displays the context menu if there is one.
39  void HandleClickEvent(int x, int y, bool left_button_click);
40
41  // Re-creates the status tray icon now after the taskbar has been created.
42  void ResetIcon();
43
44 protected:
45  // Overridden from StatusIcon.
46  virtual void UpdatePlatformContextMenu(ui::MenuModel* menu);
47
48 private:
49  void InitIconData(NOTIFYICONDATA* icon_data);
50
51  // The unique ID corresponding to this icon.
52  UINT icon_id_;
53
54  // Window used for processing messages from this icon.
55  HWND window_;
56
57  // The message identifier used for status icon messages.
58  UINT message_id_;
59
60  // The currently-displayed icon for the window.
61  base::win::ScopedHICON icon_;
62
63  // Context menu associated with this icon (if any).
64  scoped_ptr<views::Menu2> context_menu_;
65
66  DISALLOW_COPY_AND_ASSIGN(StatusIconWin);
67};
68
69#endif  // CHROME_BROWSER_UI_VIEWS_STATUS_ICONS_STATUS_ICON_WIN_H_
70