| 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/frame/caption_buttons/frame_caption_button_container_view.h" | 10 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 CustomFrameViewAsh* custom_frame_view, | 46 CustomFrameViewAsh* custom_frame_view, |
| 47 bool enable_immersive) | 47 bool enable_immersive) |
| 48 : window_state_(nullptr) { | 48 : window_state_(nullptr) { |
| 49 // Add a window state observer to exit fullscreen properly in case | 49 // Add a window state observer to exit fullscreen properly in case |
| 50 // fullscreen is exited without going through | 50 // fullscreen is exited without going through |
| 51 // WindowState::ToggleFullscreen(). This is the case when exiting | 51 // WindowState::ToggleFullscreen(). This is the case when exiting |
| 52 // immersive fullscreen via the "Restore" window control. | 52 // immersive fullscreen via the "Restore" window control. |
| 53 // TODO(pkotwicz): This is a hack. Remove ASAP. http://crbug.com/319048 | 53 // TODO(pkotwicz): This is a hack. Remove ASAP. http://crbug.com/319048 |
| 54 window_state_ = window_state; | 54 window_state_ = window_state; |
| 55 window_state_->AddObserver(this); | 55 window_state_->AddObserver(this); |
| 56 window_state_->window()->aura_window()->AddObserver(this); | 56 window_state_->window()->AddObserver(this); |
| 57 | 57 |
| 58 if (!enable_immersive) | 58 if (!enable_immersive) |
| 59 return; | 59 return; |
| 60 | 60 |
| 61 immersive_fullscreen_controller_ = | 61 immersive_fullscreen_controller_ = |
| 62 ShellPort::Get()->CreateImmersiveFullscreenController(); | 62 ShellPort::Get()->CreateImmersiveFullscreenController(); |
| 63 if (immersive_fullscreen_controller_) { | 63 if (immersive_fullscreen_controller_) { |
| 64 custom_frame_view->InitImmersiveFullscreenControllerForView( | 64 custom_frame_view->InitImmersiveFullscreenControllerForView( |
| 65 immersive_fullscreen_controller_.get()); | 65 immersive_fullscreen_controller_.get()); |
| 66 } | 66 } |
| 67 } | 67 } |
| 68 ~CustomFrameViewAshWindowStateDelegate() override { | 68 ~CustomFrameViewAshWindowStateDelegate() override { |
| 69 if (window_state_) { | 69 if (window_state_) { |
| 70 window_state_->RemoveObserver(this); | 70 window_state_->RemoveObserver(this); |
| 71 window_state_->window()->aura_window()->RemoveObserver(this); | 71 window_state_->window()->RemoveObserver(this); |
| 72 } | 72 } |
| 73 } | 73 } |
| 74 | 74 |
| 75 private: | 75 private: |
| 76 // Overridden from wm::WindowStateDelegate: | 76 // Overridden from wm::WindowStateDelegate: |
| 77 bool ToggleFullscreen(wm::WindowState* window_state) override { | 77 bool ToggleFullscreen(wm::WindowState* window_state) override { |
| 78 bool enter_fullscreen = !window_state->IsFullscreen(); | 78 bool enter_fullscreen = !window_state->IsFullscreen(); |
| 79 if (enter_fullscreen) | 79 if (enter_fullscreen) { |
| 80 window_state_->window()->SetShowState(ui::SHOW_STATE_FULLSCREEN); | 80 window_state_->window()->SetProperty(aura::client::kShowStateKey, |
| 81 else | 81 ui::SHOW_STATE_FULLSCREEN); |
| 82 } else { |
| 82 window_state->Restore(); | 83 window_state->Restore(); |
| 84 } |
| 83 if (immersive_fullscreen_controller_) { | 85 if (immersive_fullscreen_controller_) { |
| 84 immersive_fullscreen_controller_->SetEnabled( | 86 immersive_fullscreen_controller_->SetEnabled( |
| 85 ImmersiveFullscreenController::WINDOW_TYPE_OTHER, enter_fullscreen); | 87 ImmersiveFullscreenController::WINDOW_TYPE_OTHER, enter_fullscreen); |
| 86 } | 88 } |
| 87 return true; | 89 return true; |
| 88 } | 90 } |
| 89 // Overridden from aura::WindowObserver: | 91 // Overridden from aura::WindowObserver: |
| 90 void OnWindowDestroying(aura::Window* window) override { | 92 void OnWindowDestroying(aura::Window* window) override { |
| 91 window_state_->RemoveObserver(this); | 93 window_state_->RemoveObserver(this); |
| 92 window->RemoveObserver(this); | 94 window->RemoveObserver(this); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 105 | 107 |
| 106 wm::WindowState* window_state_; | 108 wm::WindowState* window_state_; |
| 107 std::unique_ptr<ImmersiveFullscreenController> | 109 std::unique_ptr<ImmersiveFullscreenController> |
| 108 immersive_fullscreen_controller_; | 110 immersive_fullscreen_controller_; |
| 109 | 111 |
| 110 DISALLOW_COPY_AND_ASSIGN(CustomFrameViewAshWindowStateDelegate); | 112 DISALLOW_COPY_AND_ASSIGN(CustomFrameViewAshWindowStateDelegate); |
| 111 }; | 113 }; |
| 112 | 114 |
| 113 } // namespace | 115 } // namespace |
| 114 | 116 |
| 117 // static |
| 118 bool CustomFrameViewAsh::use_empty_minimum_size_for_test_ = false; |
| 119 |
| 115 /////////////////////////////////////////////////////////////////////////////// | 120 /////////////////////////////////////////////////////////////////////////////// |
| 116 // CustomFrameViewAsh::OverlayView | 121 // CustomFrameViewAsh::OverlayView |
| 117 | 122 |
| 118 // View which takes up the entire widget and contains the HeaderView. HeaderView | 123 // View which takes up the entire widget and contains the HeaderView. HeaderView |
| 119 // is a child of OverlayView to avoid creating a larger texture than necessary | 124 // is a child of OverlayView to avoid creating a larger texture than necessary |
| 120 // when painting the HeaderView to its own layer. | 125 // when painting the HeaderView to its own layer. |
| 121 class CustomFrameViewAsh::OverlayView : public views::View, | 126 class CustomFrameViewAsh::OverlayView : public views::View, |
| 122 public views::ViewTargeterDelegate { | 127 public views::ViewTargeterDelegate { |
| 123 public: | 128 public: |
| 124 explicit OverlayView(HeaderView* header_view); | 129 explicit OverlayView(HeaderView* header_view); |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 WmWindow* frame_window = WmWindow::Get(frame_->GetNativeWindow()); | 317 WmWindow* frame_window = WmWindow::Get(frame_->GetNativeWindow()); |
| 313 frame_window->aura_window()->SetProperty(aura::client::kTopViewInset, | 318 frame_window->aura_window()->SetProperty(aura::client::kTopViewInset, |
| 314 NonClientTopBorderHeight()); | 319 NonClientTopBorderHeight()); |
| 315 } | 320 } |
| 316 | 321 |
| 317 const char* CustomFrameViewAsh::GetClassName() const { | 322 const char* CustomFrameViewAsh::GetClassName() const { |
| 318 return kViewClassName; | 323 return kViewClassName; |
| 319 } | 324 } |
| 320 | 325 |
| 321 gfx::Size CustomFrameViewAsh::GetMinimumSize() const { | 326 gfx::Size CustomFrameViewAsh::GetMinimumSize() const { |
| 327 if (use_empty_minimum_size_for_test_) |
| 328 return gfx::Size(); |
| 329 |
| 322 gfx::Size min_client_view_size(frame_->client_view()->GetMinimumSize()); | 330 gfx::Size min_client_view_size(frame_->client_view()->GetMinimumSize()); |
| 323 return gfx::Size( | 331 return gfx::Size( |
| 324 std::max(header_view_->GetMinimumWidth(), min_client_view_size.width()), | 332 std::max(header_view_->GetMinimumWidth(), min_client_view_size.width()), |
| 325 NonClientTopBorderHeight() + min_client_view_size.height()); | 333 NonClientTopBorderHeight() + min_client_view_size.height()); |
| 326 } | 334 } |
| 327 | 335 |
| 328 gfx::Size CustomFrameViewAsh::GetMaximumSize() const { | 336 gfx::Size CustomFrameViewAsh::GetMaximumSize() const { |
| 329 gfx::Size max_client_size(frame_->client_view()->GetMaximumSize()); | 337 gfx::Size max_client_size(frame_->client_view()->GetMaximumSize()); |
| 330 int width = 0; | 338 int width = 0; |
| 331 int height = 0; | 339 int height = 0; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 FrameCaptionButtonContainerView* | 388 FrameCaptionButtonContainerView* |
| 381 CustomFrameViewAsh::GetFrameCaptionButtonContainerViewForTest() { | 389 CustomFrameViewAsh::GetFrameCaptionButtonContainerViewForTest() { |
| 382 return header_view_->caption_button_container(); | 390 return header_view_->caption_button_container(); |
| 383 } | 391 } |
| 384 | 392 |
| 385 int CustomFrameViewAsh::NonClientTopBorderHeight() const { | 393 int CustomFrameViewAsh::NonClientTopBorderHeight() const { |
| 386 return frame_->IsFullscreen() ? 0 : header_view_->GetPreferredHeight(); | 394 return frame_->IsFullscreen() ? 0 : header_view_->GetPreferredHeight(); |
| 387 } | 395 } |
| 388 | 396 |
| 389 } // namespace ash | 397 } // namespace ash |
| OLD | NEW |