Commit e823d885 authored by calamity's avatar calamity Committed by Commit bot

Don't send a SHChangeNotify for creating an app icon when creating a shortcut.

This CL fixes an issue with the initial app sync on sign-in causing many
taskbar flashes due to icon creation always sending a SHChangeNotify.

This shouldn't be necessary for icon creation due to shortcut creation so
avoid SHChangeNotify in this case.

BUG=470002

Review URL: https://codereview.chromium.org/1026113003

Cr-Commit-Position: refs/heads/master@{#322324}
parent ed113b20
......@@ -192,7 +192,7 @@ void UpdateShortcutWorker::UpdateShortcutsOnFileThread() {
base::FilePath icon_file =
web_app::internals::GetIconFilePath(web_app_path, shortcut_info_.title);
web_app::internals::CheckAndSaveIcon(icon_file, shortcut_info_.favicon);
web_app::internals::CheckAndSaveIcon(icon_file, shortcut_info_.favicon, true);
// Update existing shortcuts' description, icon and app id.
CheckExistingShortcuts();
......
......@@ -183,7 +183,8 @@ bool CreateShortcutsInPaths(
// Generates file name to use with persisted ico and shortcut file.
base::FilePath icon_file =
web_app::internals::GetIconFilePath(web_app_path, shortcut_info.title);
if (!web_app::internals::CheckAndSaveIcon(icon_file, shortcut_info.favicon)) {
if (!web_app::internals::CheckAndSaveIcon(icon_file, shortcut_info.favicon,
false)) {
return false;
}
......@@ -357,7 +358,7 @@ void CreateIconAndSetRelaunchDetails(const base::FilePath& web_app_path,
return;
ui::win::SetAppIconForWindow(icon_file.value(), hwnd);
web_app::internals::CheckAndSaveIcon(icon_file, shortcut_info.favicon);
web_app::internals::CheckAndSaveIcon(icon_file, shortcut_info.favicon, true);
}
void OnShortcutInfoLoadedForSetRelaunchDetails(
......@@ -543,7 +544,7 @@ base::FilePath CreateShortcutInWebAppDir(const base::FilePath& web_app_dir,
} else {
internals::CheckAndSaveIcon(
internals::GetIconFilePath(web_app_dir, shortcut_info.title),
shortcut_info.favicon);
shortcut_info.favicon, true);
}
return web_app_dir_shortcut;
}
......@@ -564,23 +565,22 @@ void UpdateShortcutsForAllApps(Profile* profile,
namespace internals {
// Saves |image| to |icon_file| if the file is outdated and refresh shell's
// icon cache to ensure correct icon is displayed. Returns true if icon_file
// is up to date or successfully updated.
bool CheckAndSaveIcon(const base::FilePath& icon_file,
const gfx::ImageFamily& image) {
if (ShouldUpdateIcon(icon_file, image)) {
if (SaveIconWithCheckSum(icon_file, image)) {
// Refresh shell's icon cache. This call is quite disruptive as user would
// see explorer rebuilding the icon cache. It would be great that we find
// a better way to achieve this.
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST | SHCNF_FLUSHNOWAIT,
NULL, NULL);
} else {
return false;
}
}
const gfx::ImageFamily& image,
bool refresh_shell_icon_cache) {
if (!ShouldUpdateIcon(icon_file, image))
return true;
if (!SaveIconWithCheckSum(icon_file, image))
return false;
if (refresh_shell_icon_cache) {
// Refresh shell's icon cache. This call is quite disruptive as user would
// see explorer rebuilding the icon cache. It would be great that we find
// a better way to achieve this.
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST | SHCNF_FLUSHNOWAIT, NULL,
NULL);
}
return true;
}
......@@ -674,7 +674,7 @@ void UpdatePlatformShortcuts(
// Update the icon if necessary.
base::FilePath icon_file = GetIconFilePath(web_app_path, shortcut_info.title);
CheckAndSaveIcon(icon_file, shortcut_info.favicon);
CheckAndSaveIcon(icon_file, shortcut_info.favicon, true);
}
void DeletePlatformShortcuts(const base::FilePath& web_app_path,
......
......@@ -37,8 +37,15 @@ void UpdateRelaunchDetailsForApp(Profile* profile,
namespace internals {
// Saves |image| to |icon_file| if the file is outdated. Returns true if
// icon_file is up to date or successfully updated.
// If |refresh_shell_icon_cache| is true, the shell's icon cache will be
// refreshed, ensuring the correct icon is displayed, but causing a flicker.
// Refreshing the icon cache is not necessary on shortcut creation as the shell
// will be notified when the shortcut is created.
bool CheckAndSaveIcon(const base::FilePath& icon_file,
const gfx::ImageFamily& image);
const gfx::ImageFamily& image,
bool refresh_shell_icon_cache);
base::FilePath GetIconFilePath(const base::FilePath& web_app_path,
const base::string16& title);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment