David Bienvenu | 96bd9fd | 2020-10-05 20:02:22 | [diff] [blame] | 1 | # Windows Shortcut and Pinned Taskbar Icon handling |
| 2 | |
| 3 | When Chrome is installed on Windows, it creates a shortcut on the desktop that |
| 4 | launches Chrome. It also adds the same shortcut to the start menu. These |
| 5 | shortcuts do not specify a profile, so they launch Chrome with the most recently |
| 6 | used profile. |
| 7 | |
| 8 | Windows allows users to pin applications to the taskbar. When a user |
| 9 | pins an application to the taskbar, Windows looks for a desktop shortcut that |
| 10 | matches the application, and if it finds one, it creates a .lnk file in the |
| 11 | directory |
| 12 | `<user dir>\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar.` |
| 13 | If it does not find a matching desktop shortcut, it creates an 8-hex-digit |
| 14 | sub-directory of |
| 15 | `<user dir>\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\ImplicitAppShortcuts\` |
| 16 | and puts the .lnk file in that directory. For example, 3ffff1b1b170b31e. |
| 17 | |
| 18 | App windows on Windows have an |
| 19 | [App User Model ID (AUMI)](https://docs.microsoft.com/en-us/windows/win32/shell/appids) |
| 20 | property. For Chrome windows, this is set in |
| 21 | [BrowserWindowPropertyManager::UpdateWindowProperties](https://source.chromium.org/chromium/chromium/src/+/master:chrome/browser/ui/views/frame/browser_window_property_manager_win.cc?q=BrowserWindowPropertyManager::UpdateWindowProperties), |
| 22 | when a window is opened. Windows desktop shortcuts have an app model property, |
| 23 | and this should match the open window's AUMI. Windows groups open windows with |
| 24 | the same AUMI to a taskbar icon. |
| 25 | |
| 26 | There are two kinds of Chrome windows with AUMI's: browser windows, and app |
| 27 | windows, which include web apps, and extensions, i.e., windows opened via |
| 28 | --app-id or --app. |
| 29 | |
| 30 | [GetAppUserModelIdForBrowser](https://source.chromium.org/chromium/chromium/src/+/master:chrome/browser/shell_integration_win.cc?q=GetAppUserModelIdForBrowser) |
| 31 | constructs an AUMI for a browser window and |
| 32 | [GetAppUserModelIdForApp](https://source.chromium.org/chromium/chromium/src/+/master:chrome/browser/shell_integration_win.cc?q=GetAppUserModelIdForApp) |
| 33 | constructs an AUMI for an app window. Each calls |
| 34 | [ShellUtil::BuildAppUserModelId](https://source.chromium.org/chromium/chromium/src/+/master:chrome/installer/util/shell_util.cc;q=ShellUtil::BuildAppUserModelId) |
| 35 | to construct the AUMI out of component strings. |
| 36 | |
| 37 | All AUMI's start with the base app id, |
| 38 | [install_static::GetBaseAppId](https://source.chromium.org/chromium/chromium/src/+/master:chrome/install_static/install_util.cc?q=install_static::GetBaseAppId). |
| 39 | This varies for different Chrome channels (e.g., Canary vs. Stable) and |
| 40 | different Chromium-based browsers (e.g., Chrome vs. Chromium). |
| 41 | |
| 42 | The AUMI for a browser app has the format: |
| 43 | `<BaseAppId>.<app_name>[.<profile_name>]`. |
| 44 | profile_name is only appended when it's not the default profile. |
| 45 | |
| 46 | The AUMI for a Chrome browser window has the format: |
| 47 | `<BaseAppId>[browser_suffix][.profile_name]`. |
| 48 | profile_name is only appended when it's not the default profile. |
| 49 | browser_suffix is only appended to the BaseAppId if the installer |
| 50 | has set the kRegisterChromeBrowserSuffix command line switch, e.g., |
| 51 | on user-level installs. |
| 52 | |
| 53 | Since AUMI's for browser and app windows include the profile_name, each |
| 54 | profile's windows will be grouped together on the taskbar. |
| 55 | |
| 56 | shell_integration_win.cc has a function [GetExpectedAppId](https://source.chromium.org/chromium/chromium/src/+/master:chrome/browser/shell_integration_win.cc?q=GetExpectedAppid) |
| 57 | to determine what the AUMI for a shortcut should be. It also has a function |
| 58 | [MigrateTaskbarPins](https://source.chromium.org/chromium/chromium/src/+/master:chrome/browser/shell_integration_win.cc?q=MigrateTaskbarPins) |
| 59 | to migrate pinned taskbar icons if the AUMI's need to change. |
| 60 | |
| 61 | ## Multi-profile Support |
| 62 | When the user has more than one profile, the shortcuts are renamed to include |
| 63 | the profile name, e.g., `Chrome.lnk` becomes `<profile name> - Chrome`. The |
| 64 | shortcut icons, both desktop and taskbar, are badged with their profile icon. |
| 65 | This badged icon is also used in the tab preview for a Chrome window. |
| 66 | |
| 67 | ## Diagnosing Issues |
| 68 | To dump a taskbar icon's properties, run this command: |
| 69 | |
| 70 | `python \src\chromium\src\chrome\installer\tools\shortcut_properties.py --dump-all <user dir>\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar` |
| 71 | |
| 72 | This shows you the properties of all the taskbar pinned icons. If the taskbar |
| 73 | icon is in a subdirectory of ImplicitApps, pass that directory to |
| 74 | shortcut_properties.py. |
| 75 | |