| Index: chrome/browser/web_applications/web_app_win.cc
|
| diff --git a/chrome/browser/web_applications/web_app_win.cc b/chrome/browser/web_applications/web_app_win.cc
|
| index 0c630f6ab0e3f91d34cdbb57aff9993a768cc4ef..529e863523851c3734e9ac46a5553003cbc6d07e 100644
|
| --- a/chrome/browser/web_applications/web_app_win.cc
|
| +++ b/chrome/browser/web_applications/web_app_win.cc
|
| @@ -23,6 +23,7 @@
|
| #include "chrome/installer/util/shell_util.h"
|
| #include "chrome/installer/util/util_constants.h"
|
| #include "content/public/browser/browser_thread.h"
|
| +#include "ui/base/win/shell.h"
|
| #include "ui/gfx/icon_util.h"
|
| #include "ui/gfx/image/image.h"
|
| #include "ui/gfx/image/image_family.h"
|
| @@ -323,6 +324,58 @@ void GetShortcutLocationsAndDeleteShortcuts(
|
| }
|
| }
|
|
|
| +void CreateIconAndSetRelaunchDetails(const base::FilePath& web_app_path,
|
| + const base::FilePath& icon_file,
|
| + const web_app::ShortcutInfo& shortcut_info,
|
| + HWND hwnd) {
|
| + DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
|
| +
|
| + CommandLine command_line =
|
| + ShellIntegration::CommandLineArgsForLauncher(shortcut_info.url,
|
| + shortcut_info.extension_id,
|
| + shortcut_info.profile_path);
|
| +
|
| + base::FilePath chrome_exe;
|
| + if (!PathService::Get(base::FILE_EXE, &chrome_exe)) {
|
| + NOTREACHED();
|
| + return;
|
| + }
|
| + command_line.SetProgram(chrome_exe);
|
| + ui::win::SetRelaunchDetailsForWindow(
|
| + command_line.GetCommandLineString(), shortcut_info.title, hwnd);
|
| +
|
| + if (!base::PathExists(web_app_path) && !base::CreateDirectory(web_app_path))
|
| + return;
|
| +
|
| + ui::win::SetAppIconForWindow(icon_file.value(), hwnd);
|
| + web_app::internals::CheckAndSaveIcon(icon_file, shortcut_info.favicon);
|
| +}
|
| +
|
| +void OnShortcutInfoLoadedForSetRelaunchDetails(
|
| + HWND hwnd,
|
| + const web_app::ShortcutInfo& shortcut_info) {
|
| + DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
| +
|
| + // Set window's icon to the one we're about to create/update in the web app
|
| + // path. The icon cache will refresh on icon creation.
|
| + base::FilePath web_app_path =
|
| + web_app::GetWebAppDataDirectory(shortcut_info.profile_path,
|
| + shortcut_info.extension_id,
|
| + shortcut_info.url);
|
| + base::FilePath icon_file =
|
| + web_app_path.Append(web_app::internals::GetSanitizedFileName(
|
| + shortcut_info.title))
|
| + .ReplaceExtension(FILE_PATH_LITERAL(".ico"));
|
| +
|
| + content::BrowserThread::PostBlockingPoolTask(
|
| + FROM_HERE,
|
| + base::Bind(&CreateIconAndSetRelaunchDetails,
|
| + web_app_path,
|
| + icon_file,
|
| + shortcut_info,
|
| + hwnd));
|
| +}
|
| +
|
| } // namespace
|
|
|
| namespace web_app {
|
| @@ -351,6 +404,15 @@ base::FilePath CreateShortcutInWebAppDir(const base::FilePath& web_app_dir,
|
| return web_app_dir_shortcut;
|
| }
|
|
|
| +void UpdateRelaunchDetailsForApp(Profile* profile,
|
| + const extensions::Extension* extension,
|
| + HWND hwnd) {
|
| + web_app::UpdateShortcutInfoAndIconForApp(
|
| + extension,
|
| + profile,
|
| + base::Bind(&OnShortcutInfoLoadedForSetRelaunchDetails, hwnd));
|
| +}
|
| +
|
| namespace internals {
|
|
|
| // Saves |image| to |icon_file| if the file is outdated and refresh shell's
|
|
|