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

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

Issue 589303002: App windows launched in windows ASH should not be messing with the AppUserModelId for the remote HW… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code review comments Created 6 years, 3 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 | « chrome/browser/ui/views/apps/chrome_native_app_window_views_win.h ('k') | no next file » | 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/ui/views/app_window_frame_view.h" 7 #include "apps/ui/views/app_window_frame_view.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 if (desktop_type == chrome::HOST_DESKTOP_TYPE_ASH) 101 if (desktop_type == chrome::HOST_DESKTOP_TYPE_ASH)
102 init_params->context = ash::Shell::GetPrimaryRootWindow(); 102 init_params->context = ash::Shell::GetPrimaryRootWindow();
103 else 103 else
104 init_params->native_widget = new AppWindowDesktopNativeWidgetAuraWin(this); 104 init_params->native_widget = new AppWindowDesktopNativeWidgetAuraWin(this);
105 } 105 }
106 106
107 void ChromeNativeAppWindowViewsWin::InitializeDefaultWindow( 107 void ChromeNativeAppWindowViewsWin::InitializeDefaultWindow(
108 const extensions::AppWindow::CreateParams& create_params) { 108 const extensions::AppWindow::CreateParams& create_params) {
109 ChromeNativeAppWindowViews::InitializeDefaultWindow(create_params); 109 ChromeNativeAppWindowViews::InitializeDefaultWindow(create_params);
110 110
111 // Remaining initialization is for Windows shell integration, which doesn't
112 // apply to app windows in Ash.
113 if (IsRunningInAsh())
114 return;
115
111 const extensions::Extension* extension = app_window()->GetExtension(); 116 const extensions::Extension* extension = app_window()->GetExtension();
112 if (!extension) 117 if (!extension)
113 return; 118 return;
114 119
115 std::string app_name = 120 std::string app_name =
116 web_app::GenerateApplicationNameFromExtensionId(extension->id()); 121 web_app::GenerateApplicationNameFromExtensionId(extension->id());
117 base::string16 app_name_wide = base::UTF8ToWide(app_name); 122 base::string16 app_name_wide = base::UTF8ToWide(app_name);
118 HWND hwnd = GetNativeAppWindowHWND(); 123 HWND hwnd = GetNativeAppWindowHWND();
119 Profile* profile = 124 Profile* profile =
120 Profile::FromBrowserContext(app_window()->browser_context()); 125 Profile::FromBrowserContext(app_window()->browser_context());
121 app_model_id_ = 126 app_model_id_ =
122 ShellIntegration::GetAppModelIdForProfile(app_name_wide, 127 ShellIntegration::GetAppModelIdForProfile(app_name_wide,
123 profile->GetPath()); 128 profile->GetPath());
124 ui::win::SetAppIdForWindow(app_model_id_, hwnd); 129 ui::win::SetAppIdForWindow(app_model_id_, hwnd);
125
126 web_app::UpdateRelaunchDetailsForApp(profile, extension, hwnd); 130 web_app::UpdateRelaunchDetailsForApp(profile, extension, hwnd);
127 131
128 if (!create_params.alpha_enabled && !IsRunningInAsh()) 132 if (!create_params.alpha_enabled)
129 EnsureCaptionStyleSet(); 133 EnsureCaptionStyleSet();
130 UpdateShelfMenu(); 134 UpdateShelfMenu();
131 } 135 }
132 136
133 views::NonClientFrameView* 137 views::NonClientFrameView*
134 ChromeNativeAppWindowViewsWin::CreateStandardDesktopAppFrame() { 138 ChromeNativeAppWindowViewsWin::CreateStandardDesktopAppFrame() {
135 glass_frame_view_ = NULL; 139 glass_frame_view_ = NULL;
136 if (ui::win::IsAeroGlassEnabled()) { 140 if (ui::win::IsAeroGlassEnabled()) {
137 glass_frame_view_ = new GlassAppWindowFrameViewWin(this, widget()); 141 glass_frame_view_ = new GlassAppWindowFrameViewWin(this, widget());
138 return glass_frame_view_; 142 return glass_frame_view_;
139 } 143 }
140 return ChromeNativeAppWindowViews::CreateStandardDesktopAppFrame(); 144 return ChromeNativeAppWindowViews::CreateStandardDesktopAppFrame();
141 } 145 }
142 146
143 void ChromeNativeAppWindowViewsWin::Show() { 147 void ChromeNativeAppWindowViewsWin::Show() {
144 ActivateParentDesktopIfNecessary(); 148 ActivateParentDesktopIfNecessary();
145 ChromeNativeAppWindowViews::Show(); 149 ChromeNativeAppWindowViews::Show();
146 } 150 }
147 151
148 void ChromeNativeAppWindowViewsWin::Activate() { 152 void ChromeNativeAppWindowViewsWin::Activate() {
149 ActivateParentDesktopIfNecessary(); 153 ActivateParentDesktopIfNecessary();
150 ChromeNativeAppWindowViews::Activate(); 154 ChromeNativeAppWindowViews::Activate();
151 } 155 }
152 156
153 void ChromeNativeAppWindowViewsWin::UpdateShelfMenu() { 157 void ChromeNativeAppWindowViewsWin::UpdateShelfMenu() {
154 if (!JumpListUpdater::IsEnabled()) 158 if (!JumpListUpdater::IsEnabled() || IsRunningInAsh())
155 return; 159 return;
156 160
157 // Currently the only option is related to ephemeral apps, so avoid updating 161 // Currently the only option is related to ephemeral apps, so avoid updating
158 // the app's jump list when the feature is not enabled. 162 // the app's jump list when the feature is not enabled.
159 if (!CommandLine::ForCurrentProcess()->HasSwitch( 163 if (!CommandLine::ForCurrentProcess()->HasSwitch(
160 switches::kEnableEphemeralApps)) { 164 switches::kEnableEphemeralApps)) {
161 return; 165 return;
162 } 166 }
163 167
164 const extensions::Extension* extension = app_window()->GetExtension(); 168 const extensions::Extension* extension = app_window()->GetExtension();
165 if (!extension) 169 if (!extension)
166 return; 170 return;
167 171
168 // For the icon resources. 172 // For the icon resources.
169 base::FilePath chrome_path; 173 base::FilePath chrome_path;
170 if (!PathService::Get(base::FILE_EXE, &chrome_path)) 174 if (!PathService::Get(base::FILE_EXE, &chrome_path))
171 return; 175 return;
172 176
177 DCHECK(!app_model_id_.empty());
178
173 JumpListUpdater jumplist_updater(app_model_id_); 179 JumpListUpdater jumplist_updater(app_model_id_);
174 if (!jumplist_updater.BeginUpdate()) 180 if (!jumplist_updater.BeginUpdate())
175 return; 181 return;
176 182
177 // Add item to install ephemeral apps. 183 // Add item to install ephemeral apps.
178 if (extensions::util::IsEphemeralApp(extension->id(), 184 if (extensions::util::IsEphemeralApp(extension->id(),
179 app_window()->browser_context())) { 185 app_window()->browser_context())) {
180 scoped_refptr<ShellLinkItem> link(new ShellLinkItem()); 186 scoped_refptr<ShellLinkItem> link(new ShellLinkItem());
181 link->set_title(l10n_util::GetStringUTF16(IDS_APP_INSTALL_TITLE)); 187 link->set_title(l10n_util::GetStringUTF16(IDS_APP_INSTALL_TITLE));
182 link->set_icon(chrome_path.value(), 188 link->set_icon(chrome_path.value(),
183 icon_resources::kInstallPackagedAppIndex); 189 icon_resources::kInstallPackagedAppIndex);
184 ShellIntegration::AppendProfileArgs( 190 ShellIntegration::AppendProfileArgs(
185 app_window()->browser_context()->GetPath(), link->GetCommandLine()); 191 app_window()->browser_context()->GetPath(), link->GetCommandLine());
186 link->GetCommandLine()->AppendSwitchASCII(switches::kInstallFromWebstore, 192 link->GetCommandLine()->AppendSwitchASCII(switches::kInstallFromWebstore,
187 extension->id()); 193 extension->id());
188 194
189 ShellLinkItemList items; 195 ShellLinkItemList items;
190 items.push_back(link); 196 items.push_back(link);
191 jumplist_updater.AddTasks(items); 197 jumplist_updater.AddTasks(items);
192 } 198 }
193 199
194 // Note that an empty jumplist must still be committed to clear all items. 200 // Note that an empty jumplist must still be committed to clear all items.
195 jumplist_updater.CommitUpdate(); 201 jumplist_updater.CommitUpdate();
196 } 202 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/apps/chrome_native_app_window_views_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698