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 "apps/ui/views/app_window_frame_view.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 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 ChromeNativeAppWindowViewsWin::ChromeNativeAppWindowViewsWin() | 38 ChromeNativeAppWindowViewsWin::ChromeNativeAppWindowViewsWin() |
| 39 : weak_ptr_factory_(this), glass_frame_view_(NULL) { | 39 : weak_ptr_factory_(this), glass_frame_view_(NULL) { |
| 40 } | 40 } |
| 41 | 41 |
| 42 void ChromeNativeAppWindowViewsWin::ActivateParentDesktopIfNecessary() { | 42 void ChromeNativeAppWindowViewsWin::ActivateParentDesktopIfNecessary() { |
| 43 if (!ash::Shell::HasInstance()) | 43 if (IsRunningInAsh() && |
| 44 return; | |
| 45 | |
| 46 views::Widget* widget = | |
| 47 implicit_cast<views::WidgetDelegate*>(this)->GetWidget(); | |
| 48 chrome::HostDesktopType host_desktop_type = | |
| 49 chrome::GetHostDesktopTypeForNativeWindow(widget->GetNativeWindow()); | |
| 50 // 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. | |
| 52 // This is done for launching apps, but not regular activations. | |
|
calamity
2014/06/19 07:43:06
nit: Any reason for removing this condition's comm
benwells
2014/06/19 08:33:37
No good reason :) Added the comment back.
| |
| 53 if (host_desktop_type == chrome::HOST_DESKTOP_TYPE_ASH && | |
| 54 chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_NATIVE) { | 44 chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_NATIVE) { |
| 55 chrome::ActivateMetroChrome(); | 45 chrome::ActivateMetroChrome(); |
| 56 } | 46 } |
| 57 } | 47 } |
| 58 | 48 |
| 59 HWND ChromeNativeAppWindowViewsWin::GetNativeAppWindowHWND() const { | 49 HWND ChromeNativeAppWindowViewsWin::GetNativeAppWindowHWND() const { |
| 60 return views::HWNDForWidget(widget()->GetTopLevelWidget()); | 50 return views::HWNDForWidget(widget()->GetTopLevelWidget()); |
| 61 } | 51 } |
| 62 | 52 |
| 53 bool ChromeNativeAppWindowViewsWin::IsRunningInAsh() { | |
| 54 if (!ash::Shell::HasInstance()) | |
| 55 return false; | |
| 56 | |
| 57 views::Widget* widget = | |
| 58 implicit_cast<views::WidgetDelegate*>(this)->GetWidget(); | |
| 59 chrome::HostDesktopType host_desktop_type = | |
| 60 chrome::GetHostDesktopTypeForNativeWindow(widget->GetNativeWindow()); | |
| 61 return host_desktop_type == chrome::HOST_DESKTOP_TYPE_ASH; | |
| 62 } | |
| 63 | |
| 63 void ChromeNativeAppWindowViewsWin::EnsureCaptionStyleSet() { | 64 void ChromeNativeAppWindowViewsWin::EnsureCaptionStyleSet() { |
| 64 // Windows seems to have issues maximizing windows without WS_CAPTION. | 65 // Windows seems to have issues maximizing windows without WS_CAPTION. |
| 65 // The default views / Aura implementation will remove this if we are using | 66 // The default views / Aura implementation will remove this if we are using |
| 66 // frameless or colored windows, so we put it back here. | 67 // frameless or colored windows, so we put it back here. |
| 67 HWND hwnd = GetNativeAppWindowHWND(); | 68 HWND hwnd = GetNativeAppWindowHWND(); |
| 68 int current_style = ::GetWindowLong(hwnd, GWL_STYLE); | 69 int current_style = ::GetWindowLong(hwnd, GWL_STYLE); |
| 69 ::SetWindowLong(hwnd, GWL_STYLE, current_style | WS_CAPTION); | 70 ::SetWindowLong(hwnd, GWL_STYLE, current_style | WS_CAPTION); |
| 70 } | 71 } |
| 71 | 72 |
| 72 void ChromeNativeAppWindowViewsWin::OnBeforeWidgetInit( | 73 void ChromeNativeAppWindowViewsWin::OnBeforeWidgetInit( |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 114 HWND hwnd = GetNativeAppWindowHWND(); | 115 HWND hwnd = GetNativeAppWindowHWND(); |
| 115 Profile* profile = | 116 Profile* profile = |
| 116 Profile::FromBrowserContext(app_window()->browser_context()); | 117 Profile::FromBrowserContext(app_window()->browser_context()); |
| 117 app_model_id_ = | 118 app_model_id_ = |
| 118 ShellIntegration::GetAppModelIdForProfile(app_name_wide, | 119 ShellIntegration::GetAppModelIdForProfile(app_name_wide, |
| 119 profile->GetPath()); | 120 profile->GetPath()); |
| 120 ui::win::SetAppIdForWindow(app_model_id_, hwnd); | 121 ui::win::SetAppIdForWindow(app_model_id_, hwnd); |
| 121 | 122 |
| 122 web_app::UpdateRelaunchDetailsForApp(profile, extension, hwnd); | 123 web_app::UpdateRelaunchDetailsForApp(profile, extension, hwnd); |
| 123 | 124 |
| 124 if (!create_params.transparent_background) | 125 if (!create_params.transparent_background && !IsRunningInAsh()) |
| 125 EnsureCaptionStyleSet(); | 126 EnsureCaptionStyleSet(); |
| 126 UpdateShelfMenu(); | 127 UpdateShelfMenu(); |
| 127 } | 128 } |
| 128 | 129 |
| 129 views::NonClientFrameView* | 130 views::NonClientFrameView* |
| 130 ChromeNativeAppWindowViewsWin::CreateStandardDesktopAppFrame() { | 131 ChromeNativeAppWindowViewsWin::CreateStandardDesktopAppFrame() { |
| 131 glass_frame_view_ = NULL; | 132 glass_frame_view_ = NULL; |
| 132 if (ui::win::IsAeroGlassEnabled()) { | 133 if (ui::win::IsAeroGlassEnabled()) { |
| 133 glass_frame_view_ = new GlassAppWindowFrameViewWin(this, widget()); | 134 glass_frame_view_ = new GlassAppWindowFrameViewWin(this, widget()); |
| 134 return glass_frame_view_; | 135 return glass_frame_view_; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 183 extension->id()); | 184 extension->id()); |
| 184 | 185 |
| 185 ShellLinkItemList items; | 186 ShellLinkItemList items; |
| 186 items.push_back(link); | 187 items.push_back(link); |
| 187 jumplist_updater.AddTasks(items); | 188 jumplist_updater.AddTasks(items); |
| 188 } | 189 } |
| 189 | 190 |
| 190 // Note that an empty jumplist must still be committed to clear all items. | 191 // Note that an empty jumplist must still be committed to clear all items. |
| 191 jumplist_updater.CommitUpdate(); | 192 jumplist_updater.CommitUpdate(); |
| 192 } | 193 } |
| OLD | NEW |