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/accelerator_controller.h" | 10 #include "ash/accelerators/accelerator_controller.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "ash/first_run/first_run_helper_impl.h" | 26 #include "ash/first_run/first_run_helper_impl.h" |
27 #include "ash/focus_cycler.h" | 27 #include "ash/focus_cycler.h" |
28 #include "ash/frame/custom_frame_view_ash.h" | 28 #include "ash/frame/custom_frame_view_ash.h" |
29 #include "ash/gpu_support.h" | 29 #include "ash/gpu_support.h" |
30 #include "ash/high_contrast/high_contrast_controller.h" | 30 #include "ash/high_contrast/high_contrast_controller.h" |
31 #include "ash/host/ash_window_tree_host_init_params.h" | 31 #include "ash/host/ash_window_tree_host_init_params.h" |
32 #include "ash/keyboard_uma_event_filter.h" | 32 #include "ash/keyboard_uma_event_filter.h" |
33 #include "ash/magnifier/magnification_controller.h" | 33 #include "ash/magnifier/magnification_controller.h" |
34 #include "ash/magnifier/partial_magnification_controller.h" | 34 #include "ash/magnifier/partial_magnification_controller.h" |
35 #include "ash/media_delegate.h" | 35 #include "ash/media_delegate.h" |
| 36 #include "ash/metrics/screen_event_task_switch_metric_recorder.h" |
36 #include "ash/new_window_delegate.h" | 37 #include "ash/new_window_delegate.h" |
37 #include "ash/root_window_controller.h" | 38 #include "ash/root_window_controller.h" |
38 #include "ash/session/session_state_delegate.h" | 39 #include "ash/session/session_state_delegate.h" |
39 #include "ash/shelf/app_list_shelf_item_delegate.h" | 40 #include "ash/shelf/app_list_shelf_item_delegate.h" |
40 #include "ash/shelf/shelf_delegate.h" | 41 #include "ash/shelf/shelf_delegate.h" |
41 #include "ash/shelf/shelf_item_delegate.h" | 42 #include "ash/shelf/shelf_item_delegate.h" |
42 #include "ash/shelf/shelf_item_delegate_manager.h" | 43 #include "ash/shelf/shelf_item_delegate_manager.h" |
43 #include "ash/shelf/shelf_layout_manager.h" | 44 #include "ash/shelf/shelf_layout_manager.h" |
44 #include "ash/shelf/shelf_model.h" | 45 #include "ash/shelf/shelf_model.h" |
45 #include "ash/shelf/shelf_widget.h" | 46 #include "ash/shelf/shelf_widget.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 #include "ui/views/focus/focus_manager_factory.h" | 106 #include "ui/views/focus/focus_manager_factory.h" |
106 #include "ui/views/widget/native_widget_aura.h" | 107 #include "ui/views/widget/native_widget_aura.h" |
107 #include "ui/views/widget/widget.h" | 108 #include "ui/views/widget/widget.h" |
108 #include "ui/wm/core/accelerator_filter.h" | 109 #include "ui/wm/core/accelerator_filter.h" |
109 #include "ui/wm/core/compound_event_filter.h" | 110 #include "ui/wm/core/compound_event_filter.h" |
110 #include "ui/wm/core/focus_controller.h" | 111 #include "ui/wm/core/focus_controller.h" |
111 #include "ui/wm/core/input_method_event_filter.h" | 112 #include "ui/wm/core/input_method_event_filter.h" |
112 #include "ui/wm/core/nested_accelerator_controller.h" | 113 #include "ui/wm/core/nested_accelerator_controller.h" |
113 #include "ui/wm/core/shadow_controller.h" | 114 #include "ui/wm/core/shadow_controller.h" |
114 #include "ui/wm/core/visibility_controller.h" | 115 #include "ui/wm/core/visibility_controller.h" |
| 116 #include "ui/wm/core/window_activation_pre_target_handler.h" |
115 #include "ui/wm/core/window_modality_controller.h" | 117 #include "ui/wm/core/window_modality_controller.h" |
116 | 118 |
117 #if defined(OS_CHROMEOS) | 119 #if defined(OS_CHROMEOS) |
118 #if defined(USE_X11) | 120 #if defined(USE_X11) |
119 #include "ui/gfx/x/x11_types.h" | 121 #include "ui/gfx/x/x11_types.h" |
120 #endif // defined(USE_X11) | 122 #endif // defined(USE_X11) |
121 #include "ash/accelerators/magnifier_key_scroller.h" | 123 #include "ash/accelerators/magnifier_key_scroller.h" |
122 #include "ash/accelerators/spoken_feedback_toggler.h" | 124 #include "ash/accelerators/spoken_feedback_toggler.h" |
123 #include "ash/ash_constants.h" | 125 #include "ash/ash_constants.h" |
124 #include "ash/content/display/display_color_manager_chromeos.h" | 126 #include "ash/content/display/display_color_manager_chromeos.h" |
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 // |shelf_window_watcher_| has a weak pointer to |shelf_Model_| | 757 // |shelf_window_watcher_| has a weak pointer to |shelf_Model_| |
756 // and has window observers. | 758 // and has window observers. |
757 shelf_window_watcher_.reset(); | 759 shelf_window_watcher_.reset(); |
758 | 760 |
759 // Destroy all child windows including widgets. | 761 // Destroy all child windows including widgets. |
760 display_controller_->CloseChildWindows(); | 762 display_controller_->CloseChildWindows(); |
761 | 763 |
762 // Chrome implementation of shelf delegate depends on FocusClient, | 764 // Chrome implementation of shelf delegate depends on FocusClient, |
763 // so must be deleted before |focus_client_|. | 765 // so must be deleted before |focus_client_|. |
764 shelf_delegate_.reset(); | 766 shelf_delegate_.reset(); |
| 767 window_activation_pretarget_handler_->RemoveObserver( |
| 768 screen_event_task_switch_metric_recorder_.get()); |
| 769 screen_event_task_switch_metric_recorder_.reset(); |
| 770 // TODO(bruthig): Investigate why the |window_activation_pretarget_handler_| |
| 771 // is not removed from pre-target handler lists. |
| 772 window_activation_pretarget_handler_.reset(); |
765 focus_client_.reset(); | 773 focus_client_.reset(); |
766 | 774 |
767 // Destroy SystemTrayNotifier after destroying SystemTray as TrayItems | 775 // Destroy SystemTrayNotifier after destroying SystemTray as TrayItems |
768 // needs to remove observers from it. | 776 // needs to remove observers from it. |
769 system_tray_notifier_.reset(); | 777 system_tray_notifier_.reset(); |
770 | 778 |
771 // These need a valid Shell instance to clean up properly, so explicitly | 779 // These need a valid Shell instance to clean up properly, so explicitly |
772 // delete them before invalidating the instance. | 780 // delete them before invalidating the instance. |
773 // Alphabetical. TODO(oshima): sort. | 781 // Alphabetical. TODO(oshima): sort. |
774 magnification_controller_.reset(); | 782 magnification_controller_.reset(); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
887 | 895 |
888 env_filter_.reset(new ::wm::CompoundEventFilter); | 896 env_filter_.reset(new ::wm::CompoundEventFilter); |
889 AddPreTargetHandler(env_filter_.get()); | 897 AddPreTargetHandler(env_filter_.get()); |
890 | 898 |
891 wm::AshFocusRules* focus_rules = new wm::AshFocusRules(); | 899 wm::AshFocusRules* focus_rules = new wm::AshFocusRules(); |
892 | 900 |
893 ::wm::FocusController* focus_controller = | 901 ::wm::FocusController* focus_controller = |
894 new ::wm::FocusController(focus_rules); | 902 new ::wm::FocusController(focus_rules); |
895 focus_client_.reset(focus_controller); | 903 focus_client_.reset(focus_controller); |
896 activation_client_ = focus_controller; | 904 activation_client_ = focus_controller; |
| 905 window_activation_pretarget_handler_.reset( |
| 906 new ::wm::WindowActivationPreTargetHandler(activation_client_)); |
| 907 screen_event_task_switch_metric_recorder_.reset( |
| 908 new ScreenEventTaskSwitchMetricRecorder(user_metrics_recorder_.get())); |
| 909 window_activation_pretarget_handler_->AddObserver( |
| 910 screen_event_task_switch_metric_recorder_.get()); |
897 activation_client_->AddObserver(this); | 911 activation_client_->AddObserver(this); |
898 focus_cycler_.reset(new FocusCycler()); | 912 focus_cycler_.reset(new FocusCycler()); |
899 | 913 |
900 screen_position_controller_.reset(new ScreenPositionController); | 914 screen_position_controller_.reset(new ScreenPositionController); |
901 | 915 |
902 display_controller_->Start(); | 916 display_controller_->Start(); |
903 display_controller_->CreatePrimaryHost( | 917 display_controller_->CreatePrimaryHost( |
904 ShellInitParamsToAshWindowTreeHostInitParams(init_params)); | 918 ShellInitParamsToAshWindowTreeHostInitParams(init_params)); |
905 aura::Window* root_window = display_controller_->GetPrimaryRootWindow(); | 919 aura::Window* root_window = display_controller_->GetPrimaryRootWindow(); |
906 target_root_window_ = root_window; | 920 target_root_window_ = root_window; |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1104 } | 1118 } |
1105 | 1119 |
1106 void Shell::InitRootWindow(aura::Window* root_window) { | 1120 void Shell::InitRootWindow(aura::Window* root_window) { |
1107 DCHECK(activation_client_); | 1121 DCHECK(activation_client_); |
1108 DCHECK(visibility_controller_.get()); | 1122 DCHECK(visibility_controller_.get()); |
1109 DCHECK(drag_drop_controller_.get()); | 1123 DCHECK(drag_drop_controller_.get()); |
1110 | 1124 |
1111 aura::client::SetFocusClient(root_window, focus_client_.get()); | 1125 aura::client::SetFocusClient(root_window, focus_client_.get()); |
1112 input_method_filter_->SetInputMethodPropertyInRootWindow(root_window); | 1126 input_method_filter_->SetInputMethodPropertyInRootWindow(root_window); |
1113 aura::client::SetActivationClient(root_window, activation_client_); | 1127 aura::client::SetActivationClient(root_window, activation_client_); |
1114 ::wm::FocusController* focus_controller = | 1128 root_window->AddPreTargetHandler(window_activation_pretarget_handler_.get()); |
1115 static_cast< ::wm::FocusController*>(activation_client_); | |
1116 root_window->AddPreTargetHandler(focus_controller); | |
1117 aura::client::SetVisibilityClient(root_window, visibility_controller_.get()); | 1129 aura::client::SetVisibilityClient(root_window, visibility_controller_.get()); |
1118 aura::client::SetDragDropClient(root_window, drag_drop_controller_.get()); | 1130 aura::client::SetDragDropClient(root_window, drag_drop_controller_.get()); |
1119 aura::client::SetScreenPositionClient(root_window, | 1131 aura::client::SetScreenPositionClient(root_window, |
1120 screen_position_controller_.get()); | 1132 screen_position_controller_.get()); |
1121 aura::client::SetCursorClient(root_window, &cursor_manager_); | 1133 aura::client::SetCursorClient(root_window, &cursor_manager_); |
1122 aura::client::SetTooltipClient(root_window, tooltip_controller_.get()); | 1134 aura::client::SetTooltipClient(root_window, tooltip_controller_.get()); |
1123 aura::client::SetEventClient(root_window, event_client_.get()); | 1135 aura::client::SetEventClient(root_window, event_client_.get()); |
1124 | 1136 |
1125 aura::client::SetWindowMoveClient(root_window, | 1137 aura::client::SetWindowMoveClient(root_window, |
1126 toplevel_window_event_handler_.get()); | 1138 toplevel_window_event_handler_.get()); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1176 //////////////////////////////////////////////////////////////////////////////// | 1188 //////////////////////////////////////////////////////////////////////////////// |
1177 // Shell, aura::client::ActivationChangeObserver implementation: | 1189 // Shell, aura::client::ActivationChangeObserver implementation: |
1178 | 1190 |
1179 void Shell::OnWindowActivated(aura::Window* gained_active, | 1191 void Shell::OnWindowActivated(aura::Window* gained_active, |
1180 aura::Window* lost_active) { | 1192 aura::Window* lost_active) { |
1181 if (gained_active) | 1193 if (gained_active) |
1182 target_root_window_ = gained_active->GetRootWindow(); | 1194 target_root_window_ = gained_active->GetRootWindow(); |
1183 } | 1195 } |
1184 | 1196 |
1185 } // namespace ash | 1197 } // namespace ash |
OLD | NEW |