| 
									
										
										
										
											2015-08-02 11:11:29 +08:00
										 |  |  | // Copyright (c) 2015 GitHub, Inc.
 | 
					
						
							|  |  |  | // Use of this source code is governed by the MIT license that can be
 | 
					
						
							|  |  |  | // found in the LICENSE file.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-22 08:34:31 +01:00
										 |  |  | #ifndef ELECTRON_SHELL_BROWSER_UI_WIN_TASKBAR_HOST_H_
 | 
					
						
							|  |  |  | #define ELECTRON_SHELL_BROWSER_UI_WIN_TASKBAR_HOST_H_
 | 
					
						
							| 
									
										
										
										
											2015-08-02 11:11:29 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-06 12:58:40 +08:00
										 |  |  | #include <shobjidl.h>
 | 
					
						
							| 
									
										
										
										
											2018-04-18 19:20:15 +02:00
										 |  |  | #include <wrl/client.h>
 | 
					
						
							| 
									
										
										
										
											2015-08-02 11:11:29 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include <map>
 | 
					
						
							| 
									
										
										
										
											2015-08-06 12:44:07 +08:00
										 |  |  | #include <string>
 | 
					
						
							| 
									
										
										
										
											2015-08-02 11:11:29 +08:00
										 |  |  | #include <vector>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-03 12:43:42 +01:00
										 |  |  | #include "base/functional/callback.h"
 | 
					
						
							| 
									
										
										
										
											2019-06-19 13:46:59 -07:00
										 |  |  | #include "shell/browser/native_window.h"
 | 
					
						
							| 
									
										
										
										
											2016-07-14 13:27:16 -07:00
										 |  |  | #include "ui/gfx/geometry/rect.h"
 | 
					
						
							| 
									
										
										
										
											2015-08-06 11:10:34 +08:00
										 |  |  | #include "ui/gfx/image/image.h"
 | 
					
						
							| 
									
										
										
										
											2015-08-02 11:11:29 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace electron { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-06 10:30:22 +08:00
										 |  |  | class TaskbarHost { | 
					
						
							| 
									
										
										
										
											2015-08-02 11:11:29 +08:00
										 |  |  |  public: | 
					
						
							| 
									
										
										
										
											2015-08-06 11:10:34 +08:00
										 |  |  |   struct ThumbarButton { | 
					
						
							|  |  |  |     std::string tooltip; | 
					
						
							|  |  |  |     gfx::Image icon; | 
					
						
							|  |  |  |     std::vector<std::string> flags; | 
					
						
							| 
									
										
										
										
											2021-05-06 15:01:04 -07:00
										 |  |  |     base::RepeatingClosure clicked_callback; | 
					
						
							| 
									
										
										
										
											2018-06-25 22:30:00 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ThumbarButton(); | 
					
						
							|  |  |  |     ThumbarButton(const ThumbarButton&); | 
					
						
							|  |  |  |     ~ThumbarButton(); | 
					
						
							| 
									
										
										
										
											2015-08-06 11:10:34 +08:00
										 |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   TaskbarHost(); | 
					
						
							|  |  |  |   virtual ~TaskbarHost(); | 
					
						
							| 
									
										
										
										
											2015-08-02 11:11:29 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-03 12:41:45 +01:00
										 |  |  |   // disable copy
 | 
					
						
							|  |  |  |   TaskbarHost(const TaskbarHost&) = delete; | 
					
						
							|  |  |  |   TaskbarHost& operator=(const TaskbarHost&) = delete; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-06 12:54:00 +08:00
										 |  |  |   // Add or update the buttons in thumbar.
 | 
					
						
							| 
									
										
										
										
											2018-04-17 21:44:10 -04:00
										 |  |  |   bool SetThumbarButtons(HWND window, | 
					
						
							|  |  |  |                          const std::vector<ThumbarButton>& buttons); | 
					
						
							| 
									
										
										
										
											2015-08-06 12:44:07 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-13 01:55:42 +10:00
										 |  |  |   void RestoreThumbarButtons(HWND window); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-06 13:07:00 +08:00
										 |  |  |   // Set the progress state in taskbar.
 | 
					
						
							| 
									
										
										
										
											2018-04-17 21:44:10 -04:00
										 |  |  |   bool SetProgressBar(HWND window, | 
					
						
							|  |  |  |                       double value, | 
					
						
							|  |  |  |                       const NativeWindow::ProgressState state); | 
					
						
							| 
									
										
										
										
											2015-08-06 12:54:00 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-06 13:07:00 +08:00
										 |  |  |   // Set the overlay icon in taskbar.
 | 
					
						
							| 
									
										
										
										
											2018-04-17 21:44:10 -04:00
										 |  |  |   bool SetOverlayIcon(HWND window, | 
					
						
							| 
									
										
										
										
											2024-03-19 12:50:30 +01:00
										 |  |  |                       const SkBitmap& bitmap, | 
					
						
							| 
									
										
										
										
											2018-04-17 21:44:10 -04:00
										 |  |  |                       const std::string& text); | 
					
						
							| 
									
										
										
										
											2015-08-06 13:07:00 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-14 13:27:16 -07:00
										 |  |  |   // Set the region of the window to show as a thumbnail in taskbar.
 | 
					
						
							| 
									
										
										
										
											2016-08-07 19:23:42 +02:00
										 |  |  |   bool SetThumbnailClip(HWND window, const gfx::Rect& region); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // Set the tooltip for the thumbnail in taskbar.
 | 
					
						
							|  |  |  |   bool SetThumbnailToolTip(HWND window, const std::string& tooltip); | 
					
						
							| 
									
										
										
										
											2016-07-14 13:27:16 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-06 12:44:07 +08:00
										 |  |  |   // Called by the window that there is a button in thumbar clicked.
 | 
					
						
							| 
									
										
										
										
											2015-08-02 11:11:29 +08:00
										 |  |  |   bool HandleThumbarButtonEvent(int button_id); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-25 11:02:47 +00:00
										 |  |  |   void SetThumbarButtonsAdded(bool added) { thumbar_buttons_added_ = added; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-02 11:11:29 +08:00
										 |  |  |  private: | 
					
						
							| 
									
										
										
										
											2016-06-09 12:21:21 +07:00
										 |  |  |   // Initialize the taskbar object.
 | 
					
						
							|  |  |  |   bool InitializeTaskbar(); | 
					
						
							| 
									
										
										
										
											2015-08-06 12:58:40 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-06 15:01:04 -07:00
										 |  |  |   using CallbackMap = std::map<int, base::RepeatingClosure>; | 
					
						
							| 
									
										
										
										
											2015-08-06 12:44:07 +08:00
										 |  |  |   CallbackMap callback_map_; | 
					
						
							| 
									
										
										
										
											2015-08-02 11:11:29 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-13 01:55:42 +10:00
										 |  |  |   std::vector<ThumbarButton> last_buttons_; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-06 12:58:40 +08:00
										 |  |  |   // The COM object of taskbar.
 | 
					
						
							| 
									
										
										
										
											2018-04-18 19:20:15 +02:00
										 |  |  |   Microsoft::WRL::ComPtr<ITaskbarList3> taskbar_; | 
					
						
							| 
									
										
										
										
											2015-08-06 12:58:40 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-06 12:44:07 +08:00
										 |  |  |   // Whether we have already added the buttons to thumbar.
 | 
					
						
							| 
									
										
										
										
											2018-05-22 00:18:38 +02:00
										 |  |  |   bool thumbar_buttons_added_ = false; | 
					
						
							| 
									
										
										
										
											2015-08-02 11:11:29 +08:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | }  // namespace electron
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-22 08:34:31 +01:00
										 |  |  | #endif  // ELECTRON_SHELL_BROWSER_UI_WIN_TASKBAR_HOST_H_
 |