| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/frame/custom_frame_view_ash.h" | 5 #include "ash/frame/custom_frame_view_ash.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
| 11 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h" | 11 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h" |
| 12 #include "ash/frame/default_header_painter.h" | 12 #include "ash/frame/default_header_painter.h" |
| 13 #include "ash/frame/frame_border_hit_test_controller.h" | 13 #include "ash/frame/frame_border_hit_test_controller.h" |
| 14 #include "ash/frame/header_painter.h" | 14 #include "ash/frame/header_painter.h" |
| 15 #include "ash/session/session_state_delegate.h" | 15 #include "ash/session/session_state_delegate.h" |
| 16 #include "ash/shell.h" | 16 #include "ash/shell.h" |
| 17 #include "ash/shell_observer.h" | 17 #include "ash/shell_observer.h" |
| 18 #include "ash/wm/aura/wm_window_aura.h" |
| 18 #include "ash/wm/immersive_fullscreen_controller.h" | 19 #include "ash/wm/immersive_fullscreen_controller.h" |
| 19 #include "ash/wm/window_state.h" | 20 #include "ash/wm/window_state.h" |
| 20 #include "ash/wm/window_state_aura.h" | 21 #include "ash/wm/window_state_aura.h" |
| 21 #include "ash/wm/window_state_delegate.h" | 22 #include "ash/wm/window_state_delegate.h" |
| 22 #include "ash/wm/window_state_observer.h" | 23 #include "ash/wm/window_state_observer.h" |
| 23 #include "base/command_line.h" | 24 #include "base/command_line.h" |
| 24 #include "ui/aura/client/aura_constants.h" | 25 #include "ui/aura/client/aura_constants.h" |
| 25 #include "ui/aura/window.h" | 26 #include "ui/aura/window.h" |
| 26 #include "ui/aura/window_observer.h" | 27 #include "ui/aura/window_observer.h" |
| 27 #include "ui/gfx/canvas.h" | 28 #include "ui/gfx/canvas.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 57 custom_frame_view->InitImmersiveFullscreenControllerForView( | 58 custom_frame_view->InitImmersiveFullscreenControllerForView( |
| 58 immersive_fullscreen_controller_.get()); | 59 immersive_fullscreen_controller_.get()); |
| 59 | 60 |
| 60 // Add a window state observer to exit fullscreen properly in case | 61 // Add a window state observer to exit fullscreen properly in case |
| 61 // fullscreen is exited without going through | 62 // fullscreen is exited without going through |
| 62 // WindowState::ToggleFullscreen(). This is the case when exiting | 63 // WindowState::ToggleFullscreen(). This is the case when exiting |
| 63 // immersive fullscreen via the "Restore" window control. | 64 // immersive fullscreen via the "Restore" window control. |
| 64 // TODO(pkotwicz): This is a hack. Remove ASAP. http://crbug.com/319048 | 65 // TODO(pkotwicz): This is a hack. Remove ASAP. http://crbug.com/319048 |
| 65 window_state_ = window_state; | 66 window_state_ = window_state; |
| 66 window_state_->AddObserver(this); | 67 window_state_->AddObserver(this); |
| 67 window_state_->aura_window()->AddObserver(this); | 68 GetAuraWindow()->AddObserver(this); |
| 68 } | 69 } |
| 69 ~CustomFrameViewAshWindowStateDelegate() override { | 70 ~CustomFrameViewAshWindowStateDelegate() override { |
| 70 if (window_state_) { | 71 if (window_state_) { |
| 71 window_state_->RemoveObserver(this); | 72 window_state_->RemoveObserver(this); |
| 72 window_state_->aura_window()->RemoveObserver(this); | 73 GetAuraWindow()->RemoveObserver(this); |
| 73 } | 74 } |
| 74 } | 75 } |
| 75 private: | 76 private: |
| 77 aura::Window* GetAuraWindow() { |
| 78 return ash::wm::WmWindowAura::GetAuraWindow(window_state_->window()); |
| 79 } |
| 80 |
| 76 // Overridden from ash::wm::WindowStateDelegate: | 81 // Overridden from ash::wm::WindowStateDelegate: |
| 77 bool ToggleFullscreen(ash::wm::WindowState* window_state) override { | 82 bool ToggleFullscreen(ash::wm::WindowState* window_state) override { |
| 78 bool enter_fullscreen = !window_state->IsFullscreen(); | 83 bool enter_fullscreen = !window_state->IsFullscreen(); |
| 79 if (enter_fullscreen) { | 84 if (enter_fullscreen) { |
| 80 window_state->aura_window()->SetProperty(aura::client::kShowStateKey, | 85 GetAuraWindow()->SetProperty(aura::client::kShowStateKey, |
| 81 ui::SHOW_STATE_FULLSCREEN); | 86 ui::SHOW_STATE_FULLSCREEN); |
| 82 } else { | 87 } else { |
| 83 window_state->Restore(); | 88 window_state->Restore(); |
| 84 } | 89 } |
| 85 if (immersive_fullscreen_controller_) { | 90 if (immersive_fullscreen_controller_) { |
| 86 immersive_fullscreen_controller_->SetEnabled( | 91 immersive_fullscreen_controller_->SetEnabled( |
| 87 ash::ImmersiveFullscreenController::WINDOW_TYPE_OTHER, | 92 ash::ImmersiveFullscreenController::WINDOW_TYPE_OTHER, |
| 88 enter_fullscreen); | 93 enter_fullscreen); |
| 89 } | 94 } |
| 90 return true; | 95 return true; |
| 91 } | 96 } |
| 92 // Overridden from aura::WindowObserver: | 97 // Overridden from aura::WindowObserver: |
| 93 void OnWindowDestroying(aura::Window* window) override { | 98 void OnWindowDestroying(aura::Window* window) override { |
| 94 window_state_->RemoveObserver(this); | 99 window_state_->RemoveObserver(this); |
| 95 window_state_->aura_window()->RemoveObserver(this); | 100 GetAuraWindow()->RemoveObserver(this); |
| 96 window_state_ = NULL; | 101 window_state_ = NULL; |
| 97 } | 102 } |
| 98 // Overridden from ash::wm::WindowStateObserver: | 103 // Overridden from ash::wm::WindowStateObserver: |
| 99 void OnPostWindowStateTypeChange(ash::wm::WindowState* window_state, | 104 void OnPostWindowStateTypeChange(ash::wm::WindowState* window_state, |
| 100 ash::wm::WindowStateType old_type) override { | 105 ash::wm::WindowStateType old_type) override { |
| 101 if (!window_state->IsFullscreen() && | 106 if (!window_state->IsFullscreen() && |
| 102 !window_state->IsMinimized() && | 107 !window_state->IsMinimized() && |
| 103 immersive_fullscreen_controller_.get() && | 108 immersive_fullscreen_controller_.get() && |
| 104 immersive_fullscreen_controller_->IsEnabled()) { | 109 immersive_fullscreen_controller_->IsEnabled()) { |
| 105 immersive_fullscreen_controller_->SetEnabled( | 110 immersive_fullscreen_controller_->SetEnabled( |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 FrameCaptionButtonContainerView* CustomFrameViewAsh:: | 586 FrameCaptionButtonContainerView* CustomFrameViewAsh:: |
| 582 GetFrameCaptionButtonContainerViewForTest() { | 587 GetFrameCaptionButtonContainerViewForTest() { |
| 583 return header_view_->caption_button_container(); | 588 return header_view_->caption_button_container(); |
| 584 } | 589 } |
| 585 | 590 |
| 586 int CustomFrameViewAsh::NonClientTopBorderHeight() const { | 591 int CustomFrameViewAsh::NonClientTopBorderHeight() const { |
| 587 return frame_->IsFullscreen() ? 0 : header_view_->GetPreferredHeight(); | 592 return frame_->IsFullscreen() ? 0 : header_view_->GetPreferredHeight(); |
| 588 } | 593 } |
| 589 | 594 |
| 590 } // namespace ash | 595 } // namespace ash |
| OLD | NEW |