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/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" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "base/threading/sequenced_worker_pool.h" | 12 #include "base/threading/sequenced_worker_pool.h" |
13 #include "chrome/browser/apps/per_app_settings_service.h" | 13 #include "chrome/browser/apps/per_app_settings_service.h" |
14 #include "chrome/browser/apps/per_app_settings_service_factory.h" | 14 #include "chrome/browser/apps/per_app_settings_service_factory.h" |
15 #include "chrome/browser/metro_utils/metro_chrome_win.h" | |
16 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/shell_integration.h" | 16 #include "chrome/browser/shell_integration.h" |
18 #include "chrome/browser/ui/views/apps/app_window_desktop_native_widget_aura_win
.h" | 17 #include "chrome/browser/ui/views/apps/app_window_desktop_native_widget_aura_win
.h" |
19 #include "chrome/browser/ui/views/apps/glass_app_window_frame_view_win.h" | 18 #include "chrome/browser/ui/views/apps/glass_app_window_frame_view_win.h" |
20 #include "chrome/browser/web_applications/web_app.h" | 19 #include "chrome/browser/web_applications/web_app.h" |
21 #include "chrome/browser/web_applications/web_app_win.h" | 20 #include "chrome/browser/web_applications/web_app_win.h" |
22 #include "chrome/common/chrome_icon_resources_win.h" | 21 #include "chrome/common/chrome_icon_resources_win.h" |
23 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
24 #include "chrome/grit/generated_resources.h" | 23 #include "chrome/grit/generated_resources.h" |
25 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
26 #include "extensions/browser/app_window/app_window.h" | 25 #include "extensions/browser/app_window/app_window.h" |
27 #include "extensions/browser/app_window/app_window_registry.h" | 26 #include "extensions/browser/app_window/app_window_registry.h" |
28 #include "extensions/common/extension.h" | 27 #include "extensions/common/extension.h" |
29 #include "ui/aura/remote_window_tree_host_win.h" | 28 #include "ui/aura/remote_window_tree_host_win.h" |
30 #include "ui/base/l10n/l10n_util.h" | 29 #include "ui/base/l10n/l10n_util.h" |
31 #include "ui/base/win/shell.h" | 30 #include "ui/base/win/shell.h" |
32 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | 31 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
33 #include "ui/views/win/hwnd_util.h" | 32 #include "ui/views/win/hwnd_util.h" |
34 | 33 |
35 ChromeNativeAppWindowViewsWin::ChromeNativeAppWindowViewsWin() | 34 ChromeNativeAppWindowViewsWin::ChromeNativeAppWindowViewsWin() |
36 : glass_frame_view_(NULL), is_translucent_(false), weak_ptr_factory_(this) { | 35 : glass_frame_view_(NULL), is_translucent_(false), weak_ptr_factory_(this) { |
37 } | 36 } |
38 | 37 |
39 ChromeNativeAppWindowViewsWin::~ChromeNativeAppWindowViewsWin() { | 38 ChromeNativeAppWindowViewsWin::~ChromeNativeAppWindowViewsWin() { |
40 } | 39 } |
41 | 40 |
42 void ChromeNativeAppWindowViewsWin::ActivateParentDesktopIfNecessary() { | |
43 // Only switching into Ash from Native is supported. Tearing the user out of | |
44 // Metro mode can only be done by launching a process from Metro mode itself. | |
45 // This is done for launching apps, but not regular activations. | |
46 if (IsRunningInAsh() && | |
47 chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_NATIVE) { | |
48 chrome::ActivateMetroChrome(); | |
49 } | |
50 } | |
51 | |
52 HWND ChromeNativeAppWindowViewsWin::GetNativeAppWindowHWND() const { | 41 HWND ChromeNativeAppWindowViewsWin::GetNativeAppWindowHWND() const { |
53 return views::HWNDForWidget(widget()->GetTopLevelWidget()); | 42 return views::HWNDForWidget(widget()->GetTopLevelWidget()); |
54 } | 43 } |
55 | 44 |
56 bool ChromeNativeAppWindowViewsWin::IsRunningInAsh() { | 45 bool ChromeNativeAppWindowViewsWin::IsRunningInAsh() { |
57 if (!ash::Shell::HasInstance()) | 46 if (!ash::Shell::HasInstance()) |
58 return false; | 47 return false; |
59 | 48 |
60 views::Widget* widget = GetWidget(); | 49 views::Widget* widget = GetWidget(); |
61 chrome::HostDesktopType host_desktop_type = | 50 chrome::HostDesktopType host_desktop_type = |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 views::NonClientFrameView* | 131 views::NonClientFrameView* |
143 ChromeNativeAppWindowViewsWin::CreateStandardDesktopAppFrame() { | 132 ChromeNativeAppWindowViewsWin::CreateStandardDesktopAppFrame() { |
144 glass_frame_view_ = NULL; | 133 glass_frame_view_ = NULL; |
145 if (ui::win::IsAeroGlassEnabled()) { | 134 if (ui::win::IsAeroGlassEnabled()) { |
146 glass_frame_view_ = new GlassAppWindowFrameViewWin(this, widget()); | 135 glass_frame_view_ = new GlassAppWindowFrameViewWin(this, widget()); |
147 return glass_frame_view_; | 136 return glass_frame_view_; |
148 } | 137 } |
149 return ChromeNativeAppWindowViewsAura::CreateStandardDesktopAppFrame(); | 138 return ChromeNativeAppWindowViewsAura::CreateStandardDesktopAppFrame(); |
150 } | 139 } |
151 | 140 |
152 void ChromeNativeAppWindowViewsWin::Show() { | |
153 ActivateParentDesktopIfNecessary(); | |
154 ChromeNativeAppWindowViewsAura::Show(); | |
155 } | |
156 | |
157 void ChromeNativeAppWindowViewsWin::Activate() { | |
158 ActivateParentDesktopIfNecessary(); | |
159 ChromeNativeAppWindowViewsAura::Activate(); | |
160 } | |
161 | |
162 bool ChromeNativeAppWindowViewsWin::CanMinimize() const { | 141 bool ChromeNativeAppWindowViewsWin::CanMinimize() const { |
163 // Resizing on Windows breaks translucency if the window also has shape. | 142 // Resizing on Windows breaks translucency if the window also has shape. |
164 // See http://crbug.com/417947. | 143 // See http://crbug.com/417947. |
165 return ChromeNativeAppWindowViewsAura::CanMinimize() && | 144 return ChromeNativeAppWindowViewsAura::CanMinimize() && |
166 !(WidgetHasHitTestMask() && is_translucent_); | 145 !(WidgetHasHitTestMask() && is_translucent_); |
167 } | 146 } |
OLD | NEW |