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

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

Issue 229343004: Revert 262516 "Remove title and icon from chrome apps native style title bars." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
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"
10 #include "ash/shell.h" 9 #include "ash/shell.h"
11 #include "base/command_line.h" 10 #include "base/command_line.h"
12 #include "base/file_util.h" 11 #include "base/file_util.h"
13 #include "base/path_service.h" 12 #include "base/path_service.h"
14 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
15 #include "base/threading/sequenced_worker_pool.h" 14 #include "base/threading/sequenced_worker_pool.h"
16 #include "chrome/browser/apps/per_app_settings_service.h" 15 #include "chrome/browser/apps/per_app_settings_service.h"
17 #include "chrome/browser/apps/per_app_settings_service_factory.h" 16 #include "chrome/browser/apps/per_app_settings_service_factory.h"
18 #include "chrome/browser/jumplist_updater_win.h" 17 #include "chrome/browser/jumplist_updater_win.h"
19 #include "chrome/browser/metro_utils/metro_chrome_win.h" 18 #include "chrome/browser/metro_utils/metro_chrome_win.h"
20 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/shell_integration.h" 20 #include "chrome/browser/shell_integration.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"
24 #include "chrome/browser/web_applications/web_app.h" 21 #include "chrome/browser/web_applications/web_app.h"
25 #include "chrome/browser/web_applications/web_app_win.h" 22 #include "chrome/browser/web_applications/web_app_win.h"
26 #include "chrome/common/chrome_icon_resources_win.h" 23 #include "chrome/common/chrome_icon_resources_win.h"
27 #include "chrome/common/chrome_switches.h" 24 #include "chrome/common/chrome_switches.h"
28 #include "content/public/browser/browser_thread.h" 25 #include "content/public/browser/browser_thread.h"
29 #include "extensions/common/extension.h" 26 #include "extensions/common/extension.h"
30 #include "grit/generated_resources.h" 27 #include "grit/generated_resources.h"
31 #include "ui/aura/remote_window_tree_host_win.h" 28 #include "ui/aura/remote_window_tree_host_win.h"
32 #include "ui/base/l10n/l10n_util.h" 29 #include "ui/base/l10n/l10n_util.h"
33 #include "ui/base/win/shell.h" 30 #include "ui/base/win/shell.h"
34 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" 31 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
35 #include "ui/views/win/hwnd_util.h" 32 #include "ui/views/win/hwnd_util.h"
36 #include "ui/wm/core/easy_resize_window_targeter.h"
37
38 #if defined(USE_ASH)
39 #include "chrome/browser/ui/ash/ash_util.h"
40 #endif
41 33
42 namespace { 34 namespace {
43 35
44 void CreateIconAndSetRelaunchDetails( 36 void CreateIconAndSetRelaunchDetails(
45 const base::FilePath& web_app_path, 37 const base::FilePath& web_app_path,
46 const base::FilePath& icon_file, 38 const base::FilePath& icon_file,
47 const ShellIntegration::ShortcutInfo& shortcut_info, 39 const ShellIntegration::ShortcutInfo& shortcut_info,
48 const HWND hwnd) { 40 const HWND hwnd) {
49 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); 41 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
50 42
(...skipping 18 matching lines...) Expand all
69 return; 61 return;
70 } 62 }
71 63
72 ui::win::SetAppIconForWindow(icon_file.value(), hwnd); 64 ui::win::SetAppIconForWindow(icon_file.value(), hwnd);
73 web_app::internals::CheckAndSaveIcon(icon_file, shortcut_info.favicon); 65 web_app::internals::CheckAndSaveIcon(icon_file, shortcut_info.favicon);
74 } 66 }
75 67
76 } // namespace 68 } // namespace
77 69
78 ChromeNativeAppWindowViewsWin::ChromeNativeAppWindowViewsWin() 70 ChromeNativeAppWindowViewsWin::ChromeNativeAppWindowViewsWin()
79 : weak_ptr_factory_(this), glass_frame_view_(NULL) {} 71 : weak_ptr_factory_(this) {}
80 72
81 void ChromeNativeAppWindowViewsWin::ActivateParentDesktopIfNecessary() { 73 void ChromeNativeAppWindowViewsWin::ActivateParentDesktopIfNecessary() {
82 if (!ash::Shell::HasInstance()) 74 if (!ash::Shell::HasInstance())
83 return; 75 return;
84 76
85 views::Widget* widget = 77 views::Widget* widget =
86 implicit_cast<views::WidgetDelegate*>(this)->GetWidget(); 78 implicit_cast<views::WidgetDelegate*>(this)->GetWidget();
87 chrome::HostDesktopType host_desktop_type = 79 chrome::HostDesktopType host_desktop_type =
88 chrome::GetHostDesktopTypeForNativeWindow(widget->GetNativeWindow()); 80 chrome::GetHostDesktopTypeForNativeWindow(widget->GetNativeWindow());
89 // Only switching into Ash from Native is supported. Tearing the user out of 81 // Only switching into Ash from Native is supported. Tearing the user out of
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 desktop_type = settings->GetDesktopLastLaunchedFrom(extension->id()); 133 desktop_type = settings->GetDesktopLastLaunchedFrom(extension->id());
142 } else { 134 } else {
143 // We don't know what desktop this app was last launched from, so take our 135 // We don't know what desktop this app was last launched from, so take our
144 // best guess as to what desktop the user is on. 136 // best guess as to what desktop the user is on.
145 desktop_type = chrome::GetActiveDesktop(); 137 desktop_type = chrome::GetActiveDesktop();
146 } 138 }
147 } 139 }
148 if (desktop_type == chrome::HOST_DESKTOP_TYPE_ASH) 140 if (desktop_type == chrome::HOST_DESKTOP_TYPE_ASH)
149 init_params->context = ash::Shell::GetPrimaryRootWindow(); 141 init_params->context = ash::Shell::GetPrimaryRootWindow();
150 else 142 else
151 init_params->native_widget = new AppWindowDesktopNativeWidgetAuraWin(this); 143 init_params->native_widget = new views::DesktopNativeWidgetAura(widget);
152 } 144 }
153 145
154 void ChromeNativeAppWindowViewsWin::InitializeDefaultWindow( 146 void ChromeNativeAppWindowViewsWin::InitializeDefaultWindow(
155 const apps::AppWindow::CreateParams& create_params) { 147 const apps::AppWindow::CreateParams& create_params) {
156 ChromeNativeAppWindowViews::InitializeDefaultWindow(create_params); 148 ChromeNativeAppWindowViews::InitializeDefaultWindow(create_params);
157 149
158 const extensions::Extension* extension = app_window()->extension(); 150 const extensions::Extension* extension = app_window()->extension();
159 std::string app_name = 151 std::string app_name =
160 web_app::GenerateApplicationNameFromExtensionId(extension->id()); 152 web_app::GenerateApplicationNameFromExtensionId(extension->id());
161 base::string16 app_name_wide = base::UTF8ToWide(app_name); 153 base::string16 app_name_wide = base::UTF8ToWide(app_name);
162 HWND hwnd = GetNativeAppWindowHWND(); 154 HWND hwnd = GetNativeAppWindowHWND();
163 Profile* profile = 155 Profile* profile =
164 Profile::FromBrowserContext(app_window()->browser_context()); 156 Profile::FromBrowserContext(app_window()->browser_context());
165 app_model_id_ = 157 app_model_id_ =
166 ShellIntegration::GetAppModelIdForProfile(app_name_wide, 158 ShellIntegration::GetAppModelIdForProfile(app_name_wide,
167 profile->GetPath()); 159 profile->GetPath());
168 ui::win::SetAppIdForWindow(app_model_id_, hwnd); 160 ui::win::SetAppIdForWindow(app_model_id_, hwnd);
169 161
170 web_app::UpdateShortcutInfoAndIconForApp( 162 web_app::UpdateShortcutInfoAndIconForApp(
171 extension, 163 extension,
172 profile, 164 profile,
173 base::Bind(&ChromeNativeAppWindowViewsWin::OnShortcutInfoLoaded, 165 base::Bind(&ChromeNativeAppWindowViewsWin::OnShortcutInfoLoaded,
174 weak_ptr_factory_.GetWeakPtr())); 166 weak_ptr_factory_.GetWeakPtr()));
175 167
176 UpdateShelfMenu(); 168 UpdateShelfMenu();
177 } 169 }
178 170
179 views::NonClientFrameView*
180 ChromeNativeAppWindowViewsWin::CreateStandardDesktopAppFrame() {
181 glass_frame_view_ = NULL;
182 if (ui::win::IsAeroGlassEnabled()) {
183 glass_frame_view_ = new GlassAppWindowFrameViewWin(this, widget());
184 return glass_frame_view_;
185 }
186 return ChromeNativeAppWindowViews::CreateStandardDesktopAppFrame();
187 }
188
189 apps::AppWindowFrameView*
190 ChromeNativeAppWindowViewsWin::CreateNonStandardAppFrame() {
191 apps::AppWindowFrameView* frame =
192 ChromeNativeAppWindowViews::CreateNonStandardAppFrame();
193
194 if (!chrome::IsNativeWindowInAsh(widget()->GetNativeWindow())) {
195 aura::Window* root_window = widget()->GetNativeWindow()->GetRootWindow();
196 int resize_inside = frame->resize_inside_bounds_size();
197 gfx::Insets inset(
198 resize_inside, resize_inside, resize_inside, resize_inside);
199 root_window->SetEventTargeter(scoped_ptr<ui::EventTargeter>(
200 new wm::EasyResizeWindowTargeter(root_window, inset, inset)));
201 }
202
203 return frame;
204 }
205
206 void ChromeNativeAppWindowViewsWin::Show() { 171 void ChromeNativeAppWindowViewsWin::Show() {
207 ActivateParentDesktopIfNecessary(); 172 ActivateParentDesktopIfNecessary();
208 ChromeNativeAppWindowViews::Show(); 173 ChromeNativeAppWindowViews::Show();
209 } 174 }
210 175
211 void ChromeNativeAppWindowViewsWin::Activate() { 176 void ChromeNativeAppWindowViewsWin::Activate() {
212 ActivateParentDesktopIfNecessary(); 177 ActivateParentDesktopIfNecessary();
213 ChromeNativeAppWindowViews::Activate(); 178 ChromeNativeAppWindowViews::Activate();
214 } 179 }
215 180
(...skipping 30 matching lines...) Expand all
246 link->GetCommandLine()->AppendSwitchASCII(switches::kInstallFromWebstore, 211 link->GetCommandLine()->AppendSwitchASCII(switches::kInstallFromWebstore,
247 extension->id()); 212 extension->id());
248 213
249 ShellLinkItemList items; 214 ShellLinkItemList items;
250 items.push_back(link); 215 items.push_back(link);
251 jumplist_updater.AddTasks(items); 216 jumplist_updater.AddTasks(items);
252 } 217 }
253 218
254 jumplist_updater.CommitUpdate(); 219 jumplist_updater.CommitUpdate();
255 } 220 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698