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/wm/system_modal_container_layout_manager.h" | 5 #include "ash/wm/system_modal_container_layout_manager.h" |
6 | 6 |
7 #include "ash/session_state_delegate.h" | 7 #include "ash/session_state_delegate.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
10 #include "ash/wm/system_modal_container_event_filter.h" | 10 #include "ash/wm/system_modal_container_event_filter.h" |
11 #include "ash/wm/window_animations.h" | 11 #include "ash/wm/window_animations.h" |
12 #include "ash/wm/window_util.h" | 12 #include "ash/wm/window_util.h" |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "ui/aura/client/aura_constants.h" | 14 #include "ui/aura/client/aura_constants.h" |
15 #include "ui/aura/client/capture_client.h" | 15 #include "ui/aura/client/capture_client.h" |
16 #include "ui/aura/window.h" | 16 #include "ui/aura/window.h" |
17 #include "ui/aura/window_event_dispatcher.h" | 17 #include "ui/aura/window_event_dispatcher.h" |
18 #include "ui/base/ui_base_switches_util.h" | 18 #include "ui/base/ui_base_switches_util.h" |
19 #include "ui/compositor/layer.h" | 19 #include "ui/compositor/layer.h" |
20 #include "ui/compositor/layer_animator.h" | 20 #include "ui/compositor/layer_animator.h" |
21 #include "ui/compositor/scoped_layer_animation_settings.h" | 21 #include "ui/compositor/scoped_layer_animation_settings.h" |
22 #include "ui/events/event.h" | 22 #include "ui/events/event.h" |
23 #include "ui/gfx/screen.h" | 23 #include "ui/gfx/screen.h" |
24 #include "ui/views/background.h" | 24 #include "ui/views/background.h" |
25 #include "ui/views/view.h" | 25 #include "ui/views/view.h" |
26 #include "ui/views/widget/widget.h" | 26 #include "ui/views/widget/widget.h" |
27 #include "ui/wm/core/compound_event_filter.h" | 27 #include "ui/wm/core/compound_event_filter.h" |
28 | 28 |
29 namespace ash { | 29 namespace ash { |
30 namespace internal { | |
31 | 30 |
32 //////////////////////////////////////////////////////////////////////////////// | 31 //////////////////////////////////////////////////////////////////////////////// |
33 // SystemModalContainerLayoutManager, public: | 32 // SystemModalContainerLayoutManager, public: |
34 | 33 |
35 SystemModalContainerLayoutManager::SystemModalContainerLayoutManager( | 34 SystemModalContainerLayoutManager::SystemModalContainerLayoutManager( |
36 aura::Window* container) | 35 aura::Window* container) |
37 : container_(container), | 36 : container_(container), |
38 modal_background_(NULL) { | 37 modal_background_(NULL) { |
39 } | 38 } |
40 | 39 |
(...skipping 18 matching lines...) Expand all Loading... |
59 } | 58 } |
60 } | 59 } |
61 } | 60 } |
62 | 61 |
63 void SystemModalContainerLayoutManager::OnWindowAddedToLayout( | 62 void SystemModalContainerLayoutManager::OnWindowAddedToLayout( |
64 aura::Window* child) { | 63 aura::Window* child) { |
65 DCHECK((modal_background_ && child == modal_background_->GetNativeView()) || | 64 DCHECK((modal_background_ && child == modal_background_->GetNativeView()) || |
66 child->type() == ui::wm::WINDOW_TYPE_NORMAL || | 65 child->type() == ui::wm::WINDOW_TYPE_NORMAL || |
67 child->type() == ui::wm::WINDOW_TYPE_POPUP); | 66 child->type() == ui::wm::WINDOW_TYPE_POPUP); |
68 DCHECK( | 67 DCHECK( |
69 container_->id() != internal::kShellWindowId_LockSystemModalContainer || | 68 container_->id() != kShellWindowId_LockSystemModalContainer || |
70 Shell::GetInstance()->session_state_delegate()->IsUserSessionBlocked()); | 69 Shell::GetInstance()->session_state_delegate()->IsUserSessionBlocked()); |
71 | 70 |
72 child->AddObserver(this); | 71 child->AddObserver(this); |
73 if (child->GetProperty(aura::client::kModalKey) != ui::MODAL_TYPE_NONE) | 72 if (child->GetProperty(aura::client::kModalKey) != ui::MODAL_TYPE_NONE) |
74 AddModalWindow(child); | 73 AddModalWindow(child); |
75 } | 74 } |
76 | 75 |
77 void SystemModalContainerLayoutManager::OnWillRemoveWindowFromLayout( | 76 void SystemModalContainerLayoutManager::OnWillRemoveWindowFromLayout( |
78 aura::Window* child) { | 77 aura::Window* child) { |
79 child->RemoveObserver(this); | 78 child->RemoveObserver(this); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 // system modal window layer which added event filter. | 125 // system modal window layer which added event filter. |
127 // Now this lock modal windows layer layout manager should not block events | 126 // Now this lock modal windows layer layout manager should not block events |
128 // for windows at lock layer. | 127 // for windows at lock layer. |
129 // See SystemModalContainerLayoutManagerTest.EventFocusContainers and | 128 // See SystemModalContainerLayoutManagerTest.EventFocusContainers and |
130 // http://crbug.com/157469 | 129 // http://crbug.com/157469 |
131 if (modal_windows_.empty()) | 130 if (modal_windows_.empty()) |
132 return true; | 131 return true; |
133 // This container can not handle events if the screen is locked and it is not | 132 // This container can not handle events if the screen is locked and it is not |
134 // above the lock screen layer (crbug.com/110920). | 133 // above the lock screen layer (crbug.com/110920). |
135 if (Shell::GetInstance()->session_state_delegate()->IsUserSessionBlocked() && | 134 if (Shell::GetInstance()->session_state_delegate()->IsUserSessionBlocked() && |
136 container_->id() < ash::internal::kShellWindowId_LockScreenContainer) | 135 container_->id() < ash::kShellWindowId_LockScreenContainer) |
137 return true; | 136 return true; |
138 return wm::GetActivatableWindow(window) == modal_window(); | 137 return wm::GetActivatableWindow(window) == modal_window(); |
139 } | 138 } |
140 | 139 |
141 bool SystemModalContainerLayoutManager::ActivateNextModalWindow() { | 140 bool SystemModalContainerLayoutManager::ActivateNextModalWindow() { |
142 if (modal_windows_.empty()) | 141 if (modal_windows_.empty()) |
143 return false; | 142 return false; |
144 wm::ActivateWindow(modal_window()); | 143 wm::ActivateWindow(modal_window()); |
145 return true; | 144 return true; |
146 } | 145 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 modal_background_->Close(); | 180 modal_background_->Close(); |
182 modal_background_->GetNativeView()->layer()->SetOpacity(0.0f); | 181 modal_background_->GetNativeView()->layer()->SetOpacity(0.0f); |
183 modal_background_ = NULL; | 182 modal_background_ = NULL; |
184 } | 183 } |
185 } | 184 } |
186 | 185 |
187 // static | 186 // static |
188 bool SystemModalContainerLayoutManager::IsModalBackground( | 187 bool SystemModalContainerLayoutManager::IsModalBackground( |
189 aura::Window* window) { | 188 aura::Window* window) { |
190 int id = window->parent()->id(); | 189 int id = window->parent()->id(); |
191 if (id != internal::kShellWindowId_SystemModalContainer && | 190 if (id != kShellWindowId_SystemModalContainer && |
192 id != internal::kShellWindowId_LockSystemModalContainer) | 191 id != kShellWindowId_LockSystemModalContainer) |
193 return false; | 192 return false; |
194 SystemModalContainerLayoutManager* layout_manager = | 193 SystemModalContainerLayoutManager* layout_manager = |
195 static_cast<SystemModalContainerLayoutManager*>( | 194 static_cast<SystemModalContainerLayoutManager*>( |
196 window->parent()->layout_manager()); | 195 window->parent()->layout_manager()); |
197 return layout_manager->modal_background_ && | 196 return layout_manager->modal_background_ && |
198 layout_manager->modal_background_->GetNativeWindow() == window; | 197 layout_manager->modal_background_->GetNativeWindow() == window; |
199 } | 198 } |
200 | 199 |
201 //////////////////////////////////////////////////////////////////////////////// | 200 //////////////////////////////////////////////////////////////////////////////// |
202 // SystemModalContainerLayoutManager, private: | 201 // SystemModalContainerLayoutManager, private: |
(...skipping 10 matching lines...) Expand all Loading... |
213 } | 212 } |
214 | 213 |
215 void SystemModalContainerLayoutManager::RemoveModalWindow( | 214 void SystemModalContainerLayoutManager::RemoveModalWindow( |
216 aura::Window* window) { | 215 aura::Window* window) { |
217 aura::Window::Windows::iterator it = | 216 aura::Window::Windows::iterator it = |
218 std::find(modal_windows_.begin(), modal_windows_.end(), window); | 217 std::find(modal_windows_.begin(), modal_windows_.end(), window); |
219 if (it != modal_windows_.end()) | 218 if (it != modal_windows_.end()) |
220 modal_windows_.erase(it); | 219 modal_windows_.erase(it); |
221 } | 220 } |
222 | 221 |
223 } // namespace internal | |
224 } // namespace ash | 222 } // namespace ash |
OLD | NEW |