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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 | 401 |
401 void NativeAppWindowViews::SetBounds(const gfx::Rect& bounds) { | 402 void NativeAppWindowViews::SetBounds(const gfx::Rect& bounds) { |
402 GetWidget()->SetBounds(bounds); | 403 GetWidget()->SetBounds(bounds); |
403 } | 404 } |
404 | 405 |
405 void NativeAppWindowViews::FlashFrame(bool flash) { | 406 void NativeAppWindowViews::FlashFrame(bool flash) { |
406 window_->FlashFrame(flash); | 407 window_->FlashFrame(flash); |
407 } | 408 } |
408 | 409 |
409 bool NativeAppWindowViews::IsAlwaysOnTop() const { | 410 bool NativeAppWindowViews::IsAlwaysOnTop() const { |
410 if (!shell_window_->window_type_is_panel()) | 411 if (shell_window_->window_type_is_panel()) { |
411 return false; | |
412 #if defined(USE_ASH) | 412 #if defined(USE_ASH) |
413 return ash::wm::GetWindowState(window_->GetNativeWindow())-> | 413 return ash::wm::GetWindowState(window_->GetNativeWindow())-> |
414 panel_attached(); | 414 panel_attached(); |
415 #else | 415 #else |
416 return true; | 416 return true; |
417 #endif | 417 #endif |
| 418 } else { |
| 419 return window_->IsAlwaysOnTop(); |
| 420 } |
418 } | 421 } |
419 | 422 |
420 gfx::Insets NativeAppWindowViews::GetFrameInsets() const { | 423 gfx::Insets NativeAppWindowViews::GetFrameInsets() const { |
421 if (frameless()) | 424 if (frameless()) |
422 return gfx::Insets(); | 425 return gfx::Insets(); |
423 | 426 |
424 // The pretend client_bounds passed in need to be large enough to ensure that | 427 // The pretend client_bounds passed in need to be large enough to ensure that |
425 // GetWindowBoundsForClientBounds() doesn't decide that it needs more than | 428 // GetWindowBoundsForClientBounds() doesn't decide that it needs more than |
426 // the specified amount of space to fit the window controls in, and return a | 429 // the specified amount of space to fit the window controls in, and return a |
427 // number larger than the real frame insets. Most window controls are smaller | 430 // number larger than the real frame insets. Most window controls are smaller |
428 // than 1000x1000px, so this should be big enough. | 431 // than 1000x1000px, so this should be big enough. |
429 gfx::Rect client_bounds = gfx::Rect(1000, 1000); | 432 gfx::Rect client_bounds = gfx::Rect(1000, 1000); |
430 gfx::Rect window_bounds = | 433 gfx::Rect window_bounds = |
431 window_->non_client_view()->GetWindowBoundsForClientBounds( | 434 window_->non_client_view()->GetWindowBoundsForClientBounds( |
432 client_bounds); | 435 client_bounds); |
433 return window_bounds.InsetsFrom(client_bounds); | 436 return window_bounds.InsetsFrom(client_bounds); |
434 } | 437 } |
435 | 438 |
436 void NativeAppWindowViews::HideWithApp() {} | 439 void NativeAppWindowViews::HideWithApp() {} |
437 void NativeAppWindowViews::ShowWithApp() {} | 440 void NativeAppWindowViews::ShowWithApp() {} |
438 | 441 |
| 442 void NativeAppWindowViews::SetAlwaysOnTop(bool always_on_top) { |
| 443 window_->SetAlwaysOnTop(always_on_top); |
| 444 shell_window_->OnNativeWindowChanged(); |
| 445 } |
| 446 |
439 gfx::NativeView NativeAppWindowViews::GetHostView() const { | 447 gfx::NativeView NativeAppWindowViews::GetHostView() const { |
440 return window_->GetNativeView(); | 448 return window_->GetNativeView(); |
441 } | 449 } |
442 | 450 |
443 gfx::Point NativeAppWindowViews::GetDialogPosition(const gfx::Size& size) { | 451 gfx::Point NativeAppWindowViews::GetDialogPosition(const gfx::Size& size) { |
444 gfx::Size shell_window_size = window_->GetWindowBoundsInScreen().size(); | 452 gfx::Size shell_window_size = window_->GetWindowBoundsInScreen().size(); |
445 return gfx::Point(shell_window_size.width() / 2 - size.width() / 2, | 453 return gfx::Point(shell_window_size.width() / 2 - size.width() / 2, |
446 shell_window_size.height() / 2 - size.height() / 2); | 454 shell_window_size.height() / 2 - size.height() / 2); |
447 } | 455 } |
448 | 456 |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 const content::NativeWebKeyboardEvent& event) { | 792 const content::NativeWebKeyboardEvent& event) { |
785 unhandled_keyboard_event_handler_.HandleKeyboardEvent(event, | 793 unhandled_keyboard_event_handler_.HandleKeyboardEvent(event, |
786 GetFocusManager()); | 794 GetFocusManager()); |
787 } | 795 } |
788 | 796 |
789 void NativeAppWindowViews::RenderViewHostChanged( | 797 void NativeAppWindowViews::RenderViewHostChanged( |
790 content::RenderViewHost* old_host, | 798 content::RenderViewHost* old_host, |
791 content::RenderViewHost* new_host) { | 799 content::RenderViewHost* new_host) { |
792 OnViewWasResized(); | 800 OnViewWasResized(); |
793 } | 801 } |
OLD | NEW |