Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Side by Side Diff: chrome/browser/ui/views/apps/chrome_native_app_window_views_win.cc

Issue 298003005: Revert of Support "Pin to taskbar" for hosted app windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/views/frame/browser_window_property_manager_browsertest_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 17 matching lines...) Expand all
28 #include "content/public/browser/browser_thread.h" 28 #include "content/public/browser/browser_thread.h"
29 #include "extensions/browser/extension_util.h" 29 #include "extensions/browser/extension_util.h"
30 #include "extensions/common/extension.h" 30 #include "extensions/common/extension.h"
31 #include "grit/generated_resources.h" 31 #include "grit/generated_resources.h"
32 #include "ui/aura/remote_window_tree_host_win.h" 32 #include "ui/aura/remote_window_tree_host_win.h"
33 #include "ui/base/l10n/l10n_util.h" 33 #include "ui/base/l10n/l10n_util.h"
34 #include "ui/base/win/shell.h" 34 #include "ui/base/win/shell.h"
35 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" 35 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
36 #include "ui/views/win/hwnd_util.h" 36 #include "ui/views/win/hwnd_util.h"
37 37
38 namespace {
39
40 void CreateIconAndSetRelaunchDetails(
41 const base::FilePath& web_app_path,
42 const base::FilePath& icon_file,
43 const web_app::ShortcutInfo& shortcut_info,
44 const HWND hwnd) {
45 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
46
47 // Set the relaunch data so "Pin this program to taskbar" has the app's
48 // information.
49 CommandLine command_line = ShellIntegration::CommandLineArgsForLauncher(
50 shortcut_info.url,
51 shortcut_info.extension_id,
52 shortcut_info.profile_path);
53
54 base::FilePath chrome_exe;
55 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) {
56 NOTREACHED();
57 return;
58 }
59 command_line.SetProgram(chrome_exe);
60 ui::win::SetRelaunchDetailsForWindow(command_line.GetCommandLineString(),
61 shortcut_info.title, hwnd);
62
63 if (!base::PathExists(web_app_path) &&
64 !base::CreateDirectory(web_app_path)) {
65 return;
66 }
67
68 ui::win::SetAppIconForWindow(icon_file.value(), hwnd);
69 web_app::internals::CheckAndSaveIcon(icon_file, shortcut_info.favicon);
70 }
71
72 } // namespace
73
38 ChromeNativeAppWindowViewsWin::ChromeNativeAppWindowViewsWin() 74 ChromeNativeAppWindowViewsWin::ChromeNativeAppWindowViewsWin()
39 : weak_ptr_factory_(this), glass_frame_view_(NULL) { 75 : weak_ptr_factory_(this), glass_frame_view_(NULL) {
40 } 76 }
41 77
42 void ChromeNativeAppWindowViewsWin::ActivateParentDesktopIfNecessary() { 78 void ChromeNativeAppWindowViewsWin::ActivateParentDesktopIfNecessary() {
43 if (!ash::Shell::HasInstance()) 79 if (!ash::Shell::HasInstance())
44 return; 80 return;
45 81
46 views::Widget* widget = 82 views::Widget* widget =
47 implicit_cast<views::WidgetDelegate*>(this)->GetWidget(); 83 implicit_cast<views::WidgetDelegate*>(this)->GetWidget();
48 chrome::HostDesktopType host_desktop_type = 84 chrome::HostDesktopType host_desktop_type =
49 chrome::GetHostDesktopTypeForNativeWindow(widget->GetNativeWindow()); 85 chrome::GetHostDesktopTypeForNativeWindow(widget->GetNativeWindow());
50 // Only switching into Ash from Native is supported. Tearing the user out of 86 // Only switching into Ash from Native is supported. Tearing the user out of
51 // Metro mode can only be done by launching a process from Metro mode itself. 87 // Metro mode can only be done by launching a process from Metro mode itself.
52 // This is done for launching apps, but not regular activations. 88 // This is done for launching apps, but not regular activations.
53 if (host_desktop_type == chrome::HOST_DESKTOP_TYPE_ASH && 89 if (host_desktop_type == chrome::HOST_DESKTOP_TYPE_ASH &&
54 chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_NATIVE) { 90 chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_NATIVE) {
55 chrome::ActivateMetroChrome(); 91 chrome::ActivateMetroChrome();
56 } 92 }
57 } 93 }
58 94
95 void ChromeNativeAppWindowViewsWin::OnShortcutInfoLoaded(
96 const web_app::ShortcutInfo& shortcut_info) {
97 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
98
99 HWND hwnd = GetNativeAppWindowHWND();
100
101 // Set window's icon to the one we're about to create/update in the web app
102 // path. The icon cache will refresh on icon creation.
103 base::FilePath web_app_path = web_app::GetWebAppDataDirectory(
104 shortcut_info.profile_path, shortcut_info.extension_id,
105 shortcut_info.url);
106 base::FilePath icon_file = web_app_path
107 .Append(web_app::internals::GetSanitizedFileName(shortcut_info.title))
108 .ReplaceExtension(FILE_PATH_LITERAL(".ico"));
109
110 content::BrowserThread::PostBlockingPoolTask(
111 FROM_HERE,
112 base::Bind(&CreateIconAndSetRelaunchDetails,
113 web_app_path, icon_file, shortcut_info, hwnd));
114 }
115
59 HWND ChromeNativeAppWindowViewsWin::GetNativeAppWindowHWND() const { 116 HWND ChromeNativeAppWindowViewsWin::GetNativeAppWindowHWND() const {
60 return views::HWNDForWidget(widget()->GetTopLevelWidget()); 117 return views::HWNDForWidget(widget()->GetTopLevelWidget());
61 } 118 }
62 119
63 void ChromeNativeAppWindowViewsWin::EnsureCaptionStyleSet() { 120 void ChromeNativeAppWindowViewsWin::EnsureCaptionStyleSet() {
64 // Windows seems to have issues maximizing windows without WS_CAPTION. 121 // Windows seems to have issues maximizing windows without WS_CAPTION.
65 // The default views / Aura implementation will remove this if we are using 122 // The default views / Aura implementation will remove this if we are using
66 // frameless or colored windows, so we put it back here. 123 // frameless or colored windows, so we put it back here.
67 HWND hwnd = GetNativeAppWindowHWND(); 124 HWND hwnd = GetNativeAppWindowHWND();
68 int current_style = ::GetWindowLong(hwnd, GWL_STYLE); 125 int current_style = ::GetWindowLong(hwnd, GWL_STYLE);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 web_app::GenerateApplicationNameFromExtensionId(extension->id()); 169 web_app::GenerateApplicationNameFromExtensionId(extension->id());
113 base::string16 app_name_wide = base::UTF8ToWide(app_name); 170 base::string16 app_name_wide = base::UTF8ToWide(app_name);
114 HWND hwnd = GetNativeAppWindowHWND(); 171 HWND hwnd = GetNativeAppWindowHWND();
115 Profile* profile = 172 Profile* profile =
116 Profile::FromBrowserContext(app_window()->browser_context()); 173 Profile::FromBrowserContext(app_window()->browser_context());
117 app_model_id_ = 174 app_model_id_ =
118 ShellIntegration::GetAppModelIdForProfile(app_name_wide, 175 ShellIntegration::GetAppModelIdForProfile(app_name_wide,
119 profile->GetPath()); 176 profile->GetPath());
120 ui::win::SetAppIdForWindow(app_model_id_, hwnd); 177 ui::win::SetAppIdForWindow(app_model_id_, hwnd);
121 178
122 web_app::UpdateRelaunchDetailsForApp(profile, extension, hwnd); 179 web_app::UpdateShortcutInfoAndIconForApp(
180 extension,
181 profile,
182 base::Bind(&ChromeNativeAppWindowViewsWin::OnShortcutInfoLoaded,
183 weak_ptr_factory_.GetWeakPtr()));
123 184
124 if (!create_params.transparent_background) 185 if (!create_params.transparent_background)
125 EnsureCaptionStyleSet(); 186 EnsureCaptionStyleSet();
126 UpdateShelfMenu(); 187 UpdateShelfMenu();
127 } 188 }
128 189
129 views::NonClientFrameView* 190 views::NonClientFrameView*
130 ChromeNativeAppWindowViewsWin::CreateStandardDesktopAppFrame() { 191 ChromeNativeAppWindowViewsWin::CreateStandardDesktopAppFrame() {
131 glass_frame_view_ = NULL; 192 glass_frame_view_ = NULL;
132 if (ui::win::IsAeroGlassEnabled()) { 193 if (ui::win::IsAeroGlassEnabled()) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 extension->id()); 244 extension->id());
184 245
185 ShellLinkItemList items; 246 ShellLinkItemList items;
186 items.push_back(link); 247 items.push_back(link);
187 jumplist_updater.AddTasks(items); 248 jumplist_updater.AddTasks(items);
188 } 249 }
189 250
190 // Note that an empty jumplist must still be committed to clear all items. 251 // Note that an empty jumplist must still be committed to clear all items.
191 jumplist_updater.CommitUpdate(); 252 jumplist_updater.CommitUpdate();
192 } 253 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/frame/browser_window_property_manager_browsertest_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698