OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_aura.h" | 5 #include "chrome/browser/ui/views/apps/chrome_native_app_window_views_aura.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/ash_constants.h" | 8 #include "ash/ash_constants.h" |
9 #include "ash/frame/custom_frame_view_ash.h" | 9 #include "ash/frame/custom_frame_view_ash.h" |
10 #include "ash/screen_util.h" | 10 #include "ash/screen_util.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 }; | 111 }; |
112 | 112 |
113 } // namespace | 113 } // namespace |
114 | 114 |
115 ChromeNativeAppWindowViewsAura::ChromeNativeAppWindowViewsAura() { | 115 ChromeNativeAppWindowViewsAura::ChromeNativeAppWindowViewsAura() { |
116 } | 116 } |
117 | 117 |
118 ChromeNativeAppWindowViewsAura::~ChromeNativeAppWindowViewsAura() { | 118 ChromeNativeAppWindowViewsAura::~ChromeNativeAppWindowViewsAura() { |
119 } | 119 } |
120 | 120 |
| 121 void ChromeNativeAppWindowViewsAura::InitializeWindow( |
| 122 AppWindow* app_window, |
| 123 const AppWindow::CreateParams& create_params) { |
| 124 ChromeNativeAppWindowViews::InitializeWindow(app_window, create_params); |
| 125 // Restore docked state on ash desktop and ignore it elsewhere. |
| 126 if (create_params.state == ui::SHOW_STATE_DOCKED && |
| 127 chrome::GetHostDesktopTypeForNativeWindow(widget()->GetNativeWindow()) == |
| 128 chrome::HOST_DESKTOP_TYPE_ASH) { |
| 129 widget()->GetNativeWindow()->SetProperty(aura::client::kShowStateKey, |
| 130 create_params.state); |
| 131 } |
| 132 } |
| 133 |
121 void ChromeNativeAppWindowViewsAura::OnBeforeWidgetInit( | 134 void ChromeNativeAppWindowViewsAura::OnBeforeWidgetInit( |
122 const AppWindow::CreateParams& create_params, | 135 const AppWindow::CreateParams& create_params, |
123 views::Widget::InitParams* init_params, | 136 views::Widget::InitParams* init_params, |
124 views::Widget* widget) { | 137 views::Widget* widget) { |
125 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 138 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
126 std::string app_name = web_app::GenerateApplicationNameFromExtensionId( | 139 std::string app_name = web_app::GenerateApplicationNameFromExtensionId( |
127 app_window()->extension_id()); | 140 app_window()->extension_id()); |
128 // Set up a custom WM_CLASS for app windows. This allows task switchers in | 141 // Set up a custom WM_CLASS for app windows. This allows task switchers in |
129 // X11 environments to distinguish them from main browser windows. | 142 // X11 environments to distinguish them from main browser windows. |
130 init_params->wm_class_name = web_app::GetWMClassFromAppName(app_name); | 143 init_params->wm_class_name = web_app::GetWMClassFromAppName(app_name); |
131 init_params->wm_class_class = shell_integration_linux::GetProgramClassName(); | 144 init_params->wm_class_class = shell_integration_linux::GetProgramClassName(); |
132 const char kX11WindowRoleApp[] = "app"; | 145 const char kX11WindowRoleApp[] = "app"; |
133 init_params->wm_role_name = std::string(kX11WindowRoleApp); | 146 init_params->wm_role_name = std::string(kX11WindowRoleApp); |
134 #endif | 147 #endif |
135 | 148 |
136 ChromeNativeAppWindowViews::OnBeforeWidgetInit(create_params, init_params, | 149 ChromeNativeAppWindowViews::OnBeforeWidgetInit(create_params, init_params, |
137 widget); | 150 widget); |
138 | 151 |
139 #if defined(OS_CHROMEOS) | 152 #if defined(OS_CHROMEOS) |
140 if (create_params.is_ime_window) { | 153 if (create_params.is_ime_window) { |
141 // Puts ime windows into ime window container. | 154 // Puts ime windows into ime window container. |
142 init_params->parent = | 155 init_params->parent = |
143 ash::Shell::GetContainer(ash::Shell::GetPrimaryRootWindow(), | 156 ash::Shell::GetContainer(ash::Shell::GetPrimaryRootWindow(), |
144 ash::kShellWindowId_ImeWindowParentContainer); | 157 ash::kShellWindowId_ImeWindowParentContainer); |
145 } | 158 } |
146 #endif | 159 #endif |
147 } | 160 } |
148 | 161 |
149 void ChromeNativeAppWindowViewsAura::OnBeforePanelWidgetInit( | 162 void ChromeNativeAppWindowViewsAura::OnBeforePanelWidgetInit( |
| 163 bool use_default_bounds, |
150 views::Widget::InitParams* init_params, | 164 views::Widget::InitParams* init_params, |
151 views::Widget* widget) { | 165 views::Widget* widget) { |
152 ChromeNativeAppWindowViews::OnBeforePanelWidgetInit(init_params, widget); | 166 ChromeNativeAppWindowViews::OnBeforePanelWidgetInit(use_default_bounds, |
| 167 init_params, |
| 168 widget); |
153 | 169 |
154 if (ash::Shell::HasInstance()) { | 170 if (ash::Shell::HasInstance() && use_default_bounds) { |
155 // Open a new panel on the target root. | 171 // Open a new panel on the target root. |
156 init_params->bounds = ash::ScreenUtil::ConvertRectToScreen( | 172 init_params->bounds = ash::ScreenUtil::ConvertRectToScreen( |
157 ash::Shell::GetTargetRootWindow(), gfx::Rect(GetPreferredSize())); | 173 ash::Shell::GetTargetRootWindow(), gfx::Rect(GetPreferredSize())); |
158 } | 174 } |
159 } | 175 } |
160 | 176 |
161 apps::AppWindowFrameView* | 177 apps::AppWindowFrameView* |
162 ChromeNativeAppWindowViewsAura::CreateNonStandardAppFrame() { | 178 ChromeNativeAppWindowViewsAura::CreateNonStandardAppFrame() { |
163 apps::AppWindowFrameView* frame = | 179 apps::AppWindowFrameView* frame = |
164 ChromeNativeAppWindowViews::CreateNonStandardAppFrame(); | 180 ChromeNativeAppWindowViews::CreateNonStandardAppFrame(); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 if (IsFullscreen()) { | 232 if (IsFullscreen()) { |
217 if (immersive_fullscreen_controller_.get() && | 233 if (immersive_fullscreen_controller_.get() && |
218 immersive_fullscreen_controller_->IsEnabled()) { | 234 immersive_fullscreen_controller_->IsEnabled()) { |
219 // Restore windows which were previously in immersive fullscreen to | 235 // Restore windows which were previously in immersive fullscreen to |
220 // maximized. Restoring the window to a different fullscreen type | 236 // maximized. Restoring the window to a different fullscreen type |
221 // makes for a bad experience. | 237 // makes for a bad experience. |
222 return ui::SHOW_STATE_MAXIMIZED; | 238 return ui::SHOW_STATE_MAXIMIZED; |
223 } | 239 } |
224 return ui::SHOW_STATE_FULLSCREEN; | 240 return ui::SHOW_STATE_FULLSCREEN; |
225 } | 241 } |
| 242 if (widget()->GetNativeWindow()->GetProperty(aura::client::kShowStateKey) == |
| 243 ui::SHOW_STATE_DOCKED) { |
| 244 return ui::SHOW_STATE_DOCKED; |
| 245 } |
226 } | 246 } |
227 // Whitelist states to return so that invalid and transient states | 247 // Whitelist states to return so that invalid and transient states |
228 // are not saved and used to restore windows when they are recreated. | 248 // are not saved and used to restore windows when they are recreated. |
229 switch (restore_state) { | 249 switch (restore_state) { |
230 case ui::SHOW_STATE_NORMAL: | 250 case ui::SHOW_STATE_NORMAL: |
231 case ui::SHOW_STATE_MAXIMIZED: | 251 case ui::SHOW_STATE_MAXIMIZED: |
232 case ui::SHOW_STATE_FULLSCREEN: | 252 case ui::SHOW_STATE_FULLSCREEN: |
233 return restore_state; | 253 return restore_state; |
234 | 254 |
235 case ui::SHOW_STATE_DEFAULT: | 255 case ui::SHOW_STATE_DEFAULT: |
236 case ui::SHOW_STATE_MINIMIZED: | 256 case ui::SHOW_STATE_MINIMIZED: |
237 case ui::SHOW_STATE_INACTIVE: | 257 case ui::SHOW_STATE_INACTIVE: |
| 258 case ui::SHOW_STATE_DOCKED: |
238 case ui::SHOW_STATE_END: | 259 case ui::SHOW_STATE_END: |
239 return ui::SHOW_STATE_NORMAL; | 260 return ui::SHOW_STATE_NORMAL; |
240 } | 261 } |
241 | 262 |
242 return ui::SHOW_STATE_NORMAL; | 263 return ui::SHOW_STATE_NORMAL; |
243 } | 264 } |
244 | 265 |
245 bool ChromeNativeAppWindowViewsAura::IsAlwaysOnTop() const { | 266 bool ChromeNativeAppWindowViewsAura::IsAlwaysOnTop() const { |
246 return app_window()->window_type_is_panel() | 267 return app_window()->window_type_is_panel() |
247 ? ash::wm::GetWindowState(widget()->GetNativeWindow()) | 268 ? ash::wm::GetWindowState(widget()->GetNativeWindow()) |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 ChromeNativeAppWindowViews::UpdateShape(region.Pass()); | 367 ChromeNativeAppWindowViews::UpdateShape(region.Pass()); |
347 | 368 |
348 aura::Window* native_window = widget()->GetNativeWindow(); | 369 aura::Window* native_window = widget()->GetNativeWindow(); |
349 if (shape() && !had_shape) { | 370 if (shape() && !had_shape) { |
350 native_window->SetEventTargeter(scoped_ptr<ui::EventTargeter>( | 371 native_window->SetEventTargeter(scoped_ptr<ui::EventTargeter>( |
351 new ShapedAppWindowTargeter(native_window, this))); | 372 new ShapedAppWindowTargeter(native_window, this))); |
352 } else if (!shape() && had_shape) { | 373 } else if (!shape() && had_shape) { |
353 native_window->SetEventTargeter(scoped_ptr<ui::EventTargeter>()); | 374 native_window->SetEventTargeter(scoped_ptr<ui::EventTargeter>()); |
354 } | 375 } |
355 } | 376 } |
OLD | NEW |