desktop-pwas: Fix regression in Create Shortcuts Dialog
This CL fixes an issue that prevents an app icon from appearing when the Create shortcut dialog is invoked. The dialog is invoked by clicking: Customize and control Google Chrome > More tools > Create shortcut... Cause: The initial CL for shortcuts menu https://crrev.com/c/2146212 modified FilterSquareIconsFromMap() in web_app_install_utils.cc. From: void FilterSquareIconsFromMap(const IconsMap& icons_map, std::vector<SkBitmap>* square_icons) To: void FilterSquareIconsFromMap( const std::vector<WebApplicationIconInfo>& icon_infos, const IconsMap& icons_map, std::vector<SkBitmap>* square_icons) This was done because icons_map can contain both app icon and shortcut icon related bitmaps when a site specifies shortcuts icons in it's web app manifest and the shortcuts menu feature is enabled. The code inside FilterSquareIconsFromMap() iterated over icon_infos while adding bitmaps to the square_icons vector. Those bitmaps were used to generate app icons of various sizes. For some websites like www.google.com icon_infos can be empty. In such cases, the code to populate square_icons in FilterSquareIconsFromMap doesn't run as there's nothing to iterate over. This results in an empty square_icons which in turn leads to no app icon in the Create shortcut dialog. Fix: This CL reverts FilterSquareIconsFromMap() to its state before the shortcuts menu feature landed (no icon_infos argument). In FilterAndResizeIconsGenerateMissing() which calls FilterSquareIconsFromMap, the code checks if kDesktopPWAsAppIconShortcutsMenu is enabled. When the feature is disabled, it calls FilterSquareIconsFromMap(). When the feature is enabled, it calls the newly added: void FilterSquareIconsFromMapDisregardShortcutIcons( const std::vector<WebApplicationIconInfo>& icon_infos, const IconsMap& icons_map, std::vector<SkBitmap>* square_icons){} This method calls FilterSquareIconsFromMap() if icon_infos is empty. Otherwise, it iterates over icon_infos. Testing: I tested this fix by invoking the Create shortcut dialog with the DesktopPWAsAppIconShortcutsMenu feature enabled and also with it disabled. In both cases, app icons showed up as expected. I've also added a couple new unit tests for FilterAndResizeIconsGenerateMissing(). Bug: 1084913 Change-Id: I59bf6ca45e84546a93c891c52014017bd566c8f0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2209968 Commit-Queue: Rahul Singh <rahsin@microsoft.com> Reviewed-by:Chase Phillips <cmp@chromium.org> Cr-Commit-Position: refs/heads/master@{#771315}
Showing
Please register or sign in to comment