Chromium Code Reviews| Index: chrome/browser/ui/views/message_center/tray_watcher_win.h |
| diff --git a/chrome/browser/ui/views/message_center/tray_watcher_win.h b/chrome/browser/ui/views/message_center/tray_watcher_win.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..057c52bf05616bd186431a22017dfdacb5c7c2fa |
| --- /dev/null |
| +++ b/chrome/browser/ui/views/message_center/tray_watcher_win.h |
| @@ -0,0 +1,97 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_UI_VIEWS_MESSAGE_CENTER_TRAY_WATCHER_WIN_H_ |
| +#define CHROME_BROWSER_UI_VIEWS_MESSAGE_CENTER_TRAY_WATCHER_WIN_H_ |
| + |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/strings/string16.h" |
| +#include "base/threading/non_thread_safe.h" |
| +#include "base/win/iunknown_impl.h" |
| +#include "base/win/scoped_comptr.h" |
| + |
| +namespace message_center { |
| + |
| +// The known values for NOTIFYITEM's dwPreference member. |
| +enum NOTIFYITEM_PREFERENCE { |
| + // In Windows UI: "Only show notifications." |
| + PREFERENCE_SHOW_WHEN_ACTIVE = 0x00, |
|
Dmitry Titov
2014/03/18 22:34:13
that leading 0 is mysterious...
dewittj
2014/03/19 18:36:15
Done.
|
| + // In Windows UI: "Hide icon and notifications." |
| + PREFERENCE_SHOW_NEVER = 0x01, |
| + // In Windows UI: "Show icon and notifications." |
| + PREFERENCE_SHOW_ALWAYS = 0x02 |
| +}; |
| + |
| +const DWORD NOTIFYITEM_PREFERENCE_COUNT = 0x03; |
| + |
| +// NOTIFYITEM describes an entry in the taskbar's registry of status icons. |
| +// This structure outlives the process that creates the status item. |
|
Dmitry Titov
2014/03/18 22:34:13
This comment is unclear. This structure or the reg
dewittj
2014/03/19 18:36:15
Done.
|
| +struct NOTIFYITEM { |
| + PWSTR pszExeName; // The file name of the creating executable. |
| + PWSTR pszTip; // The last hover-text value associated with this status item. |
| + HICON hIcon; // The icon associated with this status item. |
| + HWND hWnd; // The HWND associated with the status item. |
| + DWORD dwPreference; // Determines the behavior of the icon with respect to |
| + // the taskbar. Values taken from NOTIFYITEM_PREFERENCE. |
| + UINT uID; // The ID specified by the application. (hWnd, uID) is unique. |
| + GUID guidItem; // The GUID specified by the application, alternative to uID. |
| +}; |
| + |
| +// INotificationCB GUID |
| +[uuid("D782CCBA-AFB0-43F1-94DB-FDA3779EACCB")] interface INotificationCB |
| + : public IUnknown { |
| + STDMETHOD(Notify)(ULONG event, NOTIFYITEM* notify_item) = 0; |
| +}; |
| + |
| +class TrayWatcherWin : public INotificationCB, |
| + public base::win::IUnknownImpl, |
| + public base::NonThreadSafe { |
| + public: |
| + explicit TrayWatcherWin(UINT icon_id, HWND window); |
|
Dmitry Titov
2014/03/18 22:34:13
no need to have 'explicit' with 2 params.
dewittj
2014/03/19 18:36:15
Done.
|
| + |
| + // Creates an instance of TrayNotify, and ensures that it supports either |
|
Dmitry Titov
2014/03/18 22:34:13
The comment and the name of method seem to talk ab
dewittj
2014/03/19 18:36:15
Done.
|
| + // ITrayNotify or ITrayNotifyWin8. Returns true on success. |
| + void EnsureTrayIconVisible(); |
| + |
| + // IUnknown. |
| + STDMETHOD_(ULONG, AddRef)() OVERRIDE; |
| + STDMETHOD_(ULONG, Release)() OVERRIDE; |
| + STDMETHOD(QueryInterface)(REFIID, PVOID*)OVERRIDE; |
| + |
| + // INotificationCB. |
| + STDMETHOD(Notify)(ULONG, NOTIFYITEM*); |
| + |
| + ~TrayWatcherWin(); |
| + |
| + private: |
| + friend class TrayWatcherWinTest; |
| + |
| + enum InterfaceVersion { |
| + INTERFACE_VERSION_LEGACY = 0, |
| + INTERFACE_VERSION_WIN8, |
| + INTERFACE_VERSION_UNKNOWN |
| + }; |
| + |
| + bool CreateTrayNotify(); |
| + scoped_ptr<NOTIFYITEM> RegisterCallback(); |
| + |
| + bool RegisterCallbackWin8(); |
| + bool RegisterCallbackLegacy(); |
| + |
| + void SendNotifyItemUpdate(scoped_ptr<NOTIFYITEM> notify_item); |
| + |
| + scoped_ptr<NOTIFYITEM> notify_item_; |
| + |
| + // Storing IUnknown since we will need to use different interfaces |
| + // for different versions of Windows. |
| + base::win::ScopedComPtr<IUnknown> tray_notify_; |
| + InterfaceVersion interface_version_; |
| + |
| + UINT icon_id_; |
| + HWND window_; |
| + base::string16 file_name_; |
| +}; |
| + |
| +} // namespace message_center |
| +#endif // CHROME_BROWSER_UI_VIEWS_MESSAGE_CENTER_TRAY_WATCHER_WIN_H_ |