| 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/shell.h" | 5 #include "ash/shell.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "ash/common/shelf/shelf_delegate.h" | 23 #include "ash/common/shelf/shelf_delegate.h" |
| 24 #include "ash/common/shelf/shelf_item_delegate.h" | 24 #include "ash/common/shelf/shelf_item_delegate.h" |
| 25 #include "ash/common/shelf/shelf_model.h" | 25 #include "ash/common/shelf/shelf_model.h" |
| 26 #include "ash/common/shelf/wm_shelf.h" | 26 #include "ash/common/shelf/wm_shelf.h" |
| 27 #include "ash/common/shell_delegate.h" | 27 #include "ash/common/shell_delegate.h" |
| 28 #include "ash/common/shell_window_ids.h" | 28 #include "ash/common/shell_window_ids.h" |
| 29 #include "ash/common/system/locale/locale_notification_controller.h" | 29 #include "ash/common/system/locale/locale_notification_controller.h" |
| 30 #include "ash/common/system/status_area_widget.h" | 30 #include "ash/common/system/status_area_widget.h" |
| 31 #include "ash/common/system/tray/system_tray_delegate.h" | 31 #include "ash/common/system/tray/system_tray_delegate.h" |
| 32 #include "ash/common/wallpaper/wallpaper_delegate.h" | 32 #include "ash/common/wallpaper/wallpaper_delegate.h" |
| 33 #include "ash/common/wm/container_finder.h" |
| 33 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | 34 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
| 34 #include "ash/common/wm/maximize_mode/maximize_mode_window_manager.h" | 35 #include "ash/common/wm/maximize_mode/maximize_mode_window_manager.h" |
| 35 #include "ash/common/wm/mru_window_tracker.h" | 36 #include "ash/common/wm/mru_window_tracker.h" |
| 36 #include "ash/common/wm/root_window_finder.h" | 37 #include "ash/common/wm/root_window_finder.h" |
| 38 #include "ash/common/wm/system_modal_container_layout_manager.h" |
| 37 #include "ash/common/wm/window_positioner.h" | 39 #include "ash/common/wm/window_positioner.h" |
| 38 #include "ash/common/wm/workspace_controller.h" | 40 #include "ash/common/wm/workspace_controller.h" |
| 39 #include "ash/common/wm_root_window_controller.h" | 41 #include "ash/common/wm_root_window_controller.h" |
| 40 #include "ash/common/wm_shell.h" | 42 #include "ash/common/wm_shell.h" |
| 41 #include "ash/display/cursor_window_controller.h" | 43 #include "ash/display/cursor_window_controller.h" |
| 42 #include "ash/display/display_configuration_controller.h" | 44 #include "ash/display/display_configuration_controller.h" |
| 43 #include "ash/display/display_manager.h" | 45 #include "ash/display/display_manager.h" |
| 44 #include "ash/display/event_transformation_handler.h" | 46 #include "ash/display/event_transformation_handler.h" |
| 45 #include "ash/display/mouse_cursor_event_filter.h" | 47 #include "ash/display/mouse_cursor_event_filter.h" |
| 46 #include "ash/display/screen_ash.h" | 48 #include "ash/display/screen_ash.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 62 #include "ash/wm/event_client_impl.h" | 64 #include "ash/wm/event_client_impl.h" |
| 63 #include "ash/wm/immersive_handler_factory_ash.h" | 65 #include "ash/wm/immersive_handler_factory_ash.h" |
| 64 #include "ash/wm/lock_state_controller.h" | 66 #include "ash/wm/lock_state_controller.h" |
| 65 #include "ash/wm/overlay_event_filter.h" | 67 #include "ash/wm/overlay_event_filter.h" |
| 66 #include "ash/wm/overview/scoped_overview_animation_settings_factory_aura.h" | 68 #include "ash/wm/overview/scoped_overview_animation_settings_factory_aura.h" |
| 67 #include "ash/wm/power_button_controller.h" | 69 #include "ash/wm/power_button_controller.h" |
| 68 #include "ash/wm/resize_shadow_controller.h" | 70 #include "ash/wm/resize_shadow_controller.h" |
| 69 #include "ash/wm/screen_pinning_controller.h" | 71 #include "ash/wm/screen_pinning_controller.h" |
| 70 #include "ash/wm/system_gesture_event_filter.h" | 72 #include "ash/wm/system_gesture_event_filter.h" |
| 71 #include "ash/wm/system_modal_container_event_filter.h" | 73 #include "ash/wm/system_modal_container_event_filter.h" |
| 72 #include "ash/wm/system_modal_container_layout_manager.h" | |
| 73 #include "ash/wm/toplevel_window_event_handler.h" | 74 #include "ash/wm/toplevel_window_event_handler.h" |
| 74 #include "ash/wm/video_detector.h" | 75 #include "ash/wm/video_detector.h" |
| 75 #include "ash/wm/window_animations.h" | 76 #include "ash/wm/window_animations.h" |
| 76 #include "ash/wm/window_properties.h" | 77 #include "ash/wm/window_properties.h" |
| 77 #include "ash/wm/window_util.h" | 78 #include "ash/wm/window_util.h" |
| 78 #include "base/bind.h" | 79 #include "base/bind.h" |
| 79 #include "base/memory/ptr_util.h" | 80 #include "base/memory/ptr_util.h" |
| 80 #include "base/trace_event/trace_event.h" | 81 #include "base/trace_event/trace_event.h" |
| 81 #include "ui/aura/client/aura_constants.h" | 82 #include "ui/aura/client/aura_constants.h" |
| 82 #include "ui/aura/env.h" | 83 #include "ui/aura/env.h" |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 aura::Window* Shell::GetContainer(aura::Window* root_window, int container_id) { | 257 aura::Window* Shell::GetContainer(aura::Window* root_window, int container_id) { |
| 257 return root_window->GetChildById(container_id); | 258 return root_window->GetChildById(container_id); |
| 258 } | 259 } |
| 259 | 260 |
| 260 // static | 261 // static |
| 261 const aura::Window* Shell::GetContainer(const aura::Window* root_window, | 262 const aura::Window* Shell::GetContainer(const aura::Window* root_window, |
| 262 int container_id) { | 263 int container_id) { |
| 263 return root_window->GetChildById(container_id); | 264 return root_window->GetChildById(container_id); |
| 264 } | 265 } |
| 265 | 266 |
| 266 // static | |
| 267 std::vector<aura::Window*> Shell::GetContainersFromAllRootWindows( | |
| 268 int container_id, | |
| 269 aura::Window* priority_root) { | |
| 270 std::vector<aura::Window*> containers; | |
| 271 aura::Window::Windows root_windows = GetAllRootWindows(); | |
| 272 for (aura::Window::Windows::const_iterator it = root_windows.begin(); | |
| 273 it != root_windows.end(); ++it) { | |
| 274 aura::Window* container = (*it)->GetChildById(container_id); | |
| 275 if (container) { | |
| 276 if (priority_root && priority_root->Contains(container)) | |
| 277 containers.insert(containers.begin(), container); | |
| 278 else | |
| 279 containers.push_back(container); | |
| 280 } | |
| 281 } | |
| 282 return containers; | |
| 283 } | |
| 284 | |
| 285 void Shell::ShowContextMenu(const gfx::Point& location_in_screen, | 267 void Shell::ShowContextMenu(const gfx::Point& location_in_screen, |
| 286 ui::MenuSourceType source_type) { | 268 ui::MenuSourceType source_type) { |
| 287 // No context menus if there is no session with an active user. | 269 // No context menus if there is no session with an active user. |
| 288 if (!session_state_delegate_->NumberOfLoggedInUsers()) | 270 if (!session_state_delegate_->NumberOfLoggedInUsers()) |
| 289 return; | 271 return; |
| 290 // No context menus when screen is locked. | 272 // No context menus when screen is locked. |
| 291 if (session_state_delegate_->IsScreenLocked()) | 273 if (session_state_delegate_->IsScreenLocked()) |
| 292 return; | 274 return; |
| 293 | 275 |
| 294 aura::Window* root = WmWindowAura::GetAuraWindow( | 276 aura::Window* root = WmWindowAura::GetAuraWindow( |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 FOR_EACH_OBSERVER(ShellObserver, *wm_shell_->shell_observers(), | 314 FOR_EACH_OBSERVER(ShellObserver, *wm_shell_->shell_observers(), |
| 333 OnAppTerminating()); | 315 OnAppTerminating()); |
| 334 } | 316 } |
| 335 | 317 |
| 336 void Shell::OnLockStateChanged(bool locked) { | 318 void Shell::OnLockStateChanged(bool locked) { |
| 337 FOR_EACH_OBSERVER(ShellObserver, *wm_shell_->shell_observers(), | 319 FOR_EACH_OBSERVER(ShellObserver, *wm_shell_->shell_observers(), |
| 338 OnLockStateChanged(locked)); | 320 OnLockStateChanged(locked)); |
| 339 #ifndef NDEBUG | 321 #ifndef NDEBUG |
| 340 // Make sure that there is no system modal in Lock layer when unlocked. | 322 // Make sure that there is no system modal in Lock layer when unlocked. |
| 341 if (!locked) { | 323 if (!locked) { |
| 342 std::vector<aura::Window*> containers = GetContainersFromAllRootWindows( | 324 std::vector<WmWindow*> containers = wm::GetContainersFromAllRootWindows( |
| 343 kShellWindowId_LockSystemModalContainer, GetPrimaryRootWindow()); | 325 kShellWindowId_LockSystemModalContainer, |
| 344 for (std::vector<aura::Window*>::const_iterator iter = containers.begin(); | 326 WmWindowAura::Get(GetPrimaryRootWindow())); |
| 345 iter != containers.end(); ++iter) { | 327 for (WmWindow* container : containers) |
| 346 DCHECK_EQ(0u, (*iter)->children().size()); | 328 DCHECK(container->GetChildren().empty()); |
| 347 } | |
| 348 } | 329 } |
| 349 #endif | 330 #endif |
| 350 } | 331 } |
| 351 | 332 |
| 352 void Shell::OnCastingSessionStartedOrStopped(bool started) { | 333 void Shell::OnCastingSessionStartedOrStopped(bool started) { |
| 353 #if defined(OS_CHROMEOS) | 334 #if defined(OS_CHROMEOS) |
| 354 FOR_EACH_OBSERVER(ShellObserver, *wm_shell_->shell_observers(), | 335 FOR_EACH_OBSERVER(ShellObserver, *wm_shell_->shell_observers(), |
| 355 OnCastingSessionStartedOrStopped(started)); | 336 OnCastingSessionStartedOrStopped(started)); |
| 356 #endif | 337 #endif |
| 357 } | 338 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 screen_orientation_controller_->ignore_display_configuration_updates() || | 392 screen_orientation_controller_->ignore_display_configuration_updates() || |
| 412 resolution_notification_controller_->DoesNotificationTimeout()); | 393 resolution_notification_controller_->DoesNotificationTimeout()); |
| 413 } | 394 } |
| 414 #endif | 395 #endif |
| 415 | 396 |
| 416 void Shell::UpdateShelfVisibility() { | 397 void Shell::UpdateShelfVisibility() { |
| 417 for (WmWindow* root : wm_shell_->GetAllRootWindows()) | 398 for (WmWindow* root : wm_shell_->GetAllRootWindows()) |
| 418 root->GetRootWindowController()->GetShelf()->UpdateVisibilityState(); | 399 root->GetRootWindowController()->GetShelf()->UpdateVisibilityState(); |
| 419 } | 400 } |
| 420 | 401 |
| 421 void Shell::CreateModalBackground(aura::Window* window) { | |
| 422 RootWindowControllerList controllers = GetAllRootWindowControllers(); | |
| 423 for (RootWindowControllerList::iterator iter = controllers.begin(); | |
| 424 iter != controllers.end(); ++iter) | |
| 425 (*iter)->GetSystemModalLayoutManager(window)->CreateModalBackground(); | |
| 426 } | |
| 427 | |
| 428 void Shell::OnModalWindowRemoved(aura::Window* removed) { | |
| 429 RootWindowControllerList controllers = GetAllRootWindowControllers(); | |
| 430 bool activated = false; | |
| 431 for (RootWindowControllerList::iterator iter = controllers.begin(); | |
| 432 iter != controllers.end() && !activated; ++iter) { | |
| 433 activated = (*iter) | |
| 434 ->GetSystemModalLayoutManager(removed) | |
| 435 ->ActivateNextModalWindow(); | |
| 436 } | |
| 437 if (!activated) { | |
| 438 for (RootWindowControllerList::iterator iter = controllers.begin(); | |
| 439 iter != controllers.end(); ++iter) | |
| 440 (*iter)->GetSystemModalLayoutManager(removed)->DestroyModalBackground(); | |
| 441 } | |
| 442 } | |
| 443 | |
| 444 WebNotificationTray* Shell::GetWebNotificationTray() { | 402 WebNotificationTray* Shell::GetWebNotificationTray() { |
| 445 return GetPrimaryRootWindowController() | 403 return GetPrimaryRootWindowController() |
| 446 ->GetStatusAreaWidget() | 404 ->GetStatusAreaWidget() |
| 447 ->web_notification_tray(); | 405 ->web_notification_tray(); |
| 448 } | 406 } |
| 449 | 407 |
| 450 bool Shell::HasPrimaryStatusArea() { | 408 bool Shell::HasPrimaryStatusArea() { |
| 451 return !!GetPrimaryRootWindowController()->GetStatusAreaWidget(); | 409 return !!GetPrimaryRootWindowController()->GetStatusAreaWidget(); |
| 452 } | 410 } |
| 453 | 411 |
| (...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1018 std::unique_ptr<ui::EventTargetIterator> Shell::GetChildIterator() const { | 976 std::unique_ptr<ui::EventTargetIterator> Shell::GetChildIterator() const { |
| 1019 return std::unique_ptr<ui::EventTargetIterator>(); | 977 return std::unique_ptr<ui::EventTargetIterator>(); |
| 1020 } | 978 } |
| 1021 | 979 |
| 1022 ui::EventTargeter* Shell::GetEventTargeter() { | 980 ui::EventTargeter* Shell::GetEventTargeter() { |
| 1023 NOTREACHED(); | 981 NOTREACHED(); |
| 1024 return nullptr; | 982 return nullptr; |
| 1025 } | 983 } |
| 1026 | 984 |
| 1027 } // namespace ash | 985 } // namespace ash |
| OLD | NEW |