Chromium Code Reviews| 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 ash::wm::WmWindowAura::GetAuraWindow(window_state_->window()) |
| 69 ->AddObserver(this); | |
| 68 } | 70 } |
| 69 ~CustomFrameViewAshWindowStateDelegate() override { | 71 ~CustomFrameViewAshWindowStateDelegate() override { |
| 70 if (window_state_) { | 72 if (window_state_) { |
| 71 window_state_->RemoveObserver(this); | 73 window_state_->RemoveObserver(this); |
| 72 window_state_->aura_window()->RemoveObserver(this); | 74 ash::wm::WmWindowAura::GetAuraWindow(window_state_->window()) |
| 75 ->RemoveObserver(this); | |
| 73 } | 76 } |
| 74 } | 77 } |
| 75 private: | 78 private: |
| 76 // Overridden from ash::wm::WindowStateDelegate: | 79 // Overridden from ash::wm::WindowStateDelegate: |
| 77 bool ToggleFullscreen(ash::wm::WindowState* window_state) override { | 80 bool ToggleFullscreen(ash::wm::WindowState* window_state) override { |
| 78 bool enter_fullscreen = !window_state->IsFullscreen(); | 81 bool enter_fullscreen = !window_state->IsFullscreen(); |
| 79 if (enter_fullscreen) { | 82 if (enter_fullscreen) { |
| 80 window_state->aura_window()->SetProperty(aura::client::kShowStateKey, | 83 ash::wm::WmWindowAura::GetAuraWindow(window_state->window()) |
| 81 ui::SHOW_STATE_FULLSCREEN); | 84 ->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 82 } else { | 85 } else { |
| 83 window_state->Restore(); | 86 window_state->Restore(); |
| 84 } | 87 } |
| 85 if (immersive_fullscreen_controller_) { | 88 if (immersive_fullscreen_controller_) { |
| 86 immersive_fullscreen_controller_->SetEnabled( | 89 immersive_fullscreen_controller_->SetEnabled( |
| 87 ash::ImmersiveFullscreenController::WINDOW_TYPE_OTHER, | 90 ash::ImmersiveFullscreenController::WINDOW_TYPE_OTHER, |
| 88 enter_fullscreen); | 91 enter_fullscreen); |
| 89 } | 92 } |
| 90 return true; | 93 return true; |
| 91 } | 94 } |
| 92 // Overridden from aura::WindowObserver: | 95 // Overridden from aura::WindowObserver: |
| 93 void OnWindowDestroying(aura::Window* window) override { | 96 void OnWindowDestroying(aura::Window* window) override { |
| 94 window_state_->RemoveObserver(this); | 97 window_state_->RemoveObserver(this); |
| 95 window_state_->aura_window()->RemoveObserver(this); | 98 ash::wm::WmWindowAura::GetAuraWindow(window_state_->window()) |
|
James Cook
2016/04/26 00:46:43
optional: Add a utility function aura::Window* Get
sky
2016/04/26 02:57:22
Done.
| |
| 99 ->RemoveObserver(this); | |
| 96 window_state_ = NULL; | 100 window_state_ = NULL; |
| 97 } | 101 } |
| 98 // Overridden from ash::wm::WindowStateObserver: | 102 // Overridden from ash::wm::WindowStateObserver: |
| 99 void OnPostWindowStateTypeChange(ash::wm::WindowState* window_state, | 103 void OnPostWindowStateTypeChange(ash::wm::WindowState* window_state, |
| 100 ash::wm::WindowStateType old_type) override { | 104 ash::wm::WindowStateType old_type) override { |
| 101 if (!window_state->IsFullscreen() && | 105 if (!window_state->IsFullscreen() && |
| 102 !window_state->IsMinimized() && | 106 !window_state->IsMinimized() && |
| 103 immersive_fullscreen_controller_.get() && | 107 immersive_fullscreen_controller_.get() && |
| 104 immersive_fullscreen_controller_->IsEnabled()) { | 108 immersive_fullscreen_controller_->IsEnabled()) { |
| 105 immersive_fullscreen_controller_->SetEnabled( | 109 immersive_fullscreen_controller_->SetEnabled( |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 581 FrameCaptionButtonContainerView* CustomFrameViewAsh:: | 585 FrameCaptionButtonContainerView* CustomFrameViewAsh:: |
| 582 GetFrameCaptionButtonContainerViewForTest() { | 586 GetFrameCaptionButtonContainerViewForTest() { |
| 583 return header_view_->caption_button_container(); | 587 return header_view_->caption_button_container(); |
| 584 } | 588 } |
| 585 | 589 |
| 586 int CustomFrameViewAsh::NonClientTopBorderHeight() const { | 590 int CustomFrameViewAsh::NonClientTopBorderHeight() const { |
| 587 return frame_->IsFullscreen() ? 0 : header_view_->GetPreferredHeight(); | 591 return frame_->IsFullscreen() ? 0 : header_view_->GetPreferredHeight(); |
| 588 } | 592 } |
| 589 | 593 |
| 590 } // namespace ash | 594 } // namespace ash |
| OLD | NEW |