OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/native_app_window_views.h" | 5 #include "chrome/browser/ui/views/apps/native_app_window_views.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/threading/sequenced_worker_pool.h" | 10 #include "base/threading/sequenced_worker_pool.h" |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 std::string app_name = | 162 std::string app_name = |
163 web_app::GenerateApplicationNameFromExtensionId(extension()->id()); | 163 web_app::GenerateApplicationNameFromExtensionId(extension()->id()); |
164 | 164 |
165 views::Widget::InitParams init_params(views::Widget::InitParams::TYPE_WINDOW); | 165 views::Widget::InitParams init_params(views::Widget::InitParams::TYPE_WINDOW); |
166 init_params.delegate = this; | 166 init_params.delegate = this; |
167 init_params.remove_standard_frame = ShouldUseChromeStyleFrame(); | 167 init_params.remove_standard_frame = ShouldUseChromeStyleFrame(); |
168 init_params.use_system_default_icon = true; | 168 init_params.use_system_default_icon = true; |
169 // TODO(erg): Conceptually, these are toplevel windows, but we theoretically | 169 // TODO(erg): Conceptually, these are toplevel windows, but we theoretically |
170 // could plumb context through to here in some cases. | 170 // could plumb context through to here in some cases. |
171 init_params.top_level = true; | 171 init_params.top_level = true; |
| 172 init_params.keep_on_top = create_params.always_on_top; |
172 gfx::Rect window_bounds = create_params.bounds; | 173 gfx::Rect window_bounds = create_params.bounds; |
173 bool position_specified = | 174 bool position_specified = |
174 window_bounds.x() != INT_MIN && window_bounds.y() != INT_MIN; | 175 window_bounds.x() != INT_MIN && window_bounds.y() != INT_MIN; |
175 if (position_specified && !window_bounds.IsEmpty()) | 176 if (position_specified && !window_bounds.IsEmpty()) |
176 init_params.bounds = window_bounds; | 177 init_params.bounds = window_bounds; |
177 | 178 |
178 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 179 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
179 // Set up a custom WM_CLASS for app windows. This allows task switchers in | 180 // Set up a custom WM_CLASS for app windows. This allows task switchers in |
180 // X11 environments to distinguish them from main browser windows. | 181 // X11 environments to distinguish them from main browser windows. |
181 init_params.wm_class_name = web_app::GetWMClassFromAppName(app_name); | 182 init_params.wm_class_name = web_app::GetWMClassFromAppName(app_name); |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 | 404 |
404 void NativeAppWindowViews::SetBounds(const gfx::Rect& bounds) { | 405 void NativeAppWindowViews::SetBounds(const gfx::Rect& bounds) { |
405 GetWidget()->SetBounds(bounds); | 406 GetWidget()->SetBounds(bounds); |
406 } | 407 } |
407 | 408 |
408 void NativeAppWindowViews::FlashFrame(bool flash) { | 409 void NativeAppWindowViews::FlashFrame(bool flash) { |
409 window_->FlashFrame(flash); | 410 window_->FlashFrame(flash); |
410 } | 411 } |
411 | 412 |
412 bool NativeAppWindowViews::IsAlwaysOnTop() const { | 413 bool NativeAppWindowViews::IsAlwaysOnTop() const { |
413 if (!shell_window_->window_type_is_panel()) | 414 if (shell_window_->window_type_is_panel()) { |
414 return false; | |
415 #if defined(USE_ASH) | 415 #if defined(USE_ASH) |
416 return ash::wm::GetWindowState(window_->GetNativeWindow())-> | 416 return ash::wm::GetWindowState(window_->GetNativeWindow())-> |
417 panel_attached(); | 417 panel_attached(); |
418 #else | 418 #else |
419 return true; | 419 return true; |
420 #endif | 420 #endif |
| 421 } else { |
| 422 return window_->IsAlwaysOnTop(); |
| 423 } |
421 } | 424 } |
422 | 425 |
423 gfx::Insets NativeAppWindowViews::GetFrameInsets() const { | 426 gfx::Insets NativeAppWindowViews::GetFrameInsets() const { |
424 if (frameless()) | 427 if (frameless()) |
425 return gfx::Insets(); | 428 return gfx::Insets(); |
426 | 429 |
427 // The pretend client_bounds passed in need to be large enough to ensure that | 430 // The pretend client_bounds passed in need to be large enough to ensure that |
428 // GetWindowBoundsForClientBounds() doesn't decide that it needs more than | 431 // GetWindowBoundsForClientBounds() doesn't decide that it needs more than |
429 // the specified amount of space to fit the window controls in, and return a | 432 // the specified amount of space to fit the window controls in, and return a |
430 // number larger than the real frame insets. Most window controls are smaller | 433 // number larger than the real frame insets. Most window controls are smaller |
431 // than 1000x1000px, so this should be big enough. | 434 // than 1000x1000px, so this should be big enough. |
432 gfx::Rect client_bounds = gfx::Rect(1000, 1000); | 435 gfx::Rect client_bounds = gfx::Rect(1000, 1000); |
433 gfx::Rect window_bounds = | 436 gfx::Rect window_bounds = |
434 window_->non_client_view()->GetWindowBoundsForClientBounds( | 437 window_->non_client_view()->GetWindowBoundsForClientBounds( |
435 client_bounds); | 438 client_bounds); |
436 return window_bounds.InsetsFrom(client_bounds); | 439 return window_bounds.InsetsFrom(client_bounds); |
437 } | 440 } |
438 | 441 |
439 bool NativeAppWindowViews::IsVisible() const { | 442 bool NativeAppWindowViews::IsVisible() const { |
440 return window_->IsVisible(); | 443 return window_->IsVisible(); |
441 } | 444 } |
442 | 445 |
443 void NativeAppWindowViews::HideWithApp() {} | 446 void NativeAppWindowViews::HideWithApp() {} |
444 void NativeAppWindowViews::ShowWithApp() {} | 447 void NativeAppWindowViews::ShowWithApp() {} |
445 | 448 |
| 449 void NativeAppWindowViews::SetAlwaysOnTop(bool always_on_top) { |
| 450 window_->SetAlwaysOnTop(always_on_top); |
| 451 shell_window_->OnNativeWindowChanged(); |
| 452 } |
| 453 |
446 gfx::NativeView NativeAppWindowViews::GetHostView() const { | 454 gfx::NativeView NativeAppWindowViews::GetHostView() const { |
447 return window_->GetNativeView(); | 455 return window_->GetNativeView(); |
448 } | 456 } |
449 | 457 |
450 gfx::Point NativeAppWindowViews::GetDialogPosition(const gfx::Size& size) { | 458 gfx::Point NativeAppWindowViews::GetDialogPosition(const gfx::Size& size) { |
451 gfx::Size shell_window_size = window_->GetWindowBoundsInScreen().size(); | 459 gfx::Size shell_window_size = window_->GetWindowBoundsInScreen().size(); |
452 return gfx::Point(shell_window_size.width() / 2 - size.width() / 2, | 460 return gfx::Point(shell_window_size.width() / 2 - size.width() / 2, |
453 shell_window_size.height() / 2 - size.height() / 2); | 461 shell_window_size.height() / 2 - size.height() / 2); |
454 } | 462 } |
455 | 463 |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
791 const content::NativeWebKeyboardEvent& event) { | 799 const content::NativeWebKeyboardEvent& event) { |
792 unhandled_keyboard_event_handler_.HandleKeyboardEvent(event, | 800 unhandled_keyboard_event_handler_.HandleKeyboardEvent(event, |
793 GetFocusManager()); | 801 GetFocusManager()); |
794 } | 802 } |
795 | 803 |
796 void NativeAppWindowViews::RenderViewHostChanged( | 804 void NativeAppWindowViews::RenderViewHostChanged( |
797 content::RenderViewHost* old_host, | 805 content::RenderViewHost* old_host, |
798 content::RenderViewHost* new_host) { | 806 content::RenderViewHost* new_host) { |
799 OnViewWasResized(); | 807 OnViewWasResized(); |
800 } | 808 } |
OLD | NEW |