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