2016-08-12 16:31:17 +07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								// Copyright (c) 2016 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_JUMP_LIST_H_
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#define ELECTRON_SHELL_BROWSER_UI_WIN_JUMP_LIST_H_
							 | 
						
					
						
							
								
									
										
										
										
											2016-08-12 16:31:17 +07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#include <atlbase.h>
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#include <shobjidl.h>
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#include <vector>
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#include "base/files/file_path.h"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								namespace electron {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								enum class JumpListResult : int {
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-27 18:51:45 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  kSuccess = 0,
							 | 
						
					
						
							
								
									
										
										
										
											2016-08-12 16:31:17 +07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  // In JS code this error will manifest as an exception.
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-27 18:51:45 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  kArgumentError = 1,
							 | 
						
					
						
							
								
									
										
										
										
											2016-08-12 16:31:17 +07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  // Generic error, the runtime logs may provide some clues.
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-27 18:51:45 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  kGenericError = 2,
							 | 
						
					
						
							
								
									
										
										
										
											2016-08-12 16:31:17 +07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  // Custom categories can't contain separators.
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-27 18:51:45 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  kCustomCategorySeparatorError = 3,
							 | 
						
					
						
							
								
									
										
										
										
											2016-08-12 16:31:17 +07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  // The app isn't registered to handle a file type found in a custom category.
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-27 18:51:45 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  kMissingFileTypeRegistrationError = 4,
							 | 
						
					
						
							
								
									
										
										
										
											2016-08-12 16:31:17 +07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  // Custom categories can't be created due to user privacy settings.
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-27 18:51:45 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  kCustomCategoryAccessDeniedError = 5,
							 | 
						
					
						
							
								
									
										
										
										
											2016-08-12 16:31:17 +07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								};
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								struct JumpListItem {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  enum class Type {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // A task will launch an app (usually the one that created the Jump List)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // with specific arguments.
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-27 18:51:45 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    kTask,
							 | 
						
					
						
							
								
									
										
										
										
											2016-08-12 16:31:17 +07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // Separators can only be inserted between items in the standard Tasks
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // category, they can't appear in custom categories.
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-27 18:51:45 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    kSeparator,
							 | 
						
					
						
							
								
									
										
										
										
											2016-08-12 16:31:17 +07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // A file link will open a file using the app that created the Jump List,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // for this to work the app must be registered as a handler for the file
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // type (though the app doesn't have to be the default handler).
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-27 18:51:45 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    kFile
							 | 
						
					
						
							
								
									
										
										
										
											2016-08-12 16:31:17 +07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  };
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-27 18:51:45 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  Type type = Type::kTask;
							 | 
						
					
						
							
								
									
										
										
										
											2016-08-12 16:31:17 +07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  // For tasks this is the path to the program executable, for file links this
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  // is the full filename.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  base::FilePath path;
							 | 
						
					
						
							
								
									
										
										
										
											2021-03-18 15:55:51 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  std::wstring arguments;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  std::wstring title;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  std::wstring description;
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-13 18:17:12 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  base::FilePath working_dir;
							 | 
						
					
						
							
								
									
										
										
										
											2016-08-12 16:31:17 +07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  base::FilePath icon_path;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  int icon_index = 0;
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-25 22:30:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  JumpListItem();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  JumpListItem(const JumpListItem&);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  ~JumpListItem();
							 | 
						
					
						
							
								
									
										
										
										
											2016-08-12 16:31:17 +07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								};
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								struct JumpListCategory {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  enum class Type {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // A custom category can contain tasks and files, but not separators.
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-27 18:51:45 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    kCustom,
							 | 
						
					
						
							
								
									
										
										
										
											2016-08-12 16:31:17 +07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // Frequent/Recent categories are managed by the OS, their name and items
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // can't be set by the app (though items can be set indirectly).
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-27 18:51:45 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    kFrequent,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    kRecent,
							 | 
						
					
						
							
								
									
										
										
										
											2016-08-12 16:31:17 +07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // The standard Tasks category can't be renamed by the app, but the app
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // can set the items that should appear in this category, and those items
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // can include tasks, files, and separators.
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-27 18:51:45 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    kTasks
							 | 
						
					
						
							
								
									
										
										
										
											2016-08-12 16:31:17 +07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  };
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-27 18:51:45 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  Type type = Type::kTasks;
							 | 
						
					
						
							
								
									
										
										
										
											2021-03-18 15:55:51 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  std::wstring name;
							 | 
						
					
						
							
								
									
										
										
										
											2016-08-12 16:31:17 +07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  std::vector<JumpListItem> items;
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-25 22:30:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  JumpListCategory();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  JumpListCategory(const JumpListCategory&);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  ~JumpListCategory();
							 | 
						
					
						
							
								
									
										
										
										
											2016-08-12 16:31:17 +07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								};
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								// Creates or removes a custom Jump List for an app.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								// See https://msdn.microsoft.com/en-us/library/windows/desktop/gg281362.aspx
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								class JumpList {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 public:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  // |app_id| must be the Application User Model ID of the app for which the
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  // custom Jump List should be created/removed, it's usually obtained by
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  // calling GetCurrentProcessExplicitAppUserModelID().
							 | 
						
					
						
							
								
									
										
										
										
											2021-03-18 15:55:51 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  explicit JumpList(const std::wstring& app_id);
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-25 22:30:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  ~JumpList();
							 | 
						
					
						
							
								
									
										
										
										
											2016-08-12 16:31:17 +07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-03 12:41:45 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  // disable copy
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  JumpList(const JumpList&) = delete;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  JumpList& operator=(const JumpList&) = delete;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-08-12 16:31:17 +07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  // Starts a new transaction, must be called before appending any categories,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  // aborting or committing. After the method returns |min_items| will indicate
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  // the minimum number of items that will be displayed in the Jump List, and
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  // |removed_items| (if not null) will contain all the items the user has
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  // unpinned from the Jump List. Both parameters are optional.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  bool Begin(int* min_items = nullptr,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								             std::vector<JumpListItem>* removed_items = nullptr);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  // Abandons any changes queued up since Begin() was called.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  bool Abort();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  // Commits any changes queued up since Begin() was called.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  bool Commit();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  // Deletes the custom Jump List and restores the default Jump List.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  bool Delete();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  // Appends a category to the custom Jump List.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  JumpListResult AppendCategory(const JumpListCategory& category);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  // Appends categories to the custom Jump List.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  JumpListResult AppendCategories(
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-17 21:44:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      const std::vector<JumpListCategory>& categories);
							 | 
						
					
						
							
								
									
										
										
										
											2016-08-12 16:31:17 +07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 private:
							 | 
						
					
						
							
								
									
										
										
										
											2021-03-18 15:55:51 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  std::wstring app_id_;
							 | 
						
					
						
							
								
									
										
										
										
											2016-08-12 16:31:17 +07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  CComPtr<ICustomDestinationList> destinations_;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								};
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}  // namespace electron
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 08:34:31 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#endif  // ELECTRON_SHELL_BROWSER_UI_WIN_JUMP_LIST_H_
							 |