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" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 void ChromeNativeAppWindowViewsWin::EnsureCaptionStyleSet() { | 68 void ChromeNativeAppWindowViewsWin::EnsureCaptionStyleSet() { |
69 // Windows seems to have issues maximizing windows without WS_CAPTION. | 69 // Windows seems to have issues maximizing windows without WS_CAPTION. |
70 // The default views / Aura implementation will remove this if we are using | 70 // The default views / Aura implementation will remove this if we are using |
71 // frameless or colored windows, so we put it back here. | 71 // frameless or colored windows, so we put it back here. |
72 HWND hwnd = GetNativeAppWindowHWND(); | 72 HWND hwnd = GetNativeAppWindowHWND(); |
73 int current_style = ::GetWindowLong(hwnd, GWL_STYLE); | 73 int current_style = ::GetWindowLong(hwnd, GWL_STYLE); |
74 ::SetWindowLong(hwnd, GWL_STYLE, current_style | WS_CAPTION); | 74 ::SetWindowLong(hwnd, GWL_STYLE, current_style | WS_CAPTION); |
75 } | 75 } |
76 | 76 |
77 void ChromeNativeAppWindowViewsWin::OnBeforeWidgetInit( | 77 void ChromeNativeAppWindowViewsWin::OnBeforeWidgetInit( |
| 78 const extensions::AppWindow::CreateParams& create_params, |
78 views::Widget::InitParams* init_params, | 79 views::Widget::InitParams* init_params, |
79 views::Widget* widget) { | 80 views::Widget* widget) { |
| 81 ChromeNativeAppWindowViewsAura::OnBeforeWidgetInit(create_params, init_params, |
| 82 widget); |
| 83 |
80 content::BrowserContext* browser_context = app_window()->browser_context(); | 84 content::BrowserContext* browser_context = app_window()->browser_context(); |
81 std::string extension_id = app_window()->extension_id(); | 85 std::string extension_id = app_window()->extension_id(); |
82 // If an app has any existing windows, ensure new ones are created on the | 86 // If an app has any existing windows, ensure new ones are created on the |
83 // same desktop. | 87 // same desktop. |
84 extensions::AppWindow* any_existing_window = | 88 extensions::AppWindow* any_existing_window = |
85 extensions::AppWindowRegistry::Get(browser_context) | 89 extensions::AppWindowRegistry::Get(browser_context) |
86 ->GetCurrentAppWindowForApp(extension_id); | 90 ->GetCurrentAppWindowForApp(extension_id); |
87 chrome::HostDesktopType desktop_type; | 91 chrome::HostDesktopType desktop_type; |
88 if (any_existing_window) { | 92 if (any_existing_window) { |
89 desktop_type = chrome::GetHostDesktopTypeForNativeWindow( | 93 desktop_type = chrome::GetHostDesktopTypeForNativeWindow( |
(...skipping 13 matching lines...) Expand all Loading... |
103 init_params->context = ash::Shell::GetPrimaryRootWindow(); | 107 init_params->context = ash::Shell::GetPrimaryRootWindow(); |
104 else | 108 else |
105 init_params->native_widget = new AppWindowDesktopNativeWidgetAuraWin(this); | 109 init_params->native_widget = new AppWindowDesktopNativeWidgetAuraWin(this); |
106 | 110 |
107 is_translucent_ = | 111 is_translucent_ = |
108 init_params->opacity == views::Widget::InitParams::TRANSLUCENT_WINDOW; | 112 init_params->opacity == views::Widget::InitParams::TRANSLUCENT_WINDOW; |
109 } | 113 } |
110 | 114 |
111 void ChromeNativeAppWindowViewsWin::InitializeDefaultWindow( | 115 void ChromeNativeAppWindowViewsWin::InitializeDefaultWindow( |
112 const extensions::AppWindow::CreateParams& create_params) { | 116 const extensions::AppWindow::CreateParams& create_params) { |
113 ChromeNativeAppWindowViews::InitializeDefaultWindow(create_params); | 117 ChromeNativeAppWindowViewsAura::InitializeDefaultWindow(create_params); |
114 | 118 |
115 // Remaining initialization is for Windows shell integration, which doesn't | 119 // Remaining initialization is for Windows shell integration, which doesn't |
116 // apply to app windows in Ash. | 120 // apply to app windows in Ash. |
117 if (IsRunningInAsh()) | 121 if (IsRunningInAsh()) |
118 return; | 122 return; |
119 | 123 |
120 const extensions::Extension* extension = app_window()->GetExtension(); | 124 const extensions::Extension* extension = app_window()->GetExtension(); |
121 if (!extension) | 125 if (!extension) |
122 return; | 126 return; |
123 | 127 |
(...skipping 14 matching lines...) Expand all Loading... |
138 UpdateShelfMenu(); | 142 UpdateShelfMenu(); |
139 } | 143 } |
140 | 144 |
141 views::NonClientFrameView* | 145 views::NonClientFrameView* |
142 ChromeNativeAppWindowViewsWin::CreateStandardDesktopAppFrame() { | 146 ChromeNativeAppWindowViewsWin::CreateStandardDesktopAppFrame() { |
143 glass_frame_view_ = NULL; | 147 glass_frame_view_ = NULL; |
144 if (ui::win::IsAeroGlassEnabled()) { | 148 if (ui::win::IsAeroGlassEnabled()) { |
145 glass_frame_view_ = new GlassAppWindowFrameViewWin(this, widget()); | 149 glass_frame_view_ = new GlassAppWindowFrameViewWin(this, widget()); |
146 return glass_frame_view_; | 150 return glass_frame_view_; |
147 } | 151 } |
148 return ChromeNativeAppWindowViews::CreateStandardDesktopAppFrame(); | 152 return ChromeNativeAppWindowViewsAura::CreateStandardDesktopAppFrame(); |
149 } | 153 } |
150 | 154 |
151 void ChromeNativeAppWindowViewsWin::Show() { | 155 void ChromeNativeAppWindowViewsWin::Show() { |
152 ActivateParentDesktopIfNecessary(); | 156 ActivateParentDesktopIfNecessary(); |
153 ChromeNativeAppWindowViews::Show(); | 157 ChromeNativeAppWindowViewsAura::Show(); |
154 } | 158 } |
155 | 159 |
156 void ChromeNativeAppWindowViewsWin::Activate() { | 160 void ChromeNativeAppWindowViewsWin::Activate() { |
157 ActivateParentDesktopIfNecessary(); | 161 ActivateParentDesktopIfNecessary(); |
158 ChromeNativeAppWindowViews::Activate(); | 162 ChromeNativeAppWindowViewsAura::Activate(); |
159 } | 163 } |
160 | 164 |
161 bool ChromeNativeAppWindowViewsWin::CanMinimize() const { | 165 bool ChromeNativeAppWindowViewsWin::CanMinimize() const { |
162 // Resizing on Windows breaks translucency if the window also has shape. | 166 // Resizing on Windows breaks translucency if the window also has shape. |
163 // See http://crbug.com/417947. | 167 // See http://crbug.com/417947. |
164 return ChromeNativeAppWindowViews::CanMinimize() && | 168 return ChromeNativeAppWindowViewsAura::CanMinimize() && |
165 !(WidgetHasHitTestMask() && is_translucent_); | 169 !(WidgetHasHitTestMask() && is_translucent_); |
166 } | 170 } |
167 | 171 |
168 void ChromeNativeAppWindowViewsWin::UpdateShelfMenu() { | 172 void ChromeNativeAppWindowViewsWin::UpdateShelfMenu() { |
169 if (!JumpListUpdater::IsEnabled() || IsRunningInAsh()) | 173 if (!JumpListUpdater::IsEnabled() || IsRunningInAsh()) |
170 return; | 174 return; |
171 | 175 |
172 // Currently the only option is related to ephemeral apps, so avoid updating | 176 // Currently the only option is related to ephemeral apps, so avoid updating |
173 // the app's jump list when the feature is not enabled. | 177 // the app's jump list when the feature is not enabled. |
174 if (!EphemeralAppLauncher::IsFeatureEnabled()) | 178 if (!EphemeralAppLauncher::IsFeatureEnabled()) |
(...skipping 27 matching lines...) Expand all Loading... |
202 switches::kInstallEphemeralAppFromWebstore, extension->id()); | 206 switches::kInstallEphemeralAppFromWebstore, extension->id()); |
203 | 207 |
204 ShellLinkItemList items; | 208 ShellLinkItemList items; |
205 items.push_back(link); | 209 items.push_back(link); |
206 jumplist_updater.AddTasks(items); | 210 jumplist_updater.AddTasks(items); |
207 } | 211 } |
208 | 212 |
209 // Note that an empty jumplist must still be committed to clear all items. | 213 // Note that an empty jumplist must still be committed to clear all items. |
210 jumplist_updater.CommitUpdate(); | 214 jumplist_updater.CommitUpdate(); |
211 } | 215 } |
OLD | NEW |