[Metrics] Make MetricsStateManager take a callback param to check if UMA is enabled.
[chromium-blink-merge.git] / chrome / browser / ui / views / status_icons / status_tray_win.h
blob08a05e85c6b18062eea12770b715b520347ae2c6
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.
5 #ifndef CHROME_BROWSER_UI_VIEWS_STATUS_ICONS_STATUS_TRAY_WIN_H_
6 #define CHROME_BROWSER_UI_VIEWS_STATUS_ICONS_STATUS_TRAY_WIN_H_
8 #include <windows.h>
10 #include "base/compiler_specific.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "chrome/browser/status_icons/status_tray.h"
14 class StatusIconWin;
16 // A class that's responsible for increasing, if possible, the visibility
17 // of a status tray icon on the taskbar. The default implementation sends
18 // a task to a worker thread each time EnqueueChange is called.
19 class StatusTrayStateChangerProxy {
20 public:
21 // Called by StatusTrayWin to request upgraded visibility on the icon
22 // represented by the |icon_id|, |window| pair.
23 virtual void EnqueueChange(UINT icon_id, HWND window) = 0;
26 class StatusTrayWin : public StatusTray {
27 public:
28 StatusTrayWin();
29 ~StatusTrayWin();
31 void UpdateIconVisibilityInBackground(StatusIconWin* status_icon);
33 // Exposed for testing.
34 LRESULT CALLBACK
35 WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
37 protected:
38 // Overriden from StatusTray:
39 virtual StatusIcon* CreatePlatformStatusIcon(StatusIconType type,
40 const gfx::ImageSkia& image,
41 const base::string16& tool_tip)
42 OVERRIDE;
44 private:
45 FRIEND_TEST_ALL_PREFIXES(StatusTrayWinTest, EnsureVisibleTest);
47 // Static callback invoked when a message comes in to our messaging window.
48 static LRESULT CALLBACK
49 WndProcStatic(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
51 UINT NextIconId();
53 void SetStatusTrayStateChangerProxyForTest(
54 scoped_ptr<StatusTrayStateChangerProxy> proxy);
56 // The unique icon ID we will assign to the next icon.
57 UINT next_icon_id_;
59 // The window class of |window_|.
60 ATOM atom_;
62 // The handle of the module that contains the window procedure of |window_|.
63 HMODULE instance_;
65 // The window used for processing events.
66 HWND window_;
68 // The message ID of the "TaskbarCreated" message, sent to us when we need to
69 // reset our status icons.
70 UINT taskbar_created_message_;
72 // Manages changes performed on a background thread to manipulate visibility
73 // of notification icons.
74 scoped_ptr<StatusTrayStateChangerProxy> state_changer_proxy_;
76 DISALLOW_COPY_AND_ASSIGN(StatusTrayWin);
79 #endif // CHROME_BROWSER_UI_VIEWS_STATUS_ICONS_STATUS_TRAY_WIN_H_