Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4978)

Unified Diff: chrome/browser/ui/views/message_center/tray_watcher_win.h

Issue 110693004: Moves the notification icon out of the status area overflow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..3548cff84eede0f387cdcef645cb2f9f13dde103
--- /dev/null
+++ b/chrome/browser/ui/views/message_center/tray_watcher_win.h
@@ -0,0 +1,111 @@
+// 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 = 0,
+ // In Windows UI: "Hide icon and notifications."
+ PREFERENCE_SHOW_NEVER = 1,
+ // In Windows UI: "Show icon and notifications."
+ PREFERENCE_SHOW_ALWAYS = 2
+};
+
+// NOTIFYITEM describes an entry in Explorer's registry of status icons.
+// Explorer keeps entries around for a process even after it exits.
+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,
sky 2014/03/19 22:26:39 Add a description.
dewittj 2014/03/20 19:31:08 Done.
+ public base::win::IUnknownImpl,
+ public base::NonThreadSafe {
+ public:
+ TrayWatcherWin(UINT icon_id, HWND window);
+
+ // Call this method to move the icon matching |icon_id| and |window| to the
+ // taskbar from the overflow area. This will not make any changes if the
+ // icon has been set to |PREFERENCE_SHOW_NEVER|, in order to comply with
+ // the explicit wishes/configuration of the user.
+ void EnsureTrayIconVisible();
+
+ // IUnknown.
+ STDMETHOD_(ULONG, AddRef)() OVERRIDE;
+ STDMETHOD_(ULONG, Release)() OVERRIDE;
+ STDMETHOD(QueryInterface)(REFIID, PVOID*)OVERRIDE;
+
+ // INotificationCB.
+ // Notify is called in response to RegisterCallback for each current
+ // entry in Explorer's list of notification area icons, and ever time
+ // one of them changes, until UnregisterCallback is called or |this|
+ // is destroyed.
+ STDMETHOD(Notify)(ULONG, NOTIFYITEM*);
+
+ ~TrayWatcherWin();
sky 2014/03/19 22:26:39 destructor should be beneath constructor and virtu
dewittj 2014/03/20 19:31:08 Done.
+
+ private:
+ friend class TrayWatcherWinTest;
+
+ enum InterfaceVersion {
+ INTERFACE_VERSION_LEGACY = 0,
+ INTERFACE_VERSION_WIN8,
+ INTERFACE_VERSION_UNKNOWN
+ };
+
+ // Creates an instance of TrayNotify, and ensures that it supports either
+ // ITrayNotify or ITrayNotifyWin8. Returns true on success.
+ bool CreateTrayNotify();
+
+ // Returns the NOTIFYITEM that corresponds to this executable and the
+ // HWND/ID pair that were used to create the TrayWatcherWin. Internally
+ // it calls the appropriate RegisterCallback{Win8,Legacy}.
+ scoped_ptr<NOTIFYITEM> RegisterCallback();
+
+ // Calls RegisterCallback with the appropriate interface required by
+ // different versions of Windows. This will result in |notify_item_| being
+ // updated when a matching item is passed into TrayWatcherWin::Notify.
+ bool RegisterCallbackWin8();
+ bool RegisterCallbackLegacy();
+
+ // Sends an update to Explorer with the passed NOTIFYITEM.
+ 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_;
sky 2014/03/19 22:26:39 descriptions for these, and make const if you can.
dewittj 2014/03/20 19:31:08 Done.
+ HWND window_;
+ base::string16 file_name_;
+};
sky 2014/03/19 22:26:39 DISALLOW...
dewittj 2014/03/20 19:31:08 Done.
+
+} // namespace message_center
+#endif // CHROME_BROWSER_UI_VIEWS_MESSAGE_CENTER_TRAY_WATCHER_WIN_H_

Powered by Google App Engine
This is Rietveld 408576698