Chromium Code Reviews| 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 87bd00b2c3d0c973a55e40b9583033b4f864ceea..77fb471e09f23bc7879f79a2b0bb7a9435d44d50 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,59 @@ 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)) { |
|
sky
2014/05/23 13:27:27
nit: no {}
calamity
2014/05/26 01:54:48
Done.
|
| + 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 { |
| @@ -352,6 +406,15 @@ base::FilePath CreateShortcutInWebAppDir( |
| 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 |