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 | 8 |
9 #include "ash/app_list/app_list.h" | 9 #include "ash/app_list/app_list.h" |
10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
11 #include "ash/desktop_background/desktop_background_controller.h" | 11 #include "ash/desktop_background/desktop_background_controller.h" |
12 #include "ash/desktop_background/desktop_background_resources.h" | 12 #include "ash/desktop_background/desktop_background_resources.h" |
13 #include "ash/desktop_background/desktop_background_view.h" | 13 #include "ash/desktop_background/desktop_background_view.h" |
14 #include "ash/drag_drop/drag_drop_controller.h" | 14 #include "ash/drag_drop/drag_drop_controller.h" |
15 #include "ash/focus_cycler.h" | 15 #include "ash/focus_cycler.h" |
16 #include "ash/ime/input_method_event_filter.h" | 16 #include "ash/ime/input_method_event_filter.h" |
17 #include "ash/launcher/launcher.h" | 17 #include "ash/launcher/launcher.h" |
18 #include "ash/monitor/monitor_controller.h" | 18 #include "ash/monitor/monitor_controller.h" |
19 #include "ash/monitor/multi_monitor_manager.h" | 19 #include "ash/monitor/multi_monitor_manager.h" |
20 #include "ash/screen_ash.h" | 20 #include "ash/screen_ash.h" |
21 #include "ash/shell_context_menu.h" | 21 #include "ash/shell_context_menu.h" |
22 #include "ash/shell_delegate.h" | 22 #include "ash/shell_delegate.h" |
23 #include "ash/shell_factory.h" | 23 #include "ash/shell_factory.h" |
24 #include "ash/shell_window_ids.h" | 24 #include "ash/shell_window_ids.h" |
25 #include "ash/system/audio/tray_volume.h" | 25 #include "ash/system/bluetooth/bluetooth_observer.h" |
26 #include "ash/system/bluetooth/tray_bluetooth.h" | 26 #include "ash/system/network/network_observer.h" |
27 #include "ash/system/brightness/tray_brightness.h" | |
28 #include "ash/system/date/tray_date.h" | |
29 #include "ash/system/ime/tray_ime.h" | |
30 #include "ash/system/network/tray_network.h" | |
31 #include "ash/system/power/power_status_observer.h" | |
32 #include "ash/system/power/power_supply_status.h" | |
33 #include "ash/system/power/tray_power.h" | |
34 #include "ash/system/settings/tray_settings.h" | |
35 #include "ash/system/tray/system_tray.h" | 27 #include "ash/system/tray/system_tray.h" |
36 #include "ash/system/tray/system_tray_delegate.h" | 28 #include "ash/system/tray/system_tray_delegate.h" |
37 #include "ash/system/tray/tray_empty.h" | |
38 #include "ash/system/tray_accessibility.h" | |
39 #include "ash/system/tray_caps_lock.h" | |
40 #include "ash/system/tray_update.h" | |
41 #include "ash/system/user/tray_user.h" | |
42 #include "ash/tooltips/tooltip_controller.h" | 29 #include "ash/tooltips/tooltip_controller.h" |
43 #include "ash/wm/activation_controller.h" | 30 #include "ash/wm/activation_controller.h" |
44 #include "ash/wm/base_layout_manager.h" | 31 #include "ash/wm/base_layout_manager.h" |
45 #include "ash/wm/custom_frame_view_ash.h" | 32 #include "ash/wm/custom_frame_view_ash.h" |
46 #include "ash/wm/dialog_frame_view.h" | 33 #include "ash/wm/dialog_frame_view.h" |
47 #include "ash/wm/event_client_impl.h" | 34 #include "ash/wm/event_client_impl.h" |
48 #include "ash/wm/key_rewriter_event_filter.h" | 35 #include "ash/wm/key_rewriter_event_filter.h" |
49 #include "ash/wm/panel_layout_manager.h" | 36 #include "ash/wm/panel_layout_manager.h" |
50 #include "ash/wm/panel_window_event_filter.h" | 37 #include "ash/wm/panel_window_event_filter.h" |
51 #include "ash/wm/partial_screenshot_event_filter.h" | 38 #include "ash/wm/partial_screenshot_event_filter.h" |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 //////////////////////////////////////////////////////////////////////////////// | 510 //////////////////////////////////////////////////////////////////////////////// |
524 // Shell, public: | 511 // Shell, public: |
525 | 512 |
526 Shell::Shell(ShellDelegate* delegate) | 513 Shell::Shell(ShellDelegate* delegate) |
527 : root_window_(aura::MonitorManager::CreateRootWindowForPrimaryMonitor()), | 514 : root_window_(aura::MonitorManager::CreateRootWindowForPrimaryMonitor()), |
528 screen_(new ScreenAsh(root_window_.get())), | 515 screen_(new ScreenAsh(root_window_.get())), |
529 root_filter_(NULL), | 516 root_filter_(NULL), |
530 delegate_(delegate), | 517 delegate_(delegate), |
531 shelf_(NULL), | 518 shelf_(NULL), |
532 panel_layout_manager_(NULL), | 519 panel_layout_manager_(NULL), |
533 root_window_layout_(NULL), | 520 root_window_layout_(NULL) { |
534 status_widget_(NULL) { | |
535 gfx::Screen::SetInstance(screen_); | 521 gfx::Screen::SetInstance(screen_); |
536 ui_controls::InstallUIControlsAura(CreateUIControlsAura(root_window_.get())); | 522 ui_controls::InstallUIControlsAura(CreateUIControlsAura(root_window_.get())); |
537 } | 523 } |
538 | 524 |
539 Shell::~Shell() { | 525 Shell::~Shell() { |
540 RemoveRootWindowEventFilter(key_rewriter_filter_.get()); | 526 RemoveRootWindowEventFilter(key_rewriter_filter_.get()); |
541 RemoveRootWindowEventFilter(partial_screenshot_filter_.get()); | 527 RemoveRootWindowEventFilter(partial_screenshot_filter_.get()); |
542 RemoveRootWindowEventFilter(input_method_filter_.get()); | 528 RemoveRootWindowEventFilter(input_method_filter_.get()); |
543 RemoveRootWindowEventFilter(window_modality_controller_.get()); | 529 RemoveRootWindowEventFilter(window_modality_controller_.get()); |
544 RemoveRootWindowEventFilter(system_gesture_filter_.get()); | 530 RemoveRootWindowEventFilter(system_gesture_filter_.get()); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 | 660 |
675 stacking_controller_.reset(new internal::StackingController); | 661 stacking_controller_.reset(new internal::StackingController); |
676 | 662 |
677 root_window_layout_ = new internal::RootWindowLayoutManager(root_window); | 663 root_window_layout_ = new internal::RootWindowLayoutManager(root_window); |
678 root_window->SetLayoutManager(root_window_layout_); | 664 root_window->SetLayoutManager(root_window_layout_); |
679 | 665 |
680 event_client_.reset(new internal::EventClientImpl(root_window)); | 666 event_client_.reset(new internal::EventClientImpl(root_window)); |
681 | 667 |
682 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 668 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
683 | 669 |
684 // TODO(sad): All of these initialization should happen in SystemTray. | |
685 tray_.reset(new SystemTray()); | 670 tray_.reset(new SystemTray()); |
686 if (delegate_.get()) | 671 if (delegate_.get()) |
687 tray_delegate_.reset(delegate_->CreateSystemTrayDelegate(tray_.get())); | 672 tray_delegate_.reset(delegate_->CreateSystemTrayDelegate(tray_.get())); |
688 if (!tray_delegate_.get()) | 673 if (!tray_delegate_.get()) |
689 tray_delegate_.reset(new DummySystemTrayDelegate()); | 674 tray_delegate_.reset(new DummySystemTrayDelegate()); |
690 | 675 tray_->CreateItems(); |
691 internal::TrayVolume* tray_volume = new internal::TrayVolume(); | 676 tray_->CreateWidget(); |
692 internal::TrayBluetooth* tray_bluetooth = new internal::TrayBluetooth(); | |
693 internal::TrayBrightness* tray_brightness = new internal::TrayBrightness(); | |
694 internal::TrayDate* tray_date = new internal::TrayDate(); | |
695 internal::TrayPower* tray_power = new internal::TrayPower(); | |
696 internal::TrayNetwork* tray_network = new internal::TrayNetwork; | |
697 internal::TrayUser* tray_user = new internal::TrayUser; | |
698 internal::TrayAccessibility* tray_accessibility = | |
699 new internal::TrayAccessibility; | |
700 internal::TrayCapsLock* tray_caps_lock = new internal::TrayCapsLock; | |
701 internal::TrayIME* tray_ime = new internal::TrayIME; | |
702 internal::TrayUpdate* tray_update = new internal::TrayUpdate; | |
703 | |
704 tray_->accessibility_observer_ = tray_accessibility; | |
705 tray_->audio_observer_ = tray_volume; | |
706 tray_->bluetooth_observer_ = tray_bluetooth; | |
707 tray_->brightness_observer_ = tray_brightness; | |
708 tray_->caps_lock_observer_ = tray_caps_lock; | |
709 tray_->clock_observer_ = tray_date; | |
710 tray_->ime_observer_ = tray_ime; | |
711 tray_->network_observer_ = tray_network; | |
712 tray_->power_status_observer_ = tray_power; | |
713 tray_->update_observer_ = tray_update; | |
714 tray_->user_observer_ = tray_user; | |
715 | |
716 tray_->AddTrayItem(tray_user); | |
717 tray_->AddTrayItem(new internal::TrayEmpty()); | |
718 tray_->AddTrayItem(tray_power); | |
719 tray_->AddTrayItem(tray_network); | |
720 tray_->AddTrayItem(tray_bluetooth); | |
721 tray_->AddTrayItem(tray_ime); | |
722 tray_->AddTrayItem(tray_volume); | |
723 tray_->AddTrayItem(tray_brightness); | |
724 tray_->AddTrayItem(tray_update); | |
725 tray_->AddTrayItem(new internal::TraySettings()); | |
726 tray_->AddTrayItem(tray_accessibility); | |
727 tray_->AddTrayItem(tray_caps_lock); | |
728 tray_->AddTrayItem(tray_date); | |
729 tray_->SetVisible(tray_delegate_->GetTrayVisibilityOnStartup()); | |
730 | |
731 // TODO(sad): Replace uses of status_widget_ with tray_->GetWidget(). | |
732 status_widget_ = internal::CreateStatusArea(tray_.get()); | |
733 | 677 |
734 // This controller needs to be set before SetupManagedWindowMode. | 678 // This controller needs to be set before SetupManagedWindowMode. |
735 desktop_background_controller_.reset(new DesktopBackgroundController); | 679 desktop_background_controller_.reset(new DesktopBackgroundController); |
736 if (delegate_.get()) | 680 if (delegate_.get()) |
737 user_wallpaper_delegate_.reset(delegate_->CreateUserWallpaperDelegate()); | 681 user_wallpaper_delegate_.reset(delegate_->CreateUserWallpaperDelegate()); |
738 if (!user_wallpaper_delegate_.get()) | 682 if (!user_wallpaper_delegate_.get()) |
739 user_wallpaper_delegate_.reset(new DummyUserWallpaperDelegate()); | 683 user_wallpaper_delegate_.reset(new DummyUserWallpaperDelegate()); |
740 | 684 |
741 InitLayoutManagers(); | 685 InitLayoutManagers(); |
742 | 686 |
743 if (!command_line->HasSwitch(switches::kAuraNoShadows)) { | 687 if (!command_line->HasSwitch(switches::kAuraNoShadows)) { |
744 resize_shadow_controller_.reset(new internal::ResizeShadowController()); | 688 resize_shadow_controller_.reset(new internal::ResizeShadowController()); |
745 shadow_controller_.reset(new internal::ShadowController()); | 689 shadow_controller_.reset(new internal::ShadowController()); |
746 } | 690 } |
747 | 691 |
748 focus_cycler_.reset(new internal::FocusCycler()); | 692 focus_cycler_.reset(new internal::FocusCycler()); |
749 focus_cycler_->AddWidget(status_widget_); | 693 focus_cycler_->AddWidget(tray_->widget()); |
750 | 694 |
751 if (!delegate_.get() || delegate_->IsUserLoggedIn()) | 695 if (!delegate_.get() || delegate_->IsUserLoggedIn()) |
752 CreateLauncher(); | 696 CreateLauncher(); |
753 | 697 |
754 // Force a layout. | 698 // Force a layout. |
755 root_window->layout_manager()->OnWindowResized(); | 699 root_window->layout_manager()->OnWindowResized(); |
756 | 700 |
757 window_modality_controller_.reset(new internal::WindowModalityController); | 701 window_modality_controller_.reset(new internal::WindowModalityController); |
758 AddRootWindowEventFilter(window_modality_controller_.get()); | 702 AddRootWindowEventFilter(window_modality_controller_.get()); |
759 | 703 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
907 | 851 |
908 bool Shell::IsInMaximizedMode() const { | 852 bool Shell::IsInMaximizedMode() const { |
909 return workspace_controller_->workspace_manager()->IsInMaximizedMode(); | 853 return workspace_controller_->workspace_manager()->IsInMaximizedMode(); |
910 } | 854 } |
911 | 855 |
912 //////////////////////////////////////////////////////////////////////////////// | 856 //////////////////////////////////////////////////////////////////////////////// |
913 // Shell, private: | 857 // Shell, private: |
914 | 858 |
915 void Shell::InitLayoutManagers() { | 859 void Shell::InitLayoutManagers() { |
916 DCHECK(root_window_layout_); | 860 DCHECK(root_window_layout_); |
917 DCHECK(status_widget_); | 861 DCHECK(tray_->widget()); |
918 | 862 |
919 internal::ShelfLayoutManager* shelf_layout_manager = | 863 internal::ShelfLayoutManager* shelf_layout_manager = |
920 new internal::ShelfLayoutManager(status_widget_); | 864 new internal::ShelfLayoutManager(tray_->widget()); |
921 GetContainer(internal::kShellWindowId_LauncherContainer)-> | 865 GetContainer(internal::kShellWindowId_LauncherContainer)-> |
922 SetLayoutManager(shelf_layout_manager); | 866 SetLayoutManager(shelf_layout_manager); |
923 shelf_ = shelf_layout_manager; | 867 shelf_ = shelf_layout_manager; |
924 | 868 |
925 internal::StatusAreaLayoutManager* status_area_layout_manager = | 869 internal::StatusAreaLayoutManager* status_area_layout_manager = |
926 new internal::StatusAreaLayoutManager(shelf_layout_manager); | 870 new internal::StatusAreaLayoutManager(shelf_layout_manager); |
927 GetContainer(internal::kShellWindowId_StatusContainer)-> | 871 GetContainer(internal::kShellWindowId_StatusContainer)-> |
928 SetLayoutManager(status_area_layout_manager); | 872 SetLayoutManager(status_area_layout_manager); |
929 | 873 |
930 aura::Window* default_container = | 874 aura::Window* default_container = |
(...skipping 27 matching lines...) Expand all Loading... |
958 panel_container->SetLayoutManager(panel_layout_manager_); | 902 panel_container->SetLayoutManager(panel_layout_manager_); |
959 } | 903 } |
960 } | 904 } |
961 | 905 |
962 void Shell::DisableWorkspaceGridLayout() { | 906 void Shell::DisableWorkspaceGridLayout() { |
963 if (workspace_controller_.get()) | 907 if (workspace_controller_.get()) |
964 workspace_controller_->workspace_manager()->set_grid_size(0); | 908 workspace_controller_->workspace_manager()->set_grid_size(0); |
965 } | 909 } |
966 | 910 |
967 } // namespace ash | 911 } // namespace ash |
OLD | NEW |