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