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 | 9 |
10 #include "ash/accelerators/focus_manager_factory.h" | 10 #include "ash/accelerators/focus_manager_factory.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "ash/shell_factory.h" | 28 #include "ash/shell_factory.h" |
29 #include "ash/shell_window_ids.h" | 29 #include "ash/shell_window_ids.h" |
30 #include "ash/system/status_area_widget.h" | 30 #include "ash/system/status_area_widget.h" |
31 #include "ash/tooltips/tooltip_controller.h" | 31 #include "ash/tooltips/tooltip_controller.h" |
32 #include "ash/touch/touch_observer_hud.h" | 32 #include "ash/touch/touch_observer_hud.h" |
33 #include "ash/wm/activation_controller.h" | 33 #include "ash/wm/activation_controller.h" |
34 #include "ash/wm/always_on_top_controller.h" | 34 #include "ash/wm/always_on_top_controller.h" |
35 #include "ash/wm/app_list_controller.h" | 35 #include "ash/wm/app_list_controller.h" |
36 #include "ash/wm/base_layout_manager.h" | 36 #include "ash/wm/base_layout_manager.h" |
37 #include "ash/wm/capture_controller.h" | 37 #include "ash/wm/capture_controller.h" |
| 38 #include "ash/wm/coordinate_conversion.h" |
38 #include "ash/wm/custom_frame_view_ash.h" | 39 #include "ash/wm/custom_frame_view_ash.h" |
39 #include "ash/wm/dialog_frame_view.h" | 40 #include "ash/wm/dialog_frame_view.h" |
40 #include "ash/wm/event_client_impl.h" | 41 #include "ash/wm/event_client_impl.h" |
41 #include "ash/wm/event_rewriter_event_filter.h" | 42 #include "ash/wm/event_rewriter_event_filter.h" |
42 #include "ash/wm/overlay_event_filter.h" | 43 #include "ash/wm/overlay_event_filter.h" |
43 #include "ash/wm/power_button_controller.h" | 44 #include "ash/wm/power_button_controller.h" |
44 #include "ash/wm/property_util.h" | 45 #include "ash/wm/property_util.h" |
45 #include "ash/wm/resize_shadow_controller.h" | 46 #include "ash/wm/resize_shadow_controller.h" |
46 #include "ash/wm/root_window_layout_manager.h" | 47 #include "ash/wm/root_window_layout_manager.h" |
47 #include "ash/wm/screen_dimmer.h" | 48 #include "ash/wm/screen_dimmer.h" |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 aura::Env::GetInstance()->RemovePreTargetHandler(filter); | 507 aura::Env::GetInstance()->RemovePreTargetHandler(filter); |
507 } | 508 } |
508 | 509 |
509 void Shell::ShowContextMenu(const gfx::Point& location) { | 510 void Shell::ShowContextMenu(const gfx::Point& location) { |
510 // No context menus if user have not logged in. | 511 // No context menus if user have not logged in. |
511 if (!delegate_.get() || !delegate_->IsUserLoggedIn()) | 512 if (!delegate_.get() || !delegate_->IsUserLoggedIn()) |
512 return; | 513 return; |
513 // No context menus when screen is locked. | 514 // No context menus when screen is locked. |
514 if (IsScreenLocked()) | 515 if (IsScreenLocked()) |
515 return; | 516 return; |
516 if (launcher()) | 517 aura::RootWindow* root = |
517 launcher()->ShowContextMenu(location); | 518 wm::GetRootWindowMatching(gfx::Rect(location, gfx::Size())); |
| 519 Launcher::ForWindow(root)->ShowContextMenu(location); |
518 } | 520 } |
519 | 521 |
520 void Shell::ToggleAppList() { | 522 void Shell::ToggleAppList() { |
521 if (!app_list_controller_.get()) | 523 if (!app_list_controller_.get()) |
522 app_list_controller_.reset(new internal::AppListController); | 524 app_list_controller_.reset(new internal::AppListController); |
523 app_list_controller_->SetVisible(!app_list_controller_->IsVisible()); | 525 app_list_controller_->SetVisible(!app_list_controller_->IsVisible()); |
524 } | 526 } |
525 | 527 |
526 bool Shell::GetAppListTargetVisibility() const { | 528 bool Shell::GetAppListTargetVisibility() const { |
527 return app_list_controller_.get() && | 529 return app_list_controller_.get() && |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 return; | 575 return; |
574 FOR_EACH_OBSERVER(ShellObserver, observers_, | 576 FOR_EACH_OBSERVER(ShellObserver, observers_, |
575 OnDisplayWorkAreaInsetsChanged()); | 577 OnDisplayWorkAreaInsetsChanged()); |
576 } | 578 } |
577 | 579 |
578 void Shell::OnLoginStateChanged(user::LoginStatus status) { | 580 void Shell::OnLoginStateChanged(user::LoginStatus status) { |
579 FOR_EACH_OBSERVER(ShellObserver, observers_, OnLoginStateChanged(status)); | 581 FOR_EACH_OBSERVER(ShellObserver, observers_, OnLoginStateChanged(status)); |
580 ash::Shell::GetInstance()->UpdateShelfVisibility(); | 582 ash::Shell::GetInstance()->UpdateShelfVisibility(); |
581 } | 583 } |
582 | 584 |
| 585 void Shell::UpdateAfterLoginStatusChange(user::LoginStatus status) { |
| 586 GetPrimaryRootWindowController()->status_area_widget()-> |
| 587 UpdateAfterLoginStatusChange(status); |
| 588 } |
| 589 |
583 void Shell::OnAppTerminating() { | 590 void Shell::OnAppTerminating() { |
584 FOR_EACH_OBSERVER(ShellObserver, observers_, OnAppTerminating()); | 591 FOR_EACH_OBSERVER(ShellObserver, observers_, OnAppTerminating()); |
585 } | 592 } |
586 | 593 |
587 void Shell::OnLockStateChanged(bool locked) { | 594 void Shell::OnLockStateChanged(bool locked) { |
588 FOR_EACH_OBSERVER(ShellObserver, observers_, OnLockStateChanged(locked)); | 595 FOR_EACH_OBSERVER(ShellObserver, observers_, OnLockStateChanged(locked)); |
589 } | 596 } |
590 | 597 |
591 void Shell::CreateLauncher() { | 598 void Shell::CreateLauncher() { |
592 GetPrimaryRootWindowController()->CreateLauncher(); | 599 GetPrimaryRootWindowController()->CreateLauncher(); |
593 } | 600 } |
594 | 601 |
595 void Shell::ShowLauncher() { | 602 void Shell::ShowLauncher() { |
596 GetPrimaryRootWindowController()->ShowLauncher(); | 603 GetPrimaryRootWindowController()->ShowLauncher(); |
597 } | 604 } |
598 | 605 |
599 void Shell::AddShellObserver(ShellObserver* observer) { | 606 void Shell::AddShellObserver(ShellObserver* observer) { |
600 observers_.AddObserver(observer); | 607 observers_.AddObserver(observer); |
601 } | 608 } |
602 | 609 |
603 void Shell::RemoveShellObserver(ShellObserver* observer) { | 610 void Shell::RemoveShellObserver(ShellObserver* observer) { |
604 observers_.RemoveObserver(observer); | 611 observers_.RemoveObserver(observer); |
605 } | 612 } |
606 | 613 |
607 Launcher* Shell::launcher() { | |
608 return GetPrimaryRootWindowController()->launcher(); | |
609 } | |
610 | |
611 void Shell::UpdateShelfVisibility() { | 614 void Shell::UpdateShelfVisibility() { |
| 615 // TODO(oshima): Update all root windows. |
612 GetPrimaryRootWindowController()->UpdateShelfVisibility(); | 616 GetPrimaryRootWindowController()->UpdateShelfVisibility(); |
613 } | 617 } |
614 | 618 |
615 void Shell::SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior) { | 619 void Shell::SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior) { |
616 GetPrimaryRootWindowController()->SetShelfAutoHideBehavior(behavior); | 620 GetPrimaryRootWindowController()->SetShelfAutoHideBehavior(behavior); |
617 } | 621 } |
618 | 622 |
619 ShelfAutoHideBehavior Shell::GetShelfAutoHideBehavior() const { | 623 ShelfAutoHideBehavior Shell::GetShelfAutoHideBehavior() const { |
620 return GetPrimaryRootWindowController()->GetShelfAutoHideBehavior(); | 624 return GetPrimaryRootWindowController()->GetShelfAutoHideBehavior(); |
621 } | 625 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 } | 662 } |
659 if (!activated) { | 663 if (!activated) { |
660 RemoveEnvEventFilter(modality_filter_.get()); | 664 RemoveEnvEventFilter(modality_filter_.get()); |
661 modality_filter_.reset(); | 665 modality_filter_.reset(); |
662 for (RootWindowControllerList::iterator iter = controllers.begin(); | 666 for (RootWindowControllerList::iterator iter = controllers.begin(); |
663 iter != controllers.end(); ++iter) | 667 iter != controllers.end(); ++iter) |
664 (*iter)->GetSystemModalLayoutManager(removed)->DestroyModalBackground(); | 668 (*iter)->GetSystemModalLayoutManager(removed)->DestroyModalBackground(); |
665 } | 669 } |
666 } | 670 } |
667 | 671 |
668 internal::ShelfLayoutManager* Shell::shelf() const { | 672 WebNotificationTray* Shell::GetWebNotificationTray() { |
669 return GetPrimaryRootWindowController()->shelf(); | 673 return GetPrimaryRootWindowController()->status_area_widget()-> |
670 } | 674 web_notification_tray(); |
671 | |
672 internal::StatusAreaWidget* Shell::status_area_widget() const { | |
673 return GetPrimaryRootWindowController()->status_area_widget(); | |
674 } | 675 } |
675 | 676 |
676 SystemTrayDelegate* Shell::tray_delegate() { | 677 SystemTrayDelegate* Shell::tray_delegate() { |
677 return status_area_widget() ? status_area_widget()->system_tray_delegate() : | 678 // TODO(oshima): Decouple system tray and its delegate. |
678 NULL; | 679 internal::StatusAreaWidget* status_area_widget = |
| 680 GetPrimaryRootWindowController()->status_area_widget(); |
| 681 return status_area_widget ? status_area_widget->system_tray_delegate() : NULL; |
679 } | 682 } |
680 | 683 |
681 SystemTray* Shell::system_tray() { | 684 SystemTray* Shell::system_tray() { |
682 return status_area_widget() ? status_area_widget()->system_tray() : | 685 internal::StatusAreaWidget* status_area_widget = |
683 NULL; | 686 GetPrimaryRootWindowController()->status_area_widget(); |
| 687 return status_area_widget ? status_area_widget->system_tray() : NULL; |
684 } | 688 } |
685 | 689 |
686 void Shell::InitRootWindowForSecondaryDisplay(aura::RootWindow* root) { | 690 void Shell::InitRootWindowForSecondaryDisplay(aura::RootWindow* root) { |
687 root->set_focus_manager(focus_manager_.get()); | 691 root->set_focus_manager(focus_manager_.get()); |
688 internal::RootWindowController* controller = | 692 internal::RootWindowController* controller = |
689 new internal::RootWindowController(root); | 693 new internal::RootWindowController(root); |
690 controller->CreateContainers(); | 694 controller->CreateContainers(); |
691 InitRootWindowController(controller); | 695 InitRootWindowController(controller); |
692 controller->root_window_layout()->OnWindowResized(); | 696 controller->root_window_layout()->OnWindowResized(); |
693 desktop_background_controller_->OnRootWindowAdded(root); | 697 desktop_background_controller_->OnRootWindowAdded(root); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 iter != controllers.end(); ++iter) { | 762 iter != controllers.end(); ++iter) { |
759 if ((*iter)->GetSystemModalLayoutManager(window)-> | 763 if ((*iter)->GetSystemModalLayoutManager(window)-> |
760 CanWindowReceiveEvents(window)) { | 764 CanWindowReceiveEvents(window)) { |
761 return true; | 765 return true; |
762 } | 766 } |
763 } | 767 } |
764 return false; | 768 return false; |
765 } | 769 } |
766 | 770 |
767 } // namespace ash | 771 } // namespace ash |
OLD | NEW |