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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 FrameCaptionButtonContainerView* | 382 FrameCaptionButtonContainerView* |
381 CustomFrameViewAsh::GetFrameCaptionButtonContainerViewForTest() { | 383 CustomFrameViewAsh::GetFrameCaptionButtonContainerViewForTest() { |
382 return header_view_->caption_button_container(); | 384 return header_view_->caption_button_container(); |
383 } | 385 } |
384 | 386 |
385 int CustomFrameViewAsh::NonClientTopBorderHeight() const { | 387 int CustomFrameViewAsh::NonClientTopBorderHeight() const { |
386 return frame_->IsFullscreen() ? 0 : header_view_->GetPreferredHeight(); | 388 return frame_->IsFullscreen() ? 0 : header_view_->GetPreferredHeight(); |
387 } | 389 } |
388 | 390 |
389 } // namespace ash | 391 } // namespace ash |
OLD | NEW |