status_icon_win.h revision eb525c5499e34cc9c4b825d6d9e75bb07cc06ace
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 17namespace gfx { 18class Point; 19} 20 21namespace views { 22class MenuRunner; 23} 24 25class 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(ui::MenuModel* menu) OVERRIDE; 56 57 private: 58 void InitIconData(NOTIFYICONDATA* icon_data); 59 60 // The unique ID corresponding to this icon. 61 UINT icon_id_; 62 63 // Window used for processing messages from this icon. 64 HWND window_; 65 66 // The message identifier used for status icon messages. 67 UINT message_id_; 68 69 // The currently-displayed icon for the window. 70 base::win::ScopedHICON icon_; 71 72 // The currently-displayed icon for the notification balloon. 73 base::win::ScopedHICON balloon_icon_; 74 75 // Not owned. 76 ui::MenuModel* menu_model_; 77 78 // Context menu associated with this icon (if any). 79 scoped_ptr<views::MenuRunner> menu_runner_; 80 81 DISALLOW_COPY_AND_ASSIGN(StatusIconWin); 82}; 83 84// Implements status notifications using Windows 8 metro style notifications. 85class StatusIconMetro : public StatusIcon { 86 public: 87 // Constructor which provides this icon's unique ID and messaging window. 88 explicit StatusIconMetro(UINT id); 89 virtual ~StatusIconMetro(); 90 91 // Overridden from StatusIcon: 92 virtual void SetImage(const gfx::ImageSkia& image) OVERRIDE; 93 virtual void SetPressedImage(const gfx::ImageSkia& image) OVERRIDE; 94 virtual void SetToolTip(const string16& tool_tip) OVERRIDE; 95 virtual void DisplayBalloon(const gfx::ImageSkia& icon, 96 const string16& title, 97 const string16& contents) OVERRIDE; 98 protected: 99 virtual void UpdatePlatformContextMenu(ui::MenuModel* menu) OVERRIDE; 100 101 private: 102 string16 tool_tip_; 103 const UINT id_; 104 105 DISALLOW_COPY_AND_ASSIGN(StatusIconMetro); 106}; 107 108#endif // CHROME_BROWSER_UI_VIEWS_STATUS_ICONS_STATUS_ICON_WIN_H_ 109