| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/wm/screen_pinning_controller.h" | 5 #include "ash/wm/screen_pinning_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ash/aura/wm_window_aura.h" | 10 #include "ash/aura/wm_window_aura.h" |
| 11 #include "ash/common/shell_window_ids.h" | 11 #include "ash/common/shell_window_ids.h" |
| 12 #include "ash/common/wm/window_state.h" | 12 #include "ash/common/wm/window_state.h" |
| 13 #include "ash/common/wm_shell_common.h" | 13 #include "ash/common/wm_shell.h" |
| 14 #include "ash/common/wm_window.h" | 14 #include "ash/common/wm_window.h" |
| 15 #include "ash/common/wm_window_observer.h" | 15 #include "ash/common/wm_window_observer.h" |
| 16 #include "ash/display/window_tree_host_manager.h" | 16 #include "ash/display/window_tree_host_manager.h" |
| 17 #include "ash/shell.h" | 17 #include "ash/shell.h" |
| 18 #include "ash/wm/dim_window.h" | 18 #include "ash/wm/dim_window.h" |
| 19 #include "base/auto_reset.h" | 19 #include "base/auto_reset.h" |
| 20 #include "base/logging.h" | 20 #include "base/logging.h" |
| 21 #include "base/stl_util.h" | 21 #include "base/stl_util.h" |
| 22 #include "ui/aura/window_observer.h" | 22 #include "ui/aura/window_observer.h" |
| 23 | 23 |
| 24 namespace ash { | 24 namespace ash { |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 WmWindow* CreateDimWindow(WmWindow* container) { | 27 WmWindow* CreateDimWindow(WmWindow* container) { |
| 28 DimWindow* dim_window = new DimWindow(WmWindowAura::GetAuraWindow(container)); | 28 DimWindow* dim_window = new DimWindow(WmWindowAura::GetAuraWindow(container)); |
| 29 dim_window->SetDimOpacity(1); // Set whole black. | 29 dim_window->SetDimOpacity(1); // Set whole black. |
| 30 WmWindow* result = WmWindowAura::Get(dim_window); | 30 WmWindow* result = WmWindowAura::Get(dim_window); |
| 31 result->SetFullscreen(); | 31 result->SetFullscreen(); |
| 32 result->Show(); | 32 result->Show(); |
| 33 return result; | 33 return result; |
| 34 } | 34 } |
| 35 | 35 |
| 36 // Returns a list of WmWindows corresponding to SystemModalContainers, | 36 // Returns a list of WmWindows corresponding to SystemModalContainers, |
| 37 // except ones whose root is shared with |pinned_window|. | 37 // except ones whose root is shared with |pinned_window|. |
| 38 std::vector<WmWindow*> GetSystemModalWindowsExceptPinned( | 38 std::vector<WmWindow*> GetSystemModalWindowsExceptPinned( |
| 39 WmWindow* pinned_window) { | 39 WmWindow* pinned_window) { |
| 40 WmWindow* pinned_root = pinned_window->GetRootWindow(); | 40 WmWindow* pinned_root = pinned_window->GetRootWindow(); |
| 41 | 41 |
| 42 std::vector<WmWindow*> result; | 42 std::vector<WmWindow*> result; |
| 43 for (WmWindow* system_modal : WmWindowAura::FromAuraWindows( | 43 for (WmWindow* system_modal : |
| 44 ash::Shell::GetContainersFromAllRootWindows( | 44 WmWindowAura::FromAuraWindows(Shell::GetContainersFromAllRootWindows( |
| 45 kShellWindowId_SystemModalContainer, nullptr))) { | 45 kShellWindowId_SystemModalContainer, nullptr))) { |
| 46 if (system_modal->GetRootWindow() == pinned_root) | 46 if (system_modal->GetRootWindow() == pinned_root) |
| 47 continue; | 47 continue; |
| 48 result.push_back(system_modal); | 48 result.push_back(system_modal); |
| 49 } | 49 } |
| 50 return result; | 50 return result; |
| 51 } | 51 } |
| 52 | 52 |
| 53 void AddObserverToChildren(WmWindow* container, | 53 void AddObserverToChildren(WmWindow* container, |
| 54 aura::WindowObserver* observer) { | 54 aura::WindowObserver* observer) { |
| 55 for (WmWindow* child : container->GetChildren()) { | 55 for (WmWindow* child : container->GetChildren()) { |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 void OnWindowDestroying(aura::Window* window) override { | 173 void OnWindowDestroying(aura::Window* window) override { |
| 174 controller_->OnDimWindowDestroying(WmWindowAura::Get(window)); | 174 controller_->OnDimWindowDestroying(WmWindowAura::Get(window)); |
| 175 } | 175 } |
| 176 | 176 |
| 177 private: | 177 private: |
| 178 ScreenPinningController* controller_; | 178 ScreenPinningController* controller_; |
| 179 DISALLOW_COPY_AND_ASSIGN(DimWindowObserver); | 179 DISALLOW_COPY_AND_ASSIGN(DimWindowObserver); |
| 180 }; | 180 }; |
| 181 | 181 |
| 182 ScreenPinningController::ScreenPinningController( | 182 ScreenPinningController::ScreenPinningController( |
| 183 WmShellCommon* wm_shell_common, | |
| 184 WindowTreeHostManager* window_tree_host_manager) | 183 WindowTreeHostManager* window_tree_host_manager) |
| 185 : wm_shell_common_(wm_shell_common), | 184 : window_tree_host_manager_(window_tree_host_manager), |
| 186 window_tree_host_manager_(window_tree_host_manager), | |
| 187 pinned_container_window_observer_( | 185 pinned_container_window_observer_( |
| 188 new PinnedContainerWindowObserver(this)), | 186 new PinnedContainerWindowObserver(this)), |
| 189 pinned_container_child_window_observer_( | 187 pinned_container_child_window_observer_( |
| 190 new PinnedContainerChildWindowObserver(this)), | 188 new PinnedContainerChildWindowObserver(this)), |
| 191 system_modal_container_window_observer_( | 189 system_modal_container_window_observer_( |
| 192 new SystemModalContainerWindowObserver(this)), | 190 new SystemModalContainerWindowObserver(this)), |
| 193 system_modal_container_child_window_observer_( | 191 system_modal_container_child_window_observer_( |
| 194 new SystemModalContainerChildWindowObserver(this)), | 192 new SystemModalContainerChildWindowObserver(this)), |
| 195 dim_window_observer_(new DimWindowObserver(this)) { | 193 dim_window_observer_(new DimWindowObserver(this)) { |
| 196 window_tree_host_manager_->AddObserver(this); | 194 window_tree_host_manager_->AddObserver(this); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 for (WmWindow* dim_window : std::vector<WmWindow*>(dim_windows_)) { | 272 for (WmWindow* dim_window : std::vector<WmWindow*>(dim_windows_)) { |
| 275 delete WmWindowAura::GetAuraWindow(dim_window); | 273 delete WmWindowAura::GetAuraWindow(dim_window); |
| 276 } | 274 } |
| 277 DCHECK(dim_windows_.empty()); | 275 DCHECK(dim_windows_.empty()); |
| 278 delete WmWindowAura::GetAuraWindow(background_window_); | 276 delete WmWindowAura::GetAuraWindow(background_window_); |
| 279 background_window_ = nullptr; | 277 background_window_ = nullptr; |
| 280 | 278 |
| 281 pinned_window_ = nullptr; | 279 pinned_window_ = nullptr; |
| 282 } | 280 } |
| 283 | 281 |
| 284 wm_shell_common_->NotifyPinnedStateChanged(pinned_window); | 282 WmShell::Get()->NotifyPinnedStateChanged(pinned_window); |
| 285 } | 283 } |
| 286 | 284 |
| 287 void ScreenPinningController::OnWindowAddedToPinnedContainer( | 285 void ScreenPinningController::OnWindowAddedToPinnedContainer( |
| 288 WmWindow* new_window) { | 286 WmWindow* new_window) { |
| 289 KeepPinnedWindowOnTop(); | 287 KeepPinnedWindowOnTop(); |
| 290 WmWindowAura::GetAuraWindow(new_window) | 288 WmWindowAura::GetAuraWindow(new_window) |
| 291 ->AddObserver(pinned_container_child_window_observer_.get()); | 289 ->AddObserver(pinned_container_child_window_observer_.get()); |
| 292 } | 290 } |
| 293 | 291 |
| 294 void ScreenPinningController::OnWillRemoveWindowFromPinnedContainer( | 292 void ScreenPinningController::OnWillRemoveWindowFromPinnedContainer( |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 base::AutoReset<bool> auto_reset(&in_restacking_, true); | 392 base::AutoReset<bool> auto_reset(&in_restacking_, true); |
| 395 for (WmWindow* dim_window : dim_windows_) { | 393 for (WmWindow* dim_window : dim_windows_) { |
| 396 if (dim_window->GetParent() == container) { | 394 if (dim_window->GetParent() == container) { |
| 397 container->StackChildAtBottom(dim_window); | 395 container->StackChildAtBottom(dim_window); |
| 398 break; | 396 break; |
| 399 } | 397 } |
| 400 } | 398 } |
| 401 } | 399 } |
| 402 | 400 |
| 403 } // namespace ash | 401 } // namespace ash |
| OLD | NEW |