| Index: chrome/browser/ui/views/apps/chrome_native_app_window_views_win.cc
|
| diff --git a/chrome/browser/ui/views/apps/chrome_native_app_window_views_win.cc b/chrome/browser/ui/views/apps/chrome_native_app_window_views_win.cc
|
| index b048fb4cc4cea58a64bfa2a3bf6763abc5c928f3..b100703e907fef9a898b12f1e32bc0241ff685d6 100644
|
| --- a/chrome/browser/ui/views/apps/chrome_native_app_window_views_win.cc
|
| +++ b/chrome/browser/ui/views/apps/chrome_native_app_window_views_win.cc
|
| @@ -35,6 +35,42 @@
|
| #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
|
| #include "ui/views/win/hwnd_util.h"
|
|
|
| +namespace {
|
| +
|
| +void CreateIconAndSetRelaunchDetails(
|
| + const base::FilePath& web_app_path,
|
| + const base::FilePath& icon_file,
|
| + const web_app::ShortcutInfo& shortcut_info,
|
| + const HWND hwnd) {
|
| + DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
|
| +
|
| + // Set the relaunch data so "Pin this program to taskbar" has the app's
|
| + // information.
|
| + 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);
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| ChromeNativeAppWindowViewsWin::ChromeNativeAppWindowViewsWin()
|
| : weak_ptr_factory_(this), glass_frame_view_(NULL) {
|
| }
|
| @@ -54,6 +90,27 @@
|
| chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_NATIVE) {
|
| chrome::ActivateMetroChrome();
|
| }
|
| +}
|
| +
|
| +void ChromeNativeAppWindowViewsWin::OnShortcutInfoLoaded(
|
| + const web_app::ShortcutInfo& shortcut_info) {
|
| + DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
| +
|
| + HWND hwnd = GetNativeAppWindowHWND();
|
| +
|
| + // 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));
|
| }
|
|
|
| HWND ChromeNativeAppWindowViewsWin::GetNativeAppWindowHWND() const {
|
| @@ -119,7 +176,11 @@
|
| profile->GetPath());
|
| ui::win::SetAppIdForWindow(app_model_id_, hwnd);
|
|
|
| - web_app::UpdateRelaunchDetailsForApp(profile, extension, hwnd);
|
| + web_app::UpdateShortcutInfoAndIconForApp(
|
| + extension,
|
| + profile,
|
| + base::Bind(&ChromeNativeAppWindowViewsWin::OnShortcutInfoLoaded,
|
| + weak_ptr_factory_.GetWeakPtr()));
|
|
|
| if (!create_params.transparent_background)
|
| EnsureCaptionStyleSet();
|
|
|