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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
675 | 661 |
676 stacking_controller_.reset(new internal::StackingController); | 662 stacking_controller_.reset(new internal::StackingController); |
677 | 663 |
678 root_window_layout_ = new internal::RootWindowLayoutManager(root_window); | 664 root_window_layout_ = new internal::RootWindowLayoutManager(root_window); |
679 root_window->SetLayoutManager(root_window_layout_); | 665 root_window->SetLayoutManager(root_window_layout_); |
680 | 666 |
681 event_client_.reset(new internal::EventClientImpl(root_window)); | 667 event_client_.reset(new internal::EventClientImpl(root_window)); |
682 | 668 |
683 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 669 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
684 | 670 |
685 // TODO(sad): All of these initialization should happen in SystemTray. | |
686 tray_.reset(new SystemTray()); | 671 tray_.reset(new SystemTray()); |
Ben Goodger (Google)
2012/04/24 14:57:49
food for thought (and a different CL)
ideally it'
sadrul
2012/04/24 15:36:55
Indeed. That would allow us to move DummySystemTra
| |
687 if (delegate_.get()) | 672 if (delegate_.get()) |
688 tray_delegate_.reset(delegate_->CreateSystemTrayDelegate(tray_.get())); | 673 tray_delegate_.reset(delegate_->CreateSystemTrayDelegate(tray_.get())); |
689 if (!tray_delegate_.get()) | 674 if (!tray_delegate_.get()) |
690 tray_delegate_.reset(new DummySystemTrayDelegate()); | 675 tray_delegate_.reset(new DummySystemTrayDelegate()); |
691 | 676 tray_->CreateItems(); |
692 internal::TrayVolume* tray_volume = new internal::TrayVolume(); | 677 tray_->CreateWidget(); |
693 internal::TrayBluetooth* tray_bluetooth = new internal::TrayBluetooth(); | |
694 internal::TrayBrightness* tray_brightness = new internal::TrayBrightness(); | |
695 internal::TrayDate* tray_date = new internal::TrayDate(); | |
696 internal::TrayPower* tray_power = new internal::TrayPower(); | |
697 internal::TrayNetwork* tray_network = new internal::TrayNetwork; | |
698 internal::TrayUser* tray_user = new internal::TrayUser; | |
699 internal::TrayAccessibility* tray_accessibility = | |
700 new internal::TrayAccessibility; | |
701 internal::TrayCapsLock* tray_caps_lock = new internal::TrayCapsLock; | |
702 internal::TrayIME* tray_ime = new internal::TrayIME; | |
703 internal::TrayUpdate* tray_update = new internal::TrayUpdate; | |
704 | |
705 tray_->accessibility_observer_ = tray_accessibility; | |
706 tray_->audio_observer_ = tray_volume; | |
707 tray_->bluetooth_observer_ = tray_bluetooth; | |
708 tray_->brightness_observer_ = tray_brightness; | |
709 tray_->caps_lock_observer_ = tray_caps_lock; | |
710 tray_->clock_observer_ = tray_date; | |
711 tray_->ime_observer_ = tray_ime; | |
712 tray_->network_observer_ = tray_network; | |
713 tray_->power_status_observer_ = tray_power; | |
714 tray_->update_observer_ = tray_update; | |
715 tray_->user_observer_ = tray_user; | |
716 | |
717 tray_->AddTrayItem(tray_user); | |
718 tray_->AddTrayItem(new internal::TrayEmpty()); | |
719 tray_->AddTrayItem(tray_power); | |
720 tray_->AddTrayItem(tray_network); | |
721 tray_->AddTrayItem(tray_bluetooth); | |
722 tray_->AddTrayItem(tray_ime); | |
723 tray_->AddTrayItem(tray_volume); | |
724 tray_->AddTrayItem(tray_brightness); | |
725 tray_->AddTrayItem(tray_update); | |
726 tray_->AddTrayItem(new internal::TraySettings()); | |
727 tray_->AddTrayItem(tray_accessibility); | |
728 tray_->AddTrayItem(tray_caps_lock); | |
729 tray_->AddTrayItem(tray_date); | |
730 tray_->SetVisible(tray_delegate_->GetTrayVisibilityOnStartup()); | |
731 | |
732 // TODO(sad): Replace uses of status_widget_ with tray_->GetWidget(). | |
733 status_widget_ = internal::CreateStatusArea(tray_.get()); | |
734 | 678 |
735 // This controller needs to be set before SetupManagedWindowMode. | 679 // This controller needs to be set before SetupManagedWindowMode. |
736 desktop_background_controller_.reset(new DesktopBackgroundController); | 680 desktop_background_controller_.reset(new DesktopBackgroundController); |
737 if (delegate_.get()) | 681 if (delegate_.get()) |
738 user_wallpaper_delegate_.reset(delegate_->CreateUserWallpaperDelegate()); | 682 user_wallpaper_delegate_.reset(delegate_->CreateUserWallpaperDelegate()); |
739 if (!user_wallpaper_delegate_.get()) | 683 if (!user_wallpaper_delegate_.get()) |
740 user_wallpaper_delegate_.reset(new DummyUserWallpaperDelegate()); | 684 user_wallpaper_delegate_.reset(new DummyUserWallpaperDelegate()); |
741 | 685 |
742 InitLayoutManagers(); | 686 InitLayoutManagers(); |
743 | 687 |
744 if (!command_line->HasSwitch(switches::kAuraNoShadows)) { | 688 if (!command_line->HasSwitch(switches::kAuraNoShadows)) { |
745 resize_shadow_controller_.reset(new internal::ResizeShadowController()); | 689 resize_shadow_controller_.reset(new internal::ResizeShadowController()); |
746 shadow_controller_.reset(new internal::ShadowController()); | 690 shadow_controller_.reset(new internal::ShadowController()); |
747 } | 691 } |
748 | 692 |
749 focus_cycler_.reset(new internal::FocusCycler()); | 693 focus_cycler_.reset(new internal::FocusCycler()); |
750 focus_cycler_->AddWidget(status_widget_); | 694 focus_cycler_->AddWidget(tray_->widget()); |
751 | 695 |
752 if (!delegate_.get() || delegate_->IsUserLoggedIn()) | 696 if (!delegate_.get() || delegate_->IsUserLoggedIn()) |
753 CreateLauncher(); | 697 CreateLauncher(); |
754 | 698 |
755 // Force a layout. | 699 // Force a layout. |
756 root_window->layout_manager()->OnWindowResized(); | 700 root_window->layout_manager()->OnWindowResized(); |
757 | 701 |
758 window_modality_controller_.reset(new internal::WindowModalityController); | 702 window_modality_controller_.reset(new internal::WindowModalityController); |
759 AddRootWindowEventFilter(window_modality_controller_.get()); | 703 AddRootWindowEventFilter(window_modality_controller_.get()); |
760 | 704 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
908 | 852 |
909 bool Shell::IsInMaximizedMode() const { | 853 bool Shell::IsInMaximizedMode() const { |
910 return workspace_controller_->workspace_manager()->IsInMaximizedMode(); | 854 return workspace_controller_->workspace_manager()->IsInMaximizedMode(); |
911 } | 855 } |
912 | 856 |
913 //////////////////////////////////////////////////////////////////////////////// | 857 //////////////////////////////////////////////////////////////////////////////// |
914 // Shell, private: | 858 // Shell, private: |
915 | 859 |
916 void Shell::InitLayoutManagers() { | 860 void Shell::InitLayoutManagers() { |
917 DCHECK(root_window_layout_); | 861 DCHECK(root_window_layout_); |
918 DCHECK(status_widget_); | 862 DCHECK(tray_->widget()); |
919 | 863 |
920 internal::ShelfLayoutManager* shelf_layout_manager = | 864 internal::ShelfLayoutManager* shelf_layout_manager = |
921 new internal::ShelfLayoutManager(status_widget_); | 865 new internal::ShelfLayoutManager(tray_->widget()); |
922 GetContainer(internal::kShellWindowId_LauncherContainer)-> | 866 GetContainer(internal::kShellWindowId_LauncherContainer)-> |
923 SetLayoutManager(shelf_layout_manager); | 867 SetLayoutManager(shelf_layout_manager); |
924 shelf_ = shelf_layout_manager; | 868 shelf_ = shelf_layout_manager; |
925 | 869 |
926 internal::StatusAreaLayoutManager* status_area_layout_manager = | 870 internal::StatusAreaLayoutManager* status_area_layout_manager = |
927 new internal::StatusAreaLayoutManager(shelf_layout_manager); | 871 new internal::StatusAreaLayoutManager(shelf_layout_manager); |
928 GetContainer(internal::kShellWindowId_StatusContainer)-> | 872 GetContainer(internal::kShellWindowId_StatusContainer)-> |
929 SetLayoutManager(status_area_layout_manager); | 873 SetLayoutManager(status_area_layout_manager); |
930 | 874 |
931 aura::Window* default_container = | 875 aura::Window* default_container = |
(...skipping 27 matching lines...) Expand all Loading... | |
959 panel_container->SetLayoutManager(panel_layout_manager_); | 903 panel_container->SetLayoutManager(panel_layout_manager_); |
960 } | 904 } |
961 } | 905 } |
962 | 906 |
963 void Shell::DisableWorkspaceGridLayout() { | 907 void Shell::DisableWorkspaceGridLayout() { |
964 if (workspace_controller_.get()) | 908 if (workspace_controller_.get()) |
965 workspace_controller_->workspace_manager()->set_grid_size(0); | 909 workspace_controller_->workspace_manager()->set_grid_size(0); |
966 } | 910 } |
967 | 911 |
968 } // namespace ash | 912 } // namespace ash |
OLD | NEW |