| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_UI_VIEWS_STATUS_ICONS_STATUS_TRAY_STATE_CHANGER_WIN_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_STATUS_ICONS_STATUS_TRAY_STATE_CHANGER_WIN_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_STATUS_ICONS_STATUS_TRAY_STATE_CHANGER_WIN_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_STATUS_ICONS_STATUS_TRAY_STATE_CHANGER_WIN_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
| 12 #include "base/threading/non_thread_safe.h" | 12 #include "base/threading/thread_checker.h" |
| 13 #include "base/win/iunknown_impl.h" | 13 #include "base/win/iunknown_impl.h" |
| 14 #include "base/win/scoped_comptr.h" | 14 #include "base/win/scoped_comptr.h" |
| 15 | 15 |
| 16 // The known values for NOTIFYITEM's dwPreference member. | 16 // The known values for NOTIFYITEM's dwPreference member. |
| 17 enum NOTIFYITEM_PREFERENCE { | 17 enum NOTIFYITEM_PREFERENCE { |
| 18 // In Windows UI: "Only show notifications." | 18 // In Windows UI: "Only show notifications." |
| 19 PREFERENCE_SHOW_WHEN_ACTIVE = 0, | 19 PREFERENCE_SHOW_WHEN_ACTIVE = 0, |
| 20 // In Windows UI: "Hide icon and notifications." | 20 // In Windows UI: "Hide icon and notifications." |
| 21 PREFERENCE_SHOW_NEVER = 1, | 21 PREFERENCE_SHOW_NEVER = 1, |
| 22 // In Windows UI: "Show icon and notifications." | 22 // In Windows UI: "Show icon and notifications." |
| (...skipping 23 matching lines...) Expand all Loading... |
| 46 public: | 46 public: |
| 47 virtual HRESULT STDMETHODCALLTYPE | 47 virtual HRESULT STDMETHODCALLTYPE |
| 48 Notify(ULONG event, NOTIFYITEM* notify_item) = 0; | 48 Notify(ULONG event, NOTIFYITEM* notify_item) = 0; |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 // A class that is capable of reading and writing the state of the notification | 51 // A class that is capable of reading and writing the state of the notification |
| 52 // area in the Windows taskbar. It is used to promote a tray icon from the | 52 // area in the Windows taskbar. It is used to promote a tray icon from the |
| 53 // overflow area to the taskbar, and refuses to do anything if the user has | 53 // overflow area to the taskbar, and refuses to do anything if the user has |
| 54 // explicitly marked an icon to be always hidden. | 54 // explicitly marked an icon to be always hidden. |
| 55 class StatusTrayStateChangerWin : public INotificationCB, | 55 class StatusTrayStateChangerWin : public INotificationCB, |
| 56 public base::win::IUnknownImpl, | 56 public base::win::IUnknownImpl { |
| 57 public base::NonThreadSafe { | |
| 58 public: | 57 public: |
| 59 StatusTrayStateChangerWin(UINT icon_id, HWND window); | 58 StatusTrayStateChangerWin(UINT icon_id, HWND window); |
| 60 | 59 |
| 61 // Call this method to move the icon matching |icon_id| and |window| to the | 60 // Call this method to move the icon matching |icon_id| and |window| to the |
| 62 // taskbar from the overflow area. This will not make any changes if the | 61 // taskbar from the overflow area. This will not make any changes if the |
| 63 // icon has been set to |PREFERENCE_SHOW_NEVER|, in order to comply with | 62 // icon has been set to |PREFERENCE_SHOW_NEVER|, in order to comply with |
| 64 // the explicit wishes/configuration of the user. | 63 // the explicit wishes/configuration of the user. |
| 65 void EnsureTrayIconVisible(); | 64 void EnsureTrayIconVisible(); |
| 66 | 65 |
| 67 // IUnknown. | 66 // IUnknown. |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 base::string16 file_name_; | 121 base::string16 file_name_; |
| 123 | 122 |
| 124 // Temporary storage for the matched NOTIFYITEM. This is necessary because | 123 // Temporary storage for the matched NOTIFYITEM. This is necessary because |
| 125 // Notify doesn't return anything. The call flow looks like this: | 124 // Notify doesn't return anything. The call flow looks like this: |
| 126 // TrayNotify->RegisterCallback() | 125 // TrayNotify->RegisterCallback() |
| 127 // ... other COM stack frames .. | 126 // ... other COM stack frames .. |
| 128 // StatusTrayStateChangerWin->Notify(NOTIFYITEM); | 127 // StatusTrayStateChangerWin->Notify(NOTIFYITEM); |
| 129 // so we can't just return the notifyitem we're looking for. | 128 // so we can't just return the notifyitem we're looking for. |
| 130 std::unique_ptr<NOTIFYITEM> notify_item_; | 129 std::unique_ptr<NOTIFYITEM> notify_item_; |
| 131 | 130 |
| 131 THREAD_CHECKER(thread_checker_); |
| 132 |
| 132 DISALLOW_COPY_AND_ASSIGN(StatusTrayStateChangerWin); | 133 DISALLOW_COPY_AND_ASSIGN(StatusTrayStateChangerWin); |
| 133 }; | 134 }; |
| 134 | 135 |
| 135 #endif // CHROME_BROWSER_UI_VIEWS_STATUS_ICONS_STATUS_TRAY_STATE_CHANGER_WIN_H_ | 136 #endif // CHROME_BROWSER_UI_VIEWS_STATUS_ICONS_STATUS_TRAY_STATE_CHANGER_WIN_H_ |
| OLD | NEW |