| 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 "services/ui/ws/modal_window_controller.h" | 5 #include "services/ui/ws/modal_window_controller.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "services/ui/ws/event_dispatcher.h" | 9 #include "services/ui/ws/event_dispatcher.h" |
| 10 #include "services/ui/ws/server_window.h" | 10 #include "services/ui/ws/server_window.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 for (auto it = system_modal_windows_.begin(); | 41 for (auto it = system_modal_windows_.begin(); |
| 42 it != system_modal_windows_.end(); it++) { | 42 it != system_modal_windows_.end(); it++) { |
| 43 (*it)->RemoveObserver(this); | 43 (*it)->RemoveObserver(this); |
| 44 } | 44 } |
| 45 } | 45 } |
| 46 | 46 |
| 47 void ModalWindowController::AddSystemModalWindow(ServerWindow* window) { | 47 void ModalWindowController::AddSystemModalWindow(ServerWindow* window) { |
| 48 DCHECK(window); | 48 DCHECK(window); |
| 49 DCHECK(!base::ContainsValue(system_modal_windows_, window)); | 49 DCHECK(!base::ContainsValue(system_modal_windows_, window)); |
| 50 | 50 |
| 51 window->SetModal(); | 51 window->SetModal(ui::MODAL_TYPE_SYSTEM); |
| 52 system_modal_windows_.push_back(window); | 52 system_modal_windows_.push_back(window); |
| 53 window_drawn_trackers_.insert(make_pair( | 53 window_drawn_trackers_.insert(make_pair( |
| 54 window, base::MakeUnique<ServerWindowDrawnTracker>(window, this))); | 54 window, base::MakeUnique<ServerWindowDrawnTracker>(window, this))); |
| 55 window->AddObserver(this); | 55 window->AddObserver(this); |
| 56 | 56 |
| 57 event_dispatcher_->ReleaseCaptureBlockedByModalWindow(window); | 57 event_dispatcher_->ReleaseCaptureBlockedByModalWindow(window); |
| 58 } | 58 } |
| 59 | 59 |
| 60 bool ModalWindowController::IsWindowBlockedBy( | 60 bool ModalWindowController::IsWindowBlockedBy( |
| 61 const ServerWindow* window, | 61 const ServerWindow* window, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 73 return true; | 73 return true; |
| 74 } | 74 } |
| 75 | 75 |
| 76 bool ModalWindowController::IsWindowBlocked(const ServerWindow* window) const { | 76 bool ModalWindowController::IsWindowBlocked(const ServerWindow* window) const { |
| 77 DCHECK(window); | 77 DCHECK(window); |
| 78 return GetActiveSystemModalWindow() || GetModalChildForWindowAncestor(window); | 78 return GetActiveSystemModalWindow() || GetModalChildForWindowAncestor(window); |
| 79 } | 79 } |
| 80 | 80 |
| 81 const ServerWindow* ModalWindowController::GetTargetForWindow( | 81 const ServerWindow* ModalWindowController::GetTargetForWindow( |
| 82 const ServerWindow* window) const { | 82 const ServerWindow* window) const { |
| 83 // TODO(moshayedi): crbug.com/697127. Handle windows which are modal to |
| 84 // children of their transient parent. |
| 83 ServerWindow* system_modal_window = GetActiveSystemModalWindow(); | 85 ServerWindow* system_modal_window = GetActiveSystemModalWindow(); |
| 84 if (system_modal_window) | 86 if (system_modal_window) |
| 85 return system_modal_window; | 87 return system_modal_window; |
| 86 return window ? GetWindowModalTargetForWindow(window) : nullptr; | 88 return window ? GetWindowModalTargetForWindow(window) : nullptr; |
| 87 } | 89 } |
| 88 | 90 |
| 89 ServerWindow* ModalWindowController::GetActiveSystemModalWindow() const { | 91 ServerWindow* ModalWindowController::GetActiveSystemModalWindow() const { |
| 90 for (auto it = system_modal_windows_.rbegin(); | 92 for (auto it = system_modal_windows_.rbegin(); |
| 91 it != system_modal_windows_.rend(); it++) { | 93 it != system_modal_windows_.rend(); it++) { |
| 92 ServerWindow* modal = *it; | 94 ServerWindow* modal = *it; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 114 // Move the most recently shown window to the end of the list. | 116 // Move the most recently shown window to the end of the list. |
| 115 auto it = std::find(system_modal_windows_.begin(), | 117 auto it = std::find(system_modal_windows_.begin(), |
| 116 system_modal_windows_.end(), window); | 118 system_modal_windows_.end(), window); |
| 117 DCHECK(it != system_modal_windows_.end()); | 119 DCHECK(it != system_modal_windows_.end()); |
| 118 system_modal_windows_.splice(system_modal_windows_.end(), | 120 system_modal_windows_.splice(system_modal_windows_.end(), |
| 119 system_modal_windows_, it); | 121 system_modal_windows_, it); |
| 120 } | 122 } |
| 121 | 123 |
| 122 } // namespace ws | 124 } // namespace ws |
| 123 } // namespace ui | 125 } // namespace ui |
| OLD | NEW |