| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/views/apps/chrome_native_app_window_views_win.h" | 5 #include "chrome/browser/ui/views/apps/chrome_native_app_window_views_win.h" |
| 6 | 6 |
| 7 #include "apps/app_window.h" | 7 #include "apps/app_window.h" |
| 8 #include "apps/app_window_registry.h" | 8 #include "apps/app_window_registry.h" |
| 9 #include "apps/ui/views/app_window_frame_view.h" | 9 #include "apps/ui/views/app_window_frame_view.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
| 13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "base/threading/sequenced_worker_pool.h" | 15 #include "base/threading/sequenced_worker_pool.h" |
| 16 #include "chrome/browser/apps/per_app_settings_service.h" | 16 #include "chrome/browser/apps/per_app_settings_service.h" |
| 17 #include "chrome/browser/apps/per_app_settings_service_factory.h" | 17 #include "chrome/browser/apps/per_app_settings_service_factory.h" |
| 18 #include "chrome/browser/jumplist_updater_win.h" | 18 #include "chrome/browser/jumplist_updater_win.h" |
| 19 #include "chrome/browser/metro_utils/metro_chrome_win.h" | 19 #include "chrome/browser/metro_utils/metro_chrome_win.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/browser/shell_integration.h" | 21 #include "chrome/browser/shell_integration.h" |
| 22 #include "chrome/browser/ui/views/apps/app_window_desktop_native_widget_aura_win
.h" | 22 #include "chrome/browser/ui/views/apps/app_window_desktop_native_widget_aura_win
.h" |
| 23 #include "chrome/browser/ui/views/apps/glass_app_window_frame_view_win.h" | 23 #include "chrome/browser/ui/views/apps/glass_app_window_frame_view_win.h" |
| 24 #include "chrome/browser/web_applications/web_app.h" | |
| 25 #include "chrome/browser/web_applications/web_app_win.h" | 24 #include "chrome/browser/web_applications/web_app_win.h" |
| 26 #include "chrome/common/chrome_icon_resources_win.h" | 25 #include "chrome/common/chrome_icon_resources_win.h" |
| 27 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
| 28 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
| 29 #include "extensions/common/extension.h" | 28 #include "extensions/common/extension.h" |
| 30 #include "grit/generated_resources.h" | 29 #include "grit/generated_resources.h" |
| 31 #include "ui/aura/remote_window_tree_host_win.h" | 30 #include "ui/aura/remote_window_tree_host_win.h" |
| 32 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
| 33 #include "ui/base/win/shell.h" | 32 #include "ui/base/win/shell.h" |
| 34 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | 33 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
| 35 #include "ui/views/win/hwnd_util.h" | 34 #include "ui/views/win/hwnd_util.h" |
| 36 #include "ui/wm/core/easy_resize_window_targeter.h" | 35 #include "ui/wm/core/easy_resize_window_targeter.h" |
| 37 | 36 |
| 38 #if defined(USE_ASH) | 37 #if defined(USE_ASH) |
| 39 #include "chrome/browser/ui/ash/ash_util.h" | 38 #include "chrome/browser/ui/ash/ash_util.h" |
| 40 #endif | 39 #endif |
| 41 | 40 |
| 42 namespace { | 41 namespace { |
| 43 | 42 |
| 44 void CreateIconAndSetRelaunchDetails( | 43 void CreateIconAndSetRelaunchDetails( |
| 45 const base::FilePath& web_app_path, | 44 const base::FilePath& web_app_path, |
| 46 const base::FilePath& icon_file, | 45 const base::FilePath& icon_file, |
| 47 const ShellIntegration::ShortcutInfo& shortcut_info, | 46 const web_app::ShortcutInfo& shortcut_info, |
| 48 const HWND hwnd) { | 47 const HWND hwnd) { |
| 49 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); | 48 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); |
| 50 | 49 |
| 51 // Set the relaunch data so "Pin this program to taskbar" has the app's | 50 // Set the relaunch data so "Pin this program to taskbar" has the app's |
| 52 // information. | 51 // information. |
| 53 CommandLine command_line = ShellIntegration::CommandLineArgsForLauncher( | 52 CommandLine command_line = ShellIntegration::CommandLineArgsForLauncher( |
| 54 shortcut_info.url, | 53 shortcut_info.url, |
| 55 shortcut_info.extension_id, | 54 shortcut_info.extension_id, |
| 56 shortcut_info.profile_path); | 55 shortcut_info.profile_path); |
| 57 | 56 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 // Only switching into Ash from Native is supported. Tearing the user out of | 88 // Only switching into Ash from Native is supported. Tearing the user out of |
| 90 // Metro mode can only be done by launching a process from Metro mode itself. | 89 // Metro mode can only be done by launching a process from Metro mode itself. |
| 91 // This is done for launching apps, but not regular activations. | 90 // This is done for launching apps, but not regular activations. |
| 92 if (host_desktop_type == chrome::HOST_DESKTOP_TYPE_ASH && | 91 if (host_desktop_type == chrome::HOST_DESKTOP_TYPE_ASH && |
| 93 chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_NATIVE) { | 92 chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_NATIVE) { |
| 94 chrome::ActivateMetroChrome(); | 93 chrome::ActivateMetroChrome(); |
| 95 } | 94 } |
| 96 } | 95 } |
| 97 | 96 |
| 98 void ChromeNativeAppWindowViewsWin::OnShortcutInfoLoaded( | 97 void ChromeNativeAppWindowViewsWin::OnShortcutInfoLoaded( |
| 99 const ShellIntegration::ShortcutInfo& shortcut_info) { | 98 const web_app::ShortcutInfo& shortcut_info) { |
| 100 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 99 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 101 | 100 |
| 102 HWND hwnd = GetNativeAppWindowHWND(); | 101 HWND hwnd = GetNativeAppWindowHWND(); |
| 103 | 102 |
| 104 // Set window's icon to the one we're about to create/update in the web app | 103 // Set window's icon to the one we're about to create/update in the web app |
| 105 // path. The icon cache will refresh on icon creation. | 104 // path. The icon cache will refresh on icon creation. |
| 106 base::FilePath web_app_path = web_app::GetWebAppDataDirectory( | 105 base::FilePath web_app_path = web_app::GetWebAppDataDirectory( |
| 107 shortcut_info.profile_path, shortcut_info.extension_id, | 106 shortcut_info.profile_path, shortcut_info.extension_id, |
| 108 shortcut_info.url); | 107 shortcut_info.url); |
| 109 base::FilePath icon_file = web_app_path | 108 base::FilePath icon_file = web_app_path |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 link->GetCommandLine()->AppendSwitchASCII(switches::kInstallFromWebstore, | 245 link->GetCommandLine()->AppendSwitchASCII(switches::kInstallFromWebstore, |
| 247 extension->id()); | 246 extension->id()); |
| 248 | 247 |
| 249 ShellLinkItemList items; | 248 ShellLinkItemList items; |
| 250 items.push_back(link); | 249 items.push_back(link); |
| 251 jumplist_updater.AddTasks(items); | 250 jumplist_updater.AddTasks(items); |
| 252 } | 251 } |
| 253 | 252 |
| 254 jumplist_updater.CommitUpdate(); | 253 jumplist_updater.CommitUpdate(); |
| 255 } | 254 } |
| OLD | NEW |