[email protected] | e0d22e8 | 2012-01-04 00:46:57 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | b65bdda | 2011-12-23 23:35:31 | [diff] [blame] | 5 | #include "ash/shell.h" |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 6 | |
[email protected] | f7eb89c | 2011-12-13 09:48:54 | [diff] [blame] | 7 | #include <algorithm> |
[email protected] | 0039db9 | 2012-05-09 04:11:45 | [diff] [blame] | 8 | #include <string> |
[email protected] | f7eb89c | 2011-12-13 09:48:54 | [diff] [blame] | 9 | |
[email protected] | e7293fa | 2012-05-17 04:42:33 | [diff] [blame] | 10 | #include "ash/accelerators/focus_manager_factory.h" |
[email protected] | b65bdda | 2011-12-23 23:35:31 | [diff] [blame] | 11 | #include "ash/ash_switches.h" |
[email protected] | 02dbd1a | 2012-11-08 22:50:13 | [diff] [blame] | 12 | #include "ash/caps_lock_delegate.h" |
[email protected] | e70cf0ed | 2012-03-15 16:24:47 | [diff] [blame] | 13 | #include "ash/desktop_background/desktop_background_controller.h" |
| 14 | #include "ash/desktop_background/desktop_background_resources.h" |
| 15 | #include "ash/desktop_background/desktop_background_view.h" |
[email protected] | 81abb103 | 2012-11-13 18:55:41 | [diff] [blame] | 16 | #include "ash/desktop_background/user_wallpaper_delegate.h" |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 17 | #include "ash/display/display_controller.h" |
| 18 | #include "ash/display/mouse_cursor_event_filter.h" |
[email protected] | 6bdf795 | 2012-11-14 10:10:58 | [diff] [blame] | 19 | #include "ash/display/display_manager.h" |
[email protected] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 20 | #include "ash/display/screen_position_controller.h" |
[email protected] | f4c92b38 | 2012-08-28 00:59:59 | [diff] [blame] | 21 | #include "ash/drag_drop/drag_drop_controller.h" |
| 22 | #include "ash/focus_cycler.h" |
| 23 | #include "ash/high_contrast/high_contrast_controller.h" |
[email protected] | f4c92b38 | 2012-08-28 00:59:59 | [diff] [blame] | 24 | #include "ash/magnifier/magnification_controller.h" |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 25 | #include "ash/root_window_controller.h" |
[email protected] | 1a2145b | 2012-03-13 21:09:17 | [diff] [blame] | 26 | #include "ash/screen_ash.h" |
[email protected] | b65bdda | 2011-12-23 23:35:31 | [diff] [blame] | 27 | #include "ash/shell_delegate.h" |
| 28 | #include "ash/shell_factory.h" |
| 29 | #include "ash/shell_window_ids.h" |
[email protected] | 6d6546e | 2012-05-30 23:12:02 | [diff] [blame] | 30 | #include "ash/system/status_area_widget.h" |
[email protected] | 51ed599 | 2012-11-07 10:14:39 | [diff] [blame] | 31 | #include "ash/system/tray/system_tray_delegate.h" |
[email protected] | 83b2b84c | 2012-11-14 01:11:00 | [diff] [blame] | 32 | #include "ash/system/tray/system_tray_notifier.h" |
[email protected] | 2f74428 | 2011-12-23 22:40:52 | [diff] [blame] | 33 | #include "ash/tooltips/tooltip_controller.h" |
[email protected] | 7307474 | 2012-05-17 01:44:41 | [diff] [blame] | 34 | #include "ash/touch/touch_observer_hud.h" |
[email protected] | 7634f96 | 2011-12-23 21:35:52 | [diff] [blame] | 35 | #include "ash/wm/activation_controller.h" |
[email protected] | f059c694 | 2012-07-21 14:27:57 | [diff] [blame] | 36 | #include "ash/wm/always_on_top_controller.h" |
[email protected] | 0039db9 | 2012-05-09 04:11:45 | [diff] [blame] | 37 | #include "ash/wm/app_list_controller.h" |
[email protected] | 8812588c | 2012-01-30 21:19:03 | [diff] [blame] | 38 | #include "ash/wm/base_layout_manager.h" |
[email protected] | 60a978b7 | 2012-06-08 00:29:18 | [diff] [blame] | 39 | #include "ash/wm/capture_controller.h" |
[email protected] | 88d7112 | 2012-10-18 07:11:01 | [diff] [blame] | 40 | #include "ash/wm/coordinate_conversion.h" |
[email protected] | 9d4d171 | 2012-03-06 06:55:25 | [diff] [blame] | 41 | #include "ash/wm/custom_frame_view_ash.h" |
[email protected] | 57b8bb35 | 2012-01-11 05:11:46 | [diff] [blame] | 42 | #include "ash/wm/dialog_frame_view.h" |
[email protected] | 262f8bd | 2012-03-23 19:30:27 | [diff] [blame] | 43 | #include "ash/wm/event_client_impl.h" |
[email protected] | b9d224c | 2012-07-13 01:09:03 | [diff] [blame] | 44 | #include "ash/wm/event_rewriter_event_filter.h" |
[email protected] | 9ae32df | 2012-07-26 03:25:18 | [diff] [blame] | 45 | #include "ash/wm/overlay_event_filter.h" |
[email protected] | e0d22e8 | 2012-01-04 00:46:57 | [diff] [blame] | 46 | #include "ash/wm/power_button_controller.h" |
[email protected] | 7ae52500 | 2012-07-26 23:55:10 | [diff] [blame] | 47 | #include "ash/wm/property_util.h" |
[email protected] | e4a181cc | 2012-03-17 02:20:57 | [diff] [blame] | 48 | #include "ash/wm/resize_shadow_controller.h" |
[email protected] | a3301dc | 2011-12-23 16:34:51 | [diff] [blame] | 49 | #include "ash/wm/root_window_layout_manager.h" |
[email protected] | 4299321 | 2012-04-30 23:42:04 | [diff] [blame] | 50 | #include "ash/wm/screen_dimmer.h" |
[email protected] | 222f40c | 2012-10-18 08:58:13 | [diff] [blame] | 51 | #include "ash/wm/session_state_controller.h" |
[email protected] | 839667d6 | 2012-10-23 19:38:57 | [diff] [blame] | 52 | #include "ash/wm/session_state_controller_impl.h" |
| 53 | #include "ash/wm/session_state_controller_impl2.h" |
[email protected] | 7585967 | 2011-12-23 01:04:56 | [diff] [blame] | 54 | #include "ash/wm/stacking_controller.h" |
[email protected] | 435b212e | 2012-04-05 19:43:37 | [diff] [blame] | 55 | #include "ash/wm/system_gesture_event_filter.h" |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 56 | #include "ash/wm/system_modal_container_event_filter.h" |
[email protected] | 4244d699 | 2012-01-23 17:14:33 | [diff] [blame] | 57 | #include "ash/wm/system_modal_container_layout_manager.h" |
[email protected] | c16b942 | 2012-06-06 21:51:11 | [diff] [blame] | 58 | #include "ash/wm/user_activity_detector.h" |
[email protected] | 9633a9d2 | 2012-01-21 16:40:58 | [diff] [blame] | 59 | #include "ash/wm/video_detector.h" |
[email protected] | ddd91e9 | 2012-01-27 16:03:48 | [diff] [blame] | 60 | #include "ash/wm/visibility_controller.h" |
[email protected] | 40c4cbb | 2012-01-10 23:26:07 | [diff] [blame] | 61 | #include "ash/wm/window_cycle_controller.h" |
[email protected] | 8037357 | 2012-01-06 23:14:30 | [diff] [blame] | 62 | #include "ash/wm/window_modality_controller.h" |
[email protected] | f059c694 | 2012-07-21 14:27:57 | [diff] [blame] | 63 | #include "ash/wm/window_properties.h" |
[email protected] | f4c92b38 | 2012-08-28 00:59:59 | [diff] [blame] | 64 | #include "ash/wm/window_util.h" |
[email protected] | c783955 | 2012-04-03 21:14:36 | [diff] [blame] | 65 | #include "ash/wm/workspace_controller.h" |
[email protected] | f296be7 | 2011-10-11 15:40:00 | [diff] [blame] | 66 | #include "base/bind.h" |
[email protected] | 46ca363 | 2011-11-03 03:33:42 | [diff] [blame] | 67 | #include "base/command_line.h" |
[email protected] | b0a8faa | 2012-10-19 03:22:22 | [diff] [blame] | 68 | #include "base/debug/leak_annotations.h" |
[email protected] | 2c45610 | 2011-12-26 06:26:34 | [diff] [blame] | 69 | #include "ui/aura/client/aura_constants.h" |
[email protected] | d8f1004 | 2012-11-14 01:10:46 | [diff] [blame] | 70 | #include "ui/aura/client/stacking_client.h" |
[email protected] | c2885361 | 2012-05-31 22:43:44 | [diff] [blame] | 71 | #include "ui/aura/client/user_action_client.h" |
[email protected] | 8a45c97 | 2012-03-14 18:22:44 | [diff] [blame] | 72 | #include "ui/aura/env.h" |
[email protected] | a857dbe | 2012-05-30 22:10:14 | [diff] [blame] | 73 | #include "ui/aura/focus_manager.h" |
[email protected] | 4bb1650 | 2011-12-06 14:44:58 | [diff] [blame] | 74 | #include "ui/aura/layout_manager.h" |
[email protected] | 2c45610 | 2011-12-26 06:26:34 | [diff] [blame] | 75 | #include "ui/aura/root_window.h" |
[email protected] | 536f808 | 2012-03-16 09:30:33 | [diff] [blame] | 76 | #include "ui/aura/ui_controls_aura.h" |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 77 | #include "ui/aura/window.h" |
[email protected] | 116302fc | 2012-05-05 21:45:41 | [diff] [blame] | 78 | #include "ui/compositor/layer.h" |
| 79 | #include "ui/compositor/layer_animator.h" |
[email protected] | 7da9c4c | 2012-06-12 14:43:01 | [diff] [blame] | 80 | #include "ui/gfx/display.h" |
[email protected] | 9ec0f45 | 2012-05-31 15:58:53 | [diff] [blame] | 81 | #include "ui/gfx/image/image_skia.h" |
[email protected] | b82c42c4 | 2012-04-25 20:03:41 | [diff] [blame] | 82 | #include "ui/gfx/screen.h" |
[email protected] | b063928 | 2011-12-22 21:12:27 | [diff] [blame] | 83 | #include "ui/gfx/size.h" |
[email protected] | 536f808 | 2012-03-16 09:30:33 | [diff] [blame] | 84 | #include "ui/ui_controls/ui_controls.h" |
[email protected] | 4a59e4e | 2012-11-12 21:15:40 | [diff] [blame] | 85 | #include "ui/views/corewm/compound_event_filter.h" |
| 86 | #include "ui/views/corewm/input_method_event_filter.h" |
[email protected] | 86f2b5e | 2012-11-14 20:37:00 | [diff] [blame^] | 87 | #include "ui/views/corewm/shadow_controller.h" |
[email protected] | e7293fa | 2012-05-17 04:42:33 | [diff] [blame] | 88 | #include "ui/views/focus/focus_manager_factory.h" |
[email protected] | c13be0d | 2011-11-22 02:09:58 | [diff] [blame] | 89 | #include "ui/views/widget/native_widget_aura.h" |
| 90 | #include "ui/views/widget/widget.h" |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 91 | |
[email protected] | 6e9f6aa | 2012-02-09 04:16:20 | [diff] [blame] | 92 | #if !defined(OS_MACOSX) |
| 93 | #include "ash/accelerators/accelerator_controller.h" |
| 94 | #include "ash/accelerators/accelerator_filter.h" |
| 95 | #include "ash/accelerators/nested_dispatcher_controller.h" |
| 96 | #endif |
| 97 | |
[email protected] | 70b3e7d5 | 2012-06-02 22:12:25 | [diff] [blame] | 98 | #if defined(OS_CHROMEOS) |
[email protected] | 6bdf795 | 2012-11-14 10:10:58 | [diff] [blame] | 99 | #include "ash/display/display_change_observer_x11.h" |
[email protected] | 196e945 | 2012-08-01 06:42:51 | [diff] [blame] | 100 | #include "ash/display/output_configurator_animation.h" |
[email protected] | 6bdf795 | 2012-11-14 10:10:58 | [diff] [blame] | 101 | #include "base/chromeos/chromeos_version.h" |
[email protected] | 4168ad7 | 2012-08-30 16:57:21 | [diff] [blame] | 102 | #include "base/message_pump_aurax11.h" |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 103 | #include "chromeos/display/output_configurator.h" |
[email protected] | 7158db1 | 2012-10-15 22:19:31 | [diff] [blame] | 104 | #include "content/public/browser/gpu_data_manager.h" |
| 105 | #include "content/public/common/gpu_feature_type.h" |
[email protected] | 70b3e7d5 | 2012-06-02 22:12:25 | [diff] [blame] | 106 | #endif // defined(OS_CHROMEOS) |
| 107 | |
[email protected] | 55f59335 | 2011-12-24 05:42:46 | [diff] [blame] | 108 | namespace ash { |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 109 | |
| 110 | namespace { |
[email protected] | 671a2ae | 2011-10-13 21:53:23 | [diff] [blame] | 111 | |
[email protected] | 615922f | 2012-02-07 02:41:15 | [diff] [blame] | 112 | using aura::Window; |
[email protected] | 3f02dc5 | 2011-10-21 19:36:45 | [diff] [blame] | 113 | using views::Widget; |
| 114 | |
[email protected] | 10b2261 | 2012-03-22 17:07:55 | [diff] [blame] | 115 | // This dummy class is used for shell unit tests. We dont have chrome delegate |
| 116 | // in these tests. |
[email protected] | 5c54324 | 2012-03-24 16:25:42 | [diff] [blame] | 117 | class DummyUserWallpaperDelegate : public UserWallpaperDelegate { |
[email protected] | 10b2261 | 2012-03-22 17:07:55 | [diff] [blame] | 118 | public: |
| 119 | DummyUserWallpaperDelegate() {} |
| 120 | |
| 121 | virtual ~DummyUserWallpaperDelegate() {} |
| 122 | |
[email protected] | 815d0c38 | 2012-07-21 08:13:44 | [diff] [blame] | 123 | virtual ash::WindowVisibilityAnimationType GetAnimationType() OVERRIDE { |
| 124 | return WINDOW_VISIBILITY_ANIMATION_TYPE_FADE; |
| 125 | } |
| 126 | |
[email protected] | bca9a7e | 2012-11-10 06:25:49 | [diff] [blame] | 127 | virtual bool ShouldShowInitialAnimation() OVERRIDE { |
| 128 | return false; |
| 129 | } |
| 130 | |
[email protected] | c10baf7 | 2012-11-01 18:24:32 | [diff] [blame] | 131 | virtual void UpdateWallpaper() OVERRIDE { |
| 132 | } |
| 133 | |
[email protected] | 0c4f87d | 2012-06-12 02:00:35 | [diff] [blame] | 134 | virtual void InitializeWallpaper() OVERRIDE { |
[email protected] | d5003473 | 2012-06-04 19:11:04 | [diff] [blame] | 135 | ash::Shell::GetInstance()->desktop_background_controller()-> |
| 136 | CreateEmptyWallpaper(); |
[email protected] | 10b2261 | 2012-03-22 17:07:55 | [diff] [blame] | 137 | } |
| 138 | |
[email protected] | 5c54324 | 2012-03-24 16:25:42 | [diff] [blame] | 139 | virtual void OpenSetWallpaperPage() OVERRIDE { |
| 140 | } |
| 141 | |
[email protected] | 0cfc18e | 2012-04-11 18:17:47 | [diff] [blame] | 142 | virtual bool CanOpenSetWallpaperPage() OVERRIDE { |
| 143 | return false; |
| 144 | } |
| 145 | |
[email protected] | 07a2fa6 | 2012-06-26 10:39:38 | [diff] [blame] | 146 | virtual void OnWallpaperAnimationFinished() OVERRIDE { |
| 147 | } |
| 148 | |
[email protected] | 8b04a165 | 2012-08-04 02:59:49 | [diff] [blame] | 149 | virtual void OnWallpaperBootAnimationFinished() OVERRIDE { |
| 150 | } |
| 151 | |
[email protected] | 10b2261 | 2012-03-22 17:07:55 | [diff] [blame] | 152 | private: |
[email protected] | 0039db9 | 2012-05-09 04:11:45 | [diff] [blame] | 153 | DISALLOW_COPY_AND_ASSIGN(DummyUserWallpaperDelegate); |
[email protected] | 10b2261 | 2012-03-22 17:07:55 | [diff] [blame] | 154 | }; |
| 155 | |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 156 | } // namespace |
| 157 | |
[email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 158 | // static |
| 159 | Shell* Shell::instance_ = NULL; |
[email protected] | 2b4cd30 | 2012-02-24 20:21:13 | [diff] [blame] | 160 | // static |
[email protected] | 9488d4d | 2012-02-29 18:32:37 | [diff] [blame] | 161 | bool Shell::initially_hide_cursor_ = false; |
[email protected] | 2b4cd30 | 2012-02-24 20:21:13 | [diff] [blame] | 162 | |
| 163 | //////////////////////////////////////////////////////////////////////////////// |
| 164 | // Shell::TestApi |
| 165 | |
| 166 | Shell::TestApi::TestApi(Shell* shell) : shell_(shell) {} |
| 167 | |
[email protected] | 2b4cd30 | 2012-02-24 20:21:13 | [diff] [blame] | 168 | internal::RootWindowLayoutManager* Shell::TestApi::root_window_layout() { |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 169 | return shell_->GetPrimaryRootWindowController()->root_window_layout(); |
[email protected] | 2b4cd30 | 2012-02-24 20:21:13 | [diff] [blame] | 170 | } |
[email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 171 | |
[email protected] | 4a59e4e | 2012-11-12 21:15:40 | [diff] [blame] | 172 | views::corewm::InputMethodEventFilter* |
[email protected] | 0e46c27 | 2012-05-15 18:15:23 | [diff] [blame] | 173 | Shell::TestApi::input_method_event_filter() { |
[email protected] | db913160 | 2012-02-29 19:06:32 | [diff] [blame] | 174 | return shell_->input_method_filter_.get(); |
| 175 | } |
| 176 | |
[email protected] | 435b212e | 2012-04-05 19:43:37 | [diff] [blame] | 177 | internal::SystemGestureEventFilter* |
| 178 | Shell::TestApi::system_gesture_event_filter() { |
| 179 | return shell_->system_gesture_filter_.get(); |
| 180 | } |
| 181 | |
[email protected] | db913160 | 2012-02-29 19:06:32 | [diff] [blame] | 182 | internal::WorkspaceController* Shell::TestApi::workspace_controller() { |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 183 | return shell_->GetPrimaryRootWindowController()->workspace_controller(); |
[email protected] | db913160 | 2012-02-29 19:06:32 | [diff] [blame] | 184 | } |
| 185 | |
[email protected] | 9737f8f | 2012-09-20 03:38:38 | [diff] [blame] | 186 | internal::ScreenPositionController* |
| 187 | Shell::TestApi::screen_position_controller() { |
| 188 | return shell_->screen_position_controller_.get(); |
| 189 | } |
| 190 | |
[email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 191 | //////////////////////////////////////////////////////////////////////////////// |
| 192 | // Shell, public: |
| 193 | |
[email protected] | 3266c2b9 | 2011-11-14 00:06:08 | [diff] [blame] | 194 | Shell::Shell(ShellDelegate* delegate) |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 195 | : screen_(new ScreenAsh), |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 196 | active_root_window_(NULL), |
[email protected] | 9c66adc | 2012-01-05 02:10:16 | [diff] [blame] | 197 | delegate_(delegate), |
[email protected] | 70b3e7d5 | 2012-06-02 22:12:25 | [diff] [blame] | 198 | #if defined(OS_CHROMEOS) |
[email protected] | cf1c70e | 2012-08-30 01:13:02 | [diff] [blame] | 199 | output_configurator_(new chromeos::OutputConfigurator()), |
[email protected] | 196e945 | 2012-08-01 06:42:51 | [diff] [blame] | 200 | output_configurator_animation_( |
| 201 | new internal::OutputConfiguratorAnimation()), |
[email protected] | 70b3e7d5 | 2012-06-02 22:12:25 | [diff] [blame] | 202 | #endif // defined(OS_CHROMEOS) |
[email protected] | 852a55d | 2012-10-17 13:30:30 | [diff] [blame] | 203 | browser_context_(NULL), |
| 204 | simulate_modal_window_open_for_testing_(false) { |
[email protected] | 02dbd1a | 2012-11-08 22:50:13 | [diff] [blame] | 205 | DCHECK(delegate_.get()); |
[email protected] | 6bdf795 | 2012-11-14 10:10:58 | [diff] [blame] | 206 | display_manager_.reset(new internal::DisplayManager); |
[email protected] | b0a8faa | 2012-10-19 03:22:22 | [diff] [blame] | 207 | ANNOTATE_LEAKING_OBJECT_PTR(screen_); // see crbug.com/156466 |
[email protected] | b0a8faa | 2012-10-19 03:22:22 | [diff] [blame] | 208 | gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_ALTERNATE, screen_); |
[email protected] | 5fdb45b | 2012-10-23 20:26:28 | [diff] [blame] | 209 | if (!gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE)) |
| 210 | gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_); |
[email protected] | 054b2d7 | 2012-06-08 04:52:25 | [diff] [blame] | 211 | ui_controls::InstallUIControlsAura(internal::CreateUIControls()); |
[email protected] | 70b3e7d5 | 2012-06-02 22:12:25 | [diff] [blame] | 212 | #if defined(OS_CHROMEOS) |
[email protected] | 7158db1 | 2012-10-15 22:19:31 | [diff] [blame] | 213 | content::GpuFeatureType blacklisted_features = |
| 214 | content::GpuDataManager::GetInstance()->GetBlacklistedFeatures(); |
| 215 | bool is_panel_fitting_disabled = |
| 216 | (blacklisted_features & content::GPU_FEATURE_TYPE_PANEL_FITTING) || |
| 217 | CommandLine::ForCurrentProcess()->HasSwitch( |
| 218 | switches::kAshDisablePanelFitting); |
| 219 | output_configurator_->Init(!is_panel_fitting_disabled); |
| 220 | |
[email protected] | 196e945 | 2012-08-01 06:42:51 | [diff] [blame] | 221 | output_configurator_->AddObserver(output_configurator_animation_.get()); |
[email protected] | 4168ad7 | 2012-08-30 16:57:21 | [diff] [blame] | 222 | base::MessagePumpAuraX11::Current()->AddDispatcherForRootWindow( |
| 223 | output_configurator()); |
[email protected] | 70b3e7d5 | 2012-06-02 22:12:25 | [diff] [blame] | 224 | #endif // defined(OS_CHROMEOS) |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 225 | } |
| 226 | |
| 227 | Shell::~Shell() { |
[email protected] | e7293fa | 2012-05-17 04:42:33 | [diff] [blame] | 228 | views::FocusManagerFactory::Install(NULL); |
[email protected] | cb3b8b2 | 2012-06-27 23:26:37 | [diff] [blame] | 229 | |
| 230 | // Remove the focus from any window. This will prevent overhead and side |
| 231 | // effects (e.g. crashes) from changing focus during shutdown. |
| 232 | // See bug crbug.com/134502. |
| 233 | if (active_root_window_) |
| 234 | active_root_window_->GetFocusManager()->SetFocusedWindow(NULL, NULL); |
| 235 | |
[email protected] | 9861f175 | 2012-06-01 07:16:14 | [diff] [blame] | 236 | // Please keep in same order as in Init() because it's easy to miss one. |
[email protected] | 304594c | 2012-11-13 16:35:27 | [diff] [blame] | 237 | RemovePreTargetHandler(user_activity_detector_.get()); |
| 238 | RemovePreTargetHandler(event_rewriter_filter_.get()); |
| 239 | RemovePreTargetHandler(overlay_filter_.get()); |
| 240 | RemovePreTargetHandler(input_method_filter_.get()); |
| 241 | RemovePreTargetHandler(window_modality_controller_.get()); |
[email protected] | 78d9630 | 2012-06-22 00:58:07 | [diff] [blame] | 242 | if (mouse_cursor_filter_.get()) |
[email protected] | 304594c | 2012-11-13 16:35:27 | [diff] [blame] | 243 | RemovePreTargetHandler(mouse_cursor_filter_.get()); |
[email protected] | f9f017c | 2012-11-12 19:05:17 | [diff] [blame] | 244 | RemovePreTargetHandler(system_gesture_filter_.get()); |
[email protected] | 6e9f6aa | 2012-02-09 04:16:20 | [diff] [blame] | 245 | #if !defined(OS_MACOSX) |
[email protected] | f9f017c | 2012-11-12 19:05:17 | [diff] [blame] | 246 | RemovePreTargetHandler(accelerator_filter_.get()); |
[email protected] | 6e9f6aa | 2012-02-09 04:16:20 | [diff] [blame] | 247 | #endif |
[email protected] | 7307474 | 2012-05-17 01:44:41 | [diff] [blame] | 248 | if (touch_observer_hud_.get()) |
[email protected] | f9f017c | 2012-11-12 19:05:17 | [diff] [blame] | 249 | RemovePreTargetHandler(touch_observer_hud_.get()); |
[email protected] | 745816be | 2011-11-22 05:08:30 | [diff] [blame] | 250 | |
[email protected] | 931f4f4 | 2012-02-10 23:49:42 | [diff] [blame] | 251 | // TooltipController is deleted with the Shell so removing its references. |
[email protected] | 304594c | 2012-11-13 16:35:27 | [diff] [blame] | 252 | RemovePreTargetHandler(tooltip_controller_.get()); |
[email protected] | ef589af | 2011-12-03 01:07:15 | [diff] [blame] | 253 | |
[email protected] | f5f3c75 | 2012-06-07 05:16:02 | [diff] [blame] | 254 | // AppList needs to be released before shelf layout manager, which is |
| 255 | // destroyed with launcher container in the loop below. However, app list |
| 256 | // container is now on top of launcher container and released after it. |
| 257 | // TODO(xiyuan): Move it back when app list container is no longer needed. |
| 258 | app_list_controller_.reset(); |
| 259 | |
[email protected] | 51ed599 | 2012-11-07 10:14:39 | [diff] [blame] | 260 | // Destroy SystemTrayDelegate before destroying the status area(s). |
| 261 | system_tray_delegate_.reset(); |
| 262 | |
[email protected] | 83b2b84c | 2012-11-14 01:11:00 | [diff] [blame] | 263 | // Destroy SystemTrayNotifier immediately after destroying SystemTrayDelegate |
| 264 | // so that it is still available when shutting down the UI, but not after |
| 265 | // the notifier observers have been destroyed. |
| 266 | system_tray_notifier_.reset(); |
| 267 | |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 268 | // Destroy all child windows including widgets. |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 269 | display_controller_->CloseChildWindows(); |
[email protected] | ef589af | 2011-12-03 01:07:15 | [diff] [blame] | 270 | |
[email protected] | 40c4cbb | 2012-01-10 23:26:07 | [diff] [blame] | 271 | // These need a valid Shell instance to clean up properly, so explicitly |
| 272 | // delete them before invalidating the instance. |
[email protected] | 58482fa | 2012-03-02 14:57:39 | [diff] [blame] | 273 | // Alphabetical. |
[email protected] | 084b6bb | 2011-11-17 05:18:16 | [diff] [blame] | 274 | drag_drop_controller_.reset(); |
[email protected] | c1c67017 | 2012-04-26 04:20:26 | [diff] [blame] | 275 | magnification_controller_.reset(); |
[email protected] | aa47650 | 2012-05-01 18:03:19 | [diff] [blame] | 276 | power_button_controller_.reset(); |
[email protected] | 222f40c | 2012-10-18 08:58:13 | [diff] [blame] | 277 | session_state_controller_.reset(); |
[email protected] | e4a181cc | 2012-03-17 02:20:57 | [diff] [blame] | 278 | resize_shadow_controller_.reset(); |
[email protected] | 58482fa | 2012-03-02 14:57:39 | [diff] [blame] | 279 | shadow_controller_.reset(); |
[email protected] | fd162f7 | 2012-04-14 03:24:53 | [diff] [blame] | 280 | tooltip_controller_.reset(); |
[email protected] | e67291f1 | 2012-10-10 05:52:38 | [diff] [blame] | 281 | event_client_.reset(); |
[email protected] | aa47650 | 2012-05-01 18:03:19 | [diff] [blame] | 282 | window_cycle_controller_.reset(); |
[email protected] | 60a978b7 | 2012-06-08 00:29:18 | [diff] [blame] | 283 | capture_controller_.reset(); |
[email protected] | 60a978b7 | 2012-06-08 00:29:18 | [diff] [blame] | 284 | nested_dispatcher_controller_.reset(); |
[email protected] | 60a978b7 | 2012-06-08 00:29:18 | [diff] [blame] | 285 | user_action_client_.reset(); |
[email protected] | 60a978b7 | 2012-06-08 00:29:18 | [diff] [blame] | 286 | visibility_controller_.reset(); |
[email protected] | 084b6bb | 2011-11-17 05:18:16 | [diff] [blame] | 287 | |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 288 | // This also deletes all RootWindows. |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 289 | display_controller_.reset(); |
[email protected] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 290 | screen_position_controller_.reset(); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 291 | |
[email protected] | 764864e | 2012-06-11 19:16:16 | [diff] [blame] | 292 | // Delete the activation controller after other controllers and launcher |
| 293 | // because they might have registered ActivationChangeObserver. |
[email protected] | 764864e | 2012-06-11 19:16:16 | [diff] [blame] | 294 | activation_controller_.reset(); |
| 295 | |
[email protected] | 488b4204 | 2011-11-15 00:20:18 | [diff] [blame] | 296 | DCHECK(instance_ == this); |
| 297 | instance_ = NULL; |
[email protected] | 70b3e7d5 | 2012-06-02 22:12:25 | [diff] [blame] | 298 | |
| 299 | #if defined(OS_CHROMEOS) |
[email protected] | 196e945 | 2012-08-01 06:42:51 | [diff] [blame] | 300 | output_configurator_->RemoveObserver(output_configurator_animation_.get()); |
[email protected] | 4168ad7 | 2012-08-30 16:57:21 | [diff] [blame] | 301 | base::MessagePumpAuraX11::Current()->RemoveDispatcherForRootWindow( |
| 302 | output_configurator()); |
[email protected] | 70b3e7d5 | 2012-06-02 22:12:25 | [diff] [blame] | 303 | #endif // defined(OS_CHROMEOS) |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 304 | } |
| 305 | |
[email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 306 | // static |
[email protected] | 3266c2b9 | 2011-11-14 00:06:08 | [diff] [blame] | 307 | Shell* Shell::CreateInstance(ShellDelegate* delegate) { |
| 308 | CHECK(!instance_); |
| 309 | instance_ = new Shell(delegate); |
| 310 | instance_->Init(); |
| 311 | return instance_; |
| 312 | } |
| 313 | |
| 314 | // static |
[email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 315 | Shell* Shell::GetInstance() { |
[email protected] | 3266c2b9 | 2011-11-14 00:06:08 | [diff] [blame] | 316 | DCHECK(instance_); |
[email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 317 | return instance_; |
| 318 | } |
| 319 | |
[email protected] | 6377a00 | 2011-11-10 20:26:47 | [diff] [blame] | 320 | // static |
[email protected] | b3b7bcd | 2012-03-06 19:35:45 | [diff] [blame] | 321 | bool Shell::HasInstance() { |
| 322 | return !!instance_; |
| 323 | } |
| 324 | |
| 325 | // static |
[email protected] | ef589af | 2011-12-03 01:07:15 | [diff] [blame] | 326 | void Shell::DeleteInstance() { |
[email protected] | 6377a00 | 2011-11-10 20:26:47 | [diff] [blame] | 327 | delete instance_; |
| 328 | instance_ = NULL; |
| 329 | } |
| 330 | |
[email protected] | e73bd780 | 2012-02-17 20:10:34 | [diff] [blame] | 331 | // static |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 332 | internal::RootWindowController* Shell::GetPrimaryRootWindowController() { |
[email protected] | 7ae52500 | 2012-07-26 23:55:10 | [diff] [blame] | 333 | return GetRootWindowController(GetPrimaryRootWindow()); |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 334 | } |
| 335 | |
| 336 | // static |
| 337 | Shell::RootWindowControllerList Shell::GetAllRootWindowControllers() { |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 338 | return Shell::GetInstance()->display_controller()-> |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 339 | GetAllRootWindowControllers(); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | // static |
[email protected] | 42713f7 | 2012-05-25 00:41:50 | [diff] [blame] | 343 | aura::RootWindow* Shell::GetPrimaryRootWindow() { |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 344 | return GetInstance()->display_controller()->GetPrimaryRootWindow(); |
[email protected] | e73bd780 | 2012-02-17 20:10:34 | [diff] [blame] | 345 | } |
| 346 | |
[email protected] | 7b0f750 | 2012-06-11 00:12:39 | [diff] [blame] | 347 | // static |
[email protected] | a857dbe | 2012-05-30 22:10:14 | [diff] [blame] | 348 | aura::RootWindow* Shell::GetActiveRootWindow() { |
| 349 | return GetInstance()->active_root_window_; |
| 350 | } |
| 351 | |
[email protected] | 7b0f750 | 2012-06-11 00:12:39 | [diff] [blame] | 352 | // static |
[email protected] | ffabb1e | 2012-10-12 19:51:17 | [diff] [blame] | 353 | gfx::Screen* Shell::GetScreen() { |
[email protected] | 5fdb45b | 2012-10-23 20:26:28 | [diff] [blame] | 354 | return gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE); |
[email protected] | ffabb1e | 2012-10-12 19:51:17 | [diff] [blame] | 355 | } |
| 356 | |
| 357 | // static |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 358 | Shell::RootWindowList Shell::GetAllRootWindows() { |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 359 | return Shell::GetInstance()->display_controller()-> |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 360 | GetAllRootWindows(); |
| 361 | } |
| 362 | |
| 363 | // static |
[email protected] | 7b0f750 | 2012-06-11 00:12:39 | [diff] [blame] | 364 | aura::Window* Shell::GetContainer(aura::RootWindow* root_window, |
| 365 | int container_id) { |
| 366 | return root_window->GetChildById(container_id); |
| 367 | } |
| 368 | |
| 369 | // static |
[email protected] | e67291f1 | 2012-10-10 05:52:38 | [diff] [blame] | 370 | const aura::Window* Shell::GetContainer(const aura::RootWindow* root_window, |
| 371 | int container_id) { |
| 372 | return root_window->GetChildById(container_id); |
| 373 | } |
| 374 | |
| 375 | // static |
[email protected] | 7b0f750 | 2012-06-11 00:12:39 | [diff] [blame] | 376 | std::vector<aura::Window*> Shell::GetAllContainers(int container_id) { |
[email protected] | 7b0f750 | 2012-06-11 00:12:39 | [diff] [blame] | 377 | std::vector<aura::Window*> containers; |
[email protected] | 001272f | 2012-11-02 20:05:23 | [diff] [blame] | 378 | RootWindowList root_windows = GetAllRootWindows(); |
| 379 | for (RootWindowList::const_iterator it = root_windows.begin(); |
| 380 | it != root_windows.end(); ++it) { |
| 381 | aura::Window* container = (*it)->GetChildById(container_id); |
| 382 | if (container) |
| 383 | containers.push_back(container); |
| 384 | } |
[email protected] | 7b0f750 | 2012-06-11 00:12:39 | [diff] [blame] | 385 | return containers; |
| 386 | } |
| 387 | |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 388 | // static |
| 389 | bool Shell::IsLauncherPerDisplayEnabled() { |
| 390 | CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 391 | return command_line->HasSwitch(switches::kAshLauncherPerDisplay); |
| 392 | } |
| 393 | |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 394 | void Shell::Init() { |
[email protected] | 6bdf795 | 2012-11-14 10:10:58 | [diff] [blame] | 395 | #if defined(OS_CHROMEOS) |
| 396 | if (base::chromeos::IsRunningOnChromeOS()) { |
| 397 | display_change_observer_.reset(new internal::DisplayChangeObserverX11); |
| 398 | display_change_observer_->NotifyDisplayChange(); |
| 399 | } |
| 400 | #endif |
| 401 | |
[email protected] | c9301e3 | 2012-05-23 08:34:58 | [diff] [blame] | 402 | // Install the custom factory first so that views::FocusManagers for Tray, |
| 403 | // Launcher, and WallPaper could be created by the factory. |
| 404 | views::FocusManagerFactory::Install(new AshFocusManagerFactory); |
| 405 | |
[email protected] | 4a59e4e | 2012-11-12 21:15:40 | [diff] [blame] | 406 | env_filter_.reset(new views::corewm::CompoundEventFilter); |
[email protected] | 304594c | 2012-11-13 16:35:27 | [diff] [blame] | 407 | AddPreTargetHandler(env_filter_.get()); |
[email protected] | 1aad332 | 2012-06-06 06:37:09 | [diff] [blame] | 408 | |
[email protected] | a857dbe | 2012-05-30 22:10:14 | [diff] [blame] | 409 | focus_manager_.reset(new aura::FocusManager); |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 410 | activation_controller_.reset( |
| 411 | new internal::ActivationController(focus_manager_.get())); |
| 412 | |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 413 | focus_cycler_.reset(new internal::FocusCycler()); |
| 414 | |
[email protected] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 415 | screen_position_controller_.reset(new internal::ScreenPositionController); |
[email protected] | edbfb8d | 2012-09-03 08:33:43 | [diff] [blame] | 416 | display_controller_.reset(new DisplayController); |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 417 | display_controller_->InitPrimaryDisplay(); |
| 418 | aura::RootWindow* root_window = display_controller_->GetPrimaryRootWindow(); |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 419 | active_root_window_ = root_window; |
[email protected] | a857dbe | 2012-05-30 22:10:14 | [diff] [blame] | 420 | |
[email protected] | 151ffdff | 2012-09-11 20:18:35 | [diff] [blame] | 421 | cursor_manager_.SetDeviceScaleFactor( |
| 422 | root_window->AsRootWindowHostDelegate()->GetDeviceScaleFactor()); |
| 423 | |
[email protected] | 58482fa | 2012-03-02 14:57:39 | [diff] [blame] | 424 | #if !defined(OS_MACOSX) |
| 425 | nested_dispatcher_controller_.reset(new NestedDispatcherController); |
| 426 | accelerator_controller_.reset(new AcceleratorController); |
| 427 | #endif |
[email protected] | 58482fa | 2012-03-02 14:57:39 | [diff] [blame] | 428 | |
[email protected] | c16b942 | 2012-06-06 21:51:11 | [diff] [blame] | 429 | // The order in which event filters are added is significant. |
[email protected] | c16b942 | 2012-06-06 21:51:11 | [diff] [blame] | 430 | user_activity_detector_.reset(new UserActivityDetector); |
[email protected] | 304594c | 2012-11-13 16:35:27 | [diff] [blame] | 431 | AddPreTargetHandler(user_activity_detector_.get()); |
[email protected] | c16b942 | 2012-06-06 21:51:11 | [diff] [blame] | 432 | |
[email protected] | b9d224c | 2012-07-13 01:09:03 | [diff] [blame] | 433 | event_rewriter_filter_.reset(new internal::EventRewriterEventFilter); |
[email protected] | 304594c | 2012-11-13 16:35:27 | [diff] [blame] | 434 | AddPreTargetHandler(event_rewriter_filter_.get()); |
[email protected] | 0b0b074 | 2012-02-16 13:23:45 | [diff] [blame] | 435 | |
[email protected] | 9ae32df | 2012-07-26 03:25:18 | [diff] [blame] | 436 | overlay_filter_.reset(new internal::OverlayEventFilter); |
[email protected] | 304594c | 2012-11-13 16:35:27 | [diff] [blame] | 437 | AddPreTargetHandler(overlay_filter_.get()); |
[email protected] | 9ae32df | 2012-07-26 03:25:18 | [diff] [blame] | 438 | AddShellObserver(overlay_filter_.get()); |
[email protected] | 0b0b074 | 2012-02-16 13:23:45 | [diff] [blame] | 439 | |
[email protected] | 4a59e4e | 2012-11-12 21:15:40 | [diff] [blame] | 440 | input_method_filter_.reset(new views::corewm::InputMethodEventFilter); |
[email protected] | 304594c | 2012-11-13 16:35:27 | [diff] [blame] | 441 | AddPreTargetHandler(input_method_filter_.get()); |
[email protected] | c16b942 | 2012-06-06 21:51:11 | [diff] [blame] | 442 | |
[email protected] | 21472b1 | 2012-02-17 00:30:05 | [diff] [blame] | 443 | #if !defined(OS_MACOSX) |
| 444 | accelerator_filter_.reset(new internal::AcceleratorFilter); |
[email protected] | f9f017c | 2012-11-12 19:05:17 | [diff] [blame] | 445 | AddPreTargetHandler(accelerator_filter_.get()); |
[email protected] | 21472b1 | 2012-02-17 00:30:05 | [diff] [blame] | 446 | #endif |
[email protected] | fcbbf08 | 2012-01-20 06:07:15 | [diff] [blame] | 447 | |
[email protected] | 435b212e | 2012-04-05 19:43:37 | [diff] [blame] | 448 | system_gesture_filter_.reset(new internal::SystemGestureEventFilter); |
[email protected] | f9f017c | 2012-11-12 19:05:17 | [diff] [blame] | 449 | AddPreTargetHandler(system_gesture_filter_.get()); |
[email protected] | 435b212e | 2012-04-05 19:43:37 | [diff] [blame] | 450 | |
[email protected] | 60a978b7 | 2012-06-08 00:29:18 | [diff] [blame] | 451 | capture_controller_.reset(new internal::CaptureController); |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 452 | |
[email protected] | 871e9cc | 2012-06-17 22:41:55 | [diff] [blame] | 453 | internal::RootWindowController* root_window_controller = |
| 454 | new internal::RootWindowController(root_window); |
| 455 | root_window_controller->CreateContainers(); |
[email protected] | 697f04c | 2012-10-03 01:15:10 | [diff] [blame] | 456 | root_window_controller->CreateSystemBackground( |
[email protected] | 02dbd1a | 2012-11-08 22:50:13 | [diff] [blame] | 457 | delegate_->IsFirstRunAfterBoot()); |
[email protected] | 871e9cc | 2012-06-17 22:41:55 | [diff] [blame] | 458 | |
[email protected] | 7307474 | 2012-05-17 01:44:41 | [diff] [blame] | 459 | CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 460 | |
| 461 | if (command_line->HasSwitch(switches::kAshTouchHud)) { |
| 462 | touch_observer_hud_.reset(new internal::TouchObserverHUD); |
[email protected] | f9f017c | 2012-11-12 19:05:17 | [diff] [blame] | 463 | AddPreTargetHandler(touch_observer_hud_.get()); |
[email protected] | 7307474 | 2012-05-17 01:44:41 | [diff] [blame] | 464 | } |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 465 | |
[email protected] | 8b7ba87b | 2012-09-01 00:40:40 | [diff] [blame] | 466 | mouse_cursor_filter_.reset(new internal::MouseCursorEventFilter()); |
[email protected] | 304594c | 2012-11-13 16:35:27 | [diff] [blame] | 467 | AddPreTargetHandler(mouse_cursor_filter_.get()); |
[email protected] | 0518d0d | 2012-08-26 11:59:04 | [diff] [blame] | 468 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 469 | // Create Controllers that may need root window. |
| 470 | // TODO(oshima): Move as many controllers before creating |
| 471 | // RootWindowController as possible. |
[email protected] | d8f1004 | 2012-11-14 01:10:46 | [diff] [blame] | 472 | stacking_client_.reset(delegate_->CreateStackingClient()); |
| 473 | if (stacking_client_.get()) |
| 474 | aura::client::SetStackingClient(stacking_client_.get()); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 475 | visibility_controller_.reset(new internal::VisibilityController); |
| 476 | drag_drop_controller_.reset(new internal::DragDropController); |
[email protected] | 02dbd1a | 2012-11-08 22:50:13 | [diff] [blame] | 477 | user_action_client_.reset(delegate_->CreateUserActionClient()); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 478 | window_modality_controller_.reset(new internal::WindowModalityController); |
[email protected] | 304594c | 2012-11-13 16:35:27 | [diff] [blame] | 479 | AddPreTargetHandler(window_modality_controller_.get()); |
[email protected] | 488b4204 | 2011-11-15 00:20:18 | [diff] [blame] | 480 | |
[email protected] | 9613eacf | 2012-06-22 02:18:05 | [diff] [blame] | 481 | magnification_controller_.reset( |
| 482 | internal::MagnificationController::CreateInstance()); |
| 483 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 484 | high_contrast_controller_.reset(new HighContrastController); |
| 485 | video_detector_.reset(new VideoDetector); |
[email protected] | 8fef743 | 2012-08-06 15:34:25 | [diff] [blame] | 486 | window_cycle_controller_.reset( |
| 487 | new WindowCycleController(activation_controller_.get())); |
[email protected] | b0079a9 | 2012-01-25 20:13:38 | [diff] [blame] | 488 | |
[email protected] | 54a37cdc | 2012-07-25 19:16:01 | [diff] [blame] | 489 | tooltip_controller_.reset(new internal::TooltipController( |
| 490 | drag_drop_controller_.get())); |
[email protected] | 304594c | 2012-11-13 16:35:27 | [diff] [blame] | 491 | AddPreTargetHandler(tooltip_controller_.get()); |
[email protected] | 54a37cdc | 2012-07-25 19:16:01 | [diff] [blame] | 492 | |
[email protected] | e67291f1 | 2012-10-10 05:52:38 | [diff] [blame] | 493 | event_client_.reset(new internal::EventClientImpl); |
| 494 | |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 495 | InitRootWindowController(root_window_controller); |
[email protected] | 262f8bd | 2012-03-23 19:30:27 | [diff] [blame] | 496 | |
[email protected] | 36f56653 | 2012-09-19 04:07:24 | [diff] [blame] | 497 | // This controller needs to be set before SetupManagedWindowMode. |
| 498 | desktop_background_controller_.reset(new DesktopBackgroundController()); |
[email protected] | 02dbd1a | 2012-11-08 22:50:13 | [diff] [blame] | 499 | user_wallpaper_delegate_.reset(delegate_->CreateUserWallpaperDelegate()); |
[email protected] | 36f56653 | 2012-09-19 04:07:24 | [diff] [blame] | 500 | if (!user_wallpaper_delegate_.get()) |
| 501 | user_wallpaper_delegate_.reset(new DummyUserWallpaperDelegate()); |
| 502 | |
[email protected] | f4c92b38 | 2012-08-28 00:59:59 | [diff] [blame] | 503 | // StatusAreaWidget uses Shell's CapsLockDelegate. |
[email protected] | 02dbd1a | 2012-11-08 22:50:13 | [diff] [blame] | 504 | caps_lock_delegate_.reset(delegate_->CreateCapsLockDelegate()); |
[email protected] | f4c92b38 | 2012-08-28 00:59:59 | [diff] [blame] | 505 | |
[email protected] | e4a181cc | 2012-03-17 02:20:57 | [diff] [blame] | 506 | if (!command_line->HasSwitch(switches::kAuraNoShadows)) { |
| 507 | resize_shadow_controller_.reset(new internal::ResizeShadowController()); |
[email protected] | 86f2b5e | 2012-11-14 20:37:00 | [diff] [blame^] | 508 | shadow_controller_.reset( |
| 509 | new views::corewm::ShadowController(GetPrimaryRootWindow())); |
[email protected] | e4a181cc | 2012-03-17 02:20:57 | [diff] [blame] | 510 | } |
[email protected] | a54e65b | 2011-11-21 22:03:34 | [diff] [blame] | 511 | |
[email protected] | 83b2b84c | 2012-11-14 01:11:00 | [diff] [blame] | 512 | // Create system_tray_notifier_ before the delegate. |
| 513 | system_tray_notifier_.reset(new ash::SystemTrayNotifier()); |
| 514 | |
[email protected] | 51ed599 | 2012-11-07 10:14:39 | [diff] [blame] | 515 | // Initialize system_tray_delegate_ before initializing StatusAreaWidget. |
[email protected] | 02dbd1a | 2012-11-08 22:50:13 | [diff] [blame] | 516 | system_tray_delegate_.reset(delegate()->CreateSystemTrayDelegate()); |
[email protected] | 51ed599 | 2012-11-07 10:14:39 | [diff] [blame] | 517 | if (!system_tray_delegate_.get()) |
| 518 | system_tray_delegate_.reset(SystemTrayDelegate::CreateDummyDelegate()); |
| 519 | |
| 520 | // Creates StatusAreaWidget. |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 521 | root_window_controller->InitForPrimaryDisplay(); |
[email protected] | 3d29912a | 2012-02-07 07:41:51 | [diff] [blame] | 522 | |
[email protected] | 51ed599 | 2012-11-07 10:14:39 | [diff] [blame] | 523 | // Initialize system_tray_delegate_ after StatusAreaWidget is created. |
| 524 | system_tray_delegate_->Initialize(); |
| 525 | |
[email protected] | 16059276d | 2012-10-22 18:59:50 | [diff] [blame] | 526 | display_controller_->InitSecondaryDisplays(); |
| 527 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 528 | // Force Layout |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 529 | root_window_controller->root_window_layout()->OnWindowResized(); |
[email protected] | 084b6bb | 2011-11-17 05:18:16 | [diff] [blame] | 530 | |
[email protected] | 60b5b86 | 2012-04-27 18:56:34 | [diff] [blame] | 531 | // It needs to be created after OnWindowResized has been called, otherwise the |
[email protected] | 5f2391ea | 2012-09-12 23:46:49 | [diff] [blame] | 532 | // widget will not paint when restoring after a browser crash. Also it needs |
| 533 | // to be created after InitSecondaryDisplays() to initialize the wallpapers in |
| 534 | // the correct size. |
[email protected] | 0c4f87d | 2012-06-12 02:00:35 | [diff] [blame] | 535 | user_wallpaper_delegate_->InitializeWallpaper(); |
[email protected] | 60b5b86 | 2012-04-27 18:56:34 | [diff] [blame] | 536 | |
[email protected] | 839667d6 | 2012-10-23 19:38:57 | [diff] [blame] | 537 | if (command_line->HasSwitch(ash::switches::kAshNewLockAnimationsEnabled)) |
| 538 | session_state_controller_.reset(new SessionStateControllerImpl2); |
| 539 | else |
| 540 | session_state_controller_.reset(new SessionStateControllerImpl); |
[email protected] | 222f40c | 2012-10-18 08:58:13 | [diff] [blame] | 541 | power_button_controller_.reset(new PowerButtonController( |
| 542 | session_state_controller_.get())); |
| 543 | AddShellObserver(session_state_controller_.get()); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 544 | |
| 545 | if (initially_hide_cursor_) |
[email protected] | 4b8003c | 2012-07-26 00:54:19 | [diff] [blame] | 546 | cursor_manager_.ShowCursor(false); |
[email protected] | 0ad9b76 | 2012-09-28 04:22:09 | [diff] [blame] | 547 | |
| 548 | // Cursor might have been hidden by somethign other than chrome. |
| 549 | // Let the first mouse event show the cursor. |
| 550 | env_filter_->set_cursor_hidden_by_filter(true); |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 551 | } |
| 552 | |
[email protected] | 431552c | 2012-10-23 00:38:33 | [diff] [blame] | 553 | void Shell::ShowContextMenu(const gfx::Point& location_in_screen) { |
[email protected] | f60c623 | 2012-08-24 18:55:03 | [diff] [blame] | 554 | // No context menus if user have not logged in. |
[email protected] | 02dbd1a | 2012-11-08 22:50:13 | [diff] [blame] | 555 | if (!delegate_->IsUserLoggedIn()) |
[email protected] | f60c623 | 2012-08-24 18:55:03 | [diff] [blame] | 556 | return; |
| 557 | // No context menus when screen is locked. |
| 558 | if (IsScreenLocked()) |
| 559 | return; |
[email protected] | 431552c | 2012-10-23 00:38:33 | [diff] [blame] | 560 | |
[email protected] | 88d7112 | 2012-10-18 07:11:01 | [diff] [blame] | 561 | aura::RootWindow* root = |
[email protected] | 431552c | 2012-10-23 00:38:33 | [diff] [blame] | 562 | wm::GetRootWindowMatching(gfx::Rect(location_in_screen, gfx::Size())); |
| 563 | GetRootWindowController(root)->ShowContextMenu(location_in_screen); |
[email protected] | 46ca363 | 2011-11-03 03:33:42 | [diff] [blame] | 564 | } |
| 565 | |
[email protected] | ae4987d | 2011-11-21 22:52:44 | [diff] [blame] | 566 | void Shell::ToggleAppList() { |
[email protected] | 0039db9 | 2012-05-09 04:11:45 | [diff] [blame] | 567 | if (!app_list_controller_.get()) |
| 568 | app_list_controller_.reset(new internal::AppListController); |
| 569 | app_list_controller_->SetVisible(!app_list_controller_->IsVisible()); |
[email protected] | ae4987d | 2011-11-21 22:52:44 | [diff] [blame] | 570 | } |
| 571 | |
[email protected] | 7510d108 | 2012-03-30 21:58:34 | [diff] [blame] | 572 | bool Shell::GetAppListTargetVisibility() const { |
[email protected] | 0039db9 | 2012-05-09 04:11:45 | [diff] [blame] | 573 | return app_list_controller_.get() && |
| 574 | app_list_controller_->GetTargetVisibility(); |
[email protected] | 7510d108 | 2012-03-30 21:58:34 | [diff] [blame] | 575 | } |
| 576 | |
[email protected] | 1e51a9d | 2012-04-09 23:31:11 | [diff] [blame] | 577 | aura::Window* Shell::GetAppListWindow() { |
[email protected] | 0039db9 | 2012-05-09 04:11:45 | [diff] [blame] | 578 | return app_list_controller_.get() ? app_list_controller_->GetWindow() : NULL; |
[email protected] | 1e51a9d | 2012-04-09 23:31:11 | [diff] [blame] | 579 | } |
| 580 | |
[email protected] | f7eb89c | 2011-12-13 09:48:54 | [diff] [blame] | 581 | bool Shell::IsScreenLocked() const { |
[email protected] | 02dbd1a | 2012-11-08 22:50:13 | [diff] [blame] | 582 | return delegate_->IsScreenLocked(); |
[email protected] | f7eb89c | 2011-12-13 09:48:54 | [diff] [blame] | 583 | } |
| 584 | |
[email protected] | 40c4cbb | 2012-01-10 23:26:07 | [diff] [blame] | 585 | bool Shell::IsModalWindowOpen() const { |
[email protected] | 852a55d | 2012-10-17 13:30:30 | [diff] [blame] | 586 | if (simulate_modal_window_open_for_testing_) |
| 587 | return true; |
[email protected] | 001272f | 2012-11-02 20:05:23 | [diff] [blame] | 588 | const std::vector<aura::Window*> containers = GetAllContainers( |
[email protected] | e73bd780 | 2012-02-17 20:10:34 | [diff] [blame] | 589 | internal::kShellWindowId_SystemModalContainer); |
[email protected] | 001272f | 2012-11-02 20:05:23 | [diff] [blame] | 590 | for (std::vector<aura::Window*>::const_iterator cit = containers.begin(); |
| 591 | cit != containers.end(); ++cit) { |
| 592 | for (aura::Window::Windows::const_iterator wit = (*cit)->children().begin(); |
| 593 | wit != (*cit)->children().end(); ++wit) { |
| 594 | if ((*wit)->GetProperty(aura::client::kModalKey) == |
| 595 | ui::MODAL_TYPE_SYSTEM && (*wit)->TargetVisibility()) { |
| 596 | return true; |
| 597 | } |
| 598 | } |
| 599 | } |
| 600 | return false; |
[email protected] | 40c4cbb | 2012-01-10 23:26:07 | [diff] [blame] | 601 | } |
| 602 | |
[email protected] | 57b8bb35 | 2012-01-11 05:11:46 | [diff] [blame] | 603 | views::NonClientFrameView* Shell::CreateDefaultNonClientFrameView( |
| 604 | views::Widget* widget) { |
| 605 | if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 606 | switches::kAuraGoogleDialogFrames)) { |
| 607 | return new internal::DialogFrameView; |
| 608 | } |
[email protected] | c73d133 | 2012-03-08 17:11:04 | [diff] [blame] | 609 | // Use translucent-style window frames for dialogs. |
[email protected] | 95c6cc4 | 2012-03-08 20:53:15 | [diff] [blame] | 610 | CustomFrameViewAsh* frame_view = new CustomFrameViewAsh; |
[email protected] | c73d133 | 2012-03-08 17:11:04 | [diff] [blame] | 611 | frame_view->Init(widget); |
| 612 | return frame_view; |
[email protected] | 57b8bb35 | 2012-01-11 05:11:46 | [diff] [blame] | 613 | } |
| 614 | |
[email protected] | 3d29912a | 2012-02-07 07:41:51 | [diff] [blame] | 615 | void Shell::RotateFocus(Direction direction) { |
| 616 | focus_cycler_->RotateFocus( |
| 617 | direction == FORWARD ? internal::FocusCycler::FORWARD : |
| 618 | internal::FocusCycler::BACKWARD); |
| 619 | } |
| 620 | |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 621 | void Shell::SetDisplayWorkAreaInsets(Window* contains, |
[email protected] | 8a45c97 | 2012-03-14 18:22:44 | [diff] [blame] | 622 | const gfx::Insets& insets) { |
[email protected] | 6bdf795 | 2012-11-14 10:10:58 | [diff] [blame] | 623 | if (!display_manager_->UpdateWorkAreaOfDisplayNearestWindow(contains, insets)) |
[email protected] | 1a2145b | 2012-03-13 21:09:17 | [diff] [blame] | 624 | return; |
[email protected] | 1a2145b | 2012-03-13 21:09:17 | [diff] [blame] | 625 | FOR_EACH_OBSERVER(ShellObserver, observers_, |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 626 | OnDisplayWorkAreaInsetsChanged()); |
[email protected] | 1a2145b | 2012-03-13 21:09:17 | [diff] [blame] | 627 | } |
| 628 | |
[email protected] | 82d3954ae | 2012-04-20 09:02:22 | [diff] [blame] | 629 | void Shell::OnLoginStateChanged(user::LoginStatus status) { |
| 630 | FOR_EACH_OBSERVER(ShellObserver, observers_, OnLoginStateChanged(status)); |
[email protected] | 16059276d | 2012-10-22 18:59:50 | [diff] [blame] | 631 | RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 632 | for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 633 | iter != controllers.end(); ++iter) |
| 634 | (*iter)->OnLoginStateChanged(status); |
[email protected] | 82d3954ae | 2012-04-20 09:02:22 | [diff] [blame] | 635 | } |
| 636 | |
[email protected] | 88d7112 | 2012-10-18 07:11:01 | [diff] [blame] | 637 | void Shell::UpdateAfterLoginStatusChange(user::LoginStatus status) { |
[email protected] | 16059276d | 2012-10-22 18:59:50 | [diff] [blame] | 638 | RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 639 | for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 640 | iter != controllers.end(); ++iter) |
| 641 | (*iter)->UpdateAfterLoginStatusChange(status); |
[email protected] | 88d7112 | 2012-10-18 07:11:01 | [diff] [blame] | 642 | } |
| 643 | |
[email protected] | 82d3954ae | 2012-04-20 09:02:22 | [diff] [blame] | 644 | void Shell::OnAppTerminating() { |
| 645 | FOR_EACH_OBSERVER(ShellObserver, observers_, OnAppTerminating()); |
| 646 | } |
| 647 | |
| 648 | void Shell::OnLockStateChanged(bool locked) { |
| 649 | FOR_EACH_OBSERVER(ShellObserver, observers_, OnLockStateChanged(locked)); |
| 650 | } |
| 651 | |
[email protected] | d9456cb | 2012-03-21 16:41:04 | [diff] [blame] | 652 | void Shell::CreateLauncher() { |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 653 | GetPrimaryRootWindowController()->CreateLauncher(); |
[email protected] | d9456cb | 2012-03-21 16:41:04 | [diff] [blame] | 654 | } |
| 655 | |
[email protected] | 7e1df2f6 | 2012-07-19 19:17:18 | [diff] [blame] | 656 | void Shell::ShowLauncher() { |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 657 | GetPrimaryRootWindowController()->ShowLauncher(); |
[email protected] | 7e1df2f6 | 2012-07-19 19:17:18 | [diff] [blame] | 658 | } |
| 659 | |
[email protected] | 1a2145b | 2012-03-13 21:09:17 | [diff] [blame] | 660 | void Shell::AddShellObserver(ShellObserver* observer) { |
| 661 | observers_.AddObserver(observer); |
| 662 | } |
| 663 | |
| 664 | void Shell::RemoveShellObserver(ShellObserver* observer) { |
| 665 | observers_.RemoveObserver(observer); |
| 666 | } |
| 667 | |
[email protected] | c758fbf | 2012-03-25 22:53:59 | [diff] [blame] | 668 | void Shell::UpdateShelfVisibility() { |
[email protected] | 431552c | 2012-10-23 00:38:33 | [diff] [blame] | 669 | RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 670 | for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 671 | iter != controllers.end(); ++iter) |
| 672 | if ((*iter)->shelf()) |
| 673 | (*iter)->UpdateShelfVisibility(); |
[email protected] | c758fbf | 2012-03-25 22:53:59 | [diff] [blame] | 674 | } |
| 675 | |
[email protected] | 431552c | 2012-10-23 00:38:33 | [diff] [blame] | 676 | void Shell::SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior, |
| 677 | aura::RootWindow* root_window) { |
| 678 | GetRootWindowController(root_window)->SetShelfAutoHideBehavior(behavior); |
[email protected] | c758fbf | 2012-03-25 22:53:59 | [diff] [blame] | 679 | } |
| 680 | |
[email protected] | 431552c | 2012-10-23 00:38:33 | [diff] [blame] | 681 | ShelfAutoHideBehavior Shell::GetShelfAutoHideBehavior( |
| 682 | aura::RootWindow* root_window) const { |
| 683 | return GetRootWindowController(root_window)->GetShelfAutoHideBehavior(); |
[email protected] | c758fbf | 2012-03-25 22:53:59 | [diff] [blame] | 684 | } |
| 685 | |
[email protected] | 431552c | 2012-10-23 00:38:33 | [diff] [blame] | 686 | bool Shell::IsShelfAutoHideMenuHideChecked(aura::RootWindow* root_window) { |
| 687 | return GetRootWindowController(root_window)->GetShelfAutoHideBehavior() == |
| 688 | ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS; |
| 689 | } |
| 690 | |
| 691 | ShelfAutoHideBehavior Shell::GetToggledShelfAutoHideBehavior( |
| 692 | aura::RootWindow* root_window) { |
| 693 | return GetRootWindowController(root_window)-> |
| 694 | GetToggledShelfAutoHideBehavior(); |
| 695 | } |
| 696 | |
| 697 | void Shell::SetShelfAlignment(ShelfAlignment alignment, |
| 698 | aura::RootWindow* root_window) { |
| 699 | if (GetRootWindowController(root_window)->SetShelfAlignment(alignment)) |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 700 | FOR_EACH_OBSERVER(ShellObserver, observers_, OnShelfAlignmentChanged()); |
[email protected] | 5544450 | 2012-05-10 15:43:53 | [diff] [blame] | 701 | } |
| 702 | |
[email protected] | 431552c | 2012-10-23 00:38:33 | [diff] [blame] | 703 | ShelfAlignment Shell::GetShelfAlignment(aura::RootWindow* root_window) { |
| 704 | return GetRootWindowController(root_window)->GetShelfAlignment(); |
[email protected] | 5544450 | 2012-05-10 15:43:53 | [diff] [blame] | 705 | } |
| 706 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 707 | void Shell::SetDimming(bool should_dim) { |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 708 | RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 709 | for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 710 | iter != controllers.end(); ++iter) |
| 711 | (*iter)->screen_dimmer()->SetDimming(should_dim); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 712 | } |
| 713 | |
[email protected] | 090c4f1 | 2012-10-29 18:56:42 | [diff] [blame] | 714 | void Shell::CreateModalBackground(aura::Window* window) { |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 715 | if (!modality_filter_.get()) { |
| 716 | modality_filter_.reset(new internal::SystemModalContainerEventFilter(this)); |
[email protected] | 304594c | 2012-11-13 16:35:27 | [diff] [blame] | 717 | AddPreTargetHandler(modality_filter_.get()); |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 718 | } |
| 719 | RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 720 | for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 721 | iter != controllers.end(); ++iter) |
[email protected] | 090c4f1 | 2012-10-29 18:56:42 | [diff] [blame] | 722 | (*iter)->GetSystemModalLayoutManager(window)->CreateModalBackground(); |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 723 | } |
| 724 | |
| 725 | void Shell::OnModalWindowRemoved(aura::Window* removed) { |
| 726 | RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 727 | bool activated = false; |
| 728 | for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 729 | iter != controllers.end() && !activated; ++iter) { |
[email protected] | 8674b31 | 2012-10-12 19:02:44 | [diff] [blame] | 730 | activated = (*iter)->GetSystemModalLayoutManager(removed)-> |
| 731 | ActivateNextModalWindow(); |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 732 | } |
| 733 | if (!activated) { |
[email protected] | 304594c | 2012-11-13 16:35:27 | [diff] [blame] | 734 | RemovePreTargetHandler(modality_filter_.get()); |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 735 | modality_filter_.reset(); |
| 736 | for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 737 | iter != controllers.end(); ++iter) |
[email protected] | 8674b31 | 2012-10-12 19:02:44 | [diff] [blame] | 738 | (*iter)->GetSystemModalLayoutManager(removed)->DestroyModalBackground(); |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 739 | } |
| 740 | } |
| 741 | |
[email protected] | 88d7112 | 2012-10-18 07:11:01 | [diff] [blame] | 742 | WebNotificationTray* Shell::GetWebNotificationTray() { |
| 743 | return GetPrimaryRootWindowController()->status_area_widget()-> |
| 744 | web_notification_tray(); |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 745 | } |
| 746 | |
[email protected] | 31f19e3 | 2012-10-30 22:31:23 | [diff] [blame] | 747 | internal::StatusAreaWidget* Shell::status_area_widget() { |
| 748 | return GetPrimaryRootWindowController()->status_area_widget(); |
| 749 | } |
| 750 | |
[email protected] | aa54218b | 2012-06-12 16:51:42 | [diff] [blame] | 751 | SystemTray* Shell::system_tray() { |
[email protected] | 31f19e3 | 2012-10-30 22:31:23 | [diff] [blame] | 752 | // We assume in throughout the code that this will not return NULL. If code |
| 753 | // triggers this for valid reasons, it should test status_area_widget first. |
| 754 | internal::StatusAreaWidget* status_area = status_area_widget(); |
| 755 | CHECK(status_area); |
| 756 | return status_area->system_tray(); |
[email protected] | aa54218b | 2012-06-12 16:51:42 | [diff] [blame] | 757 | } |
| 758 | |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 759 | void Shell::InitRootWindowForSecondaryDisplay(aura::RootWindow* root) { |
[email protected] | a857dbe | 2012-05-30 22:10:14 | [diff] [blame] | 760 | root->set_focus_manager(focus_manager_.get()); |
[email protected] | cf1c70e | 2012-08-30 01:13:02 | [diff] [blame] | 761 | internal::RootWindowController* controller = |
| 762 | new internal::RootWindowController(root); |
| 763 | controller->CreateContainers(); |
[email protected] | bca9a7e | 2012-11-10 06:25:49 | [diff] [blame] | 764 | // Pass false for the |is_first_run_after_boot| parameter so we'll show a |
| 765 | // black background on this display instead of trying to mimic the boot splash |
| 766 | // screen. |
| 767 | controller->CreateSystemBackground(false); |
[email protected] | cf1c70e | 2012-08-30 01:13:02 | [diff] [blame] | 768 | InitRootWindowController(controller); |
[email protected] | 16059276d | 2012-10-22 18:59:50 | [diff] [blame] | 769 | if (IsLauncherPerDisplayEnabled()) |
| 770 | controller->InitForPrimaryDisplay(); |
[email protected] | cf1c70e | 2012-08-30 01:13:02 | [diff] [blame] | 771 | controller->root_window_layout()->OnWindowResized(); |
| 772 | desktop_background_controller_->OnRootWindowAdded(root); |
[email protected] | 6b37addd | 2012-09-28 03:08:09 | [diff] [blame] | 773 | high_contrast_controller_->OnRootWindowAdded(root); |
[email protected] | cf1c70e | 2012-08-30 01:13:02 | [diff] [blame] | 774 | root->ShowRootWindow(); |
| 775 | // Activate new root for testing. |
| 776 | active_root_window_ = root; |
[email protected] | a857dbe | 2012-05-30 22:10:14 | [diff] [blame] | 777 | } |
| 778 | |
[email protected] | f946670 | 2012-09-17 16:35:27 | [diff] [blame] | 779 | void Shell::DoInitialWorkspaceAnimation() { |
| 780 | return GetPrimaryRootWindowController()->workspace_controller()-> |
| 781 | DoInitialAnimation(); |
| 782 | } |
| 783 | |
[email protected] | d8f1004 | 2012-11-14 01:10:46 | [diff] [blame] | 784 | aura::client::StackingClient* Shell::stacking_client() { |
| 785 | return stacking_client_.get(); |
| 786 | } |
| 787 | |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 788 | void Shell::InitRootWindowController( |
| 789 | internal::RootWindowController* controller) { |
| 790 | aura::RootWindow* root_window = controller->root_window(); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 791 | DCHECK(activation_controller_.get()); |
| 792 | DCHECK(visibility_controller_.get()); |
| 793 | DCHECK(drag_drop_controller_.get()); |
| 794 | DCHECK(capture_controller_.get()); |
[email protected] | 8fef743 | 2012-08-06 15:34:25 | [diff] [blame] | 795 | DCHECK(window_cycle_controller_.get()); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 796 | |
| 797 | root_window->set_focus_manager(focus_manager_.get()); |
| 798 | input_method_filter_->SetInputMethodPropertyInRootWindow(root_window); |
| 799 | aura::client::SetActivationClient(root_window, activation_controller_.get()); |
| 800 | aura::client::SetVisibilityClient(root_window, visibility_controller_.get()); |
| 801 | aura::client::SetDragDropClient(root_window, drag_drop_controller_.get()); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 802 | aura::client::SetCaptureClient(root_window, capture_controller_.get()); |
[email protected] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 803 | aura::client::SetScreenPositionClient(root_window, |
| 804 | screen_position_controller_.get()); |
[email protected] | 4b8003c | 2012-07-26 00:54:19 | [diff] [blame] | 805 | aura::client::SetCursorClient(root_window, &cursor_manager_); |
[email protected] | 54a37cdc | 2012-07-25 19:16:01 | [diff] [blame] | 806 | aura::client::SetTooltipClient(root_window, tooltip_controller_.get()); |
[email protected] | e67291f1 | 2012-10-10 05:52:38 | [diff] [blame] | 807 | aura::client::SetEventClient(root_window, event_client_.get()); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 808 | |
| 809 | if (nested_dispatcher_controller_.get()) { |
| 810 | aura::client::SetDispatcherClient(root_window, |
| 811 | nested_dispatcher_controller_.get()); |
| 812 | } |
| 813 | if (user_action_client_.get()) |
| 814 | aura::client::SetUserActionClient(root_window, user_action_client_.get()); |
| 815 | |
| 816 | root_window->SetCursor(ui::kCursorPointer); |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 817 | controller->InitLayoutManagers(); |
[email protected] | f059c694 | 2012-07-21 14:27:57 | [diff] [blame] | 818 | |
| 819 | // TODO(oshima): Move the instance to RootWindowController when |
| 820 | // the extended desktop is enabled by default. |
| 821 | internal::AlwaysOnTopController* always_on_top_controller = |
| 822 | new internal::AlwaysOnTopController; |
[email protected] | c96b981 | 2012-10-17 16:04:04 | [diff] [blame] | 823 | always_on_top_controller->SetAlwaysOnTopContainer( |
[email protected] | f059c694 | 2012-07-21 14:27:57 | [diff] [blame] | 824 | root_window->GetChildById(internal::kShellWindowId_AlwaysOnTopContainer)); |
| 825 | root_window->SetProperty(internal::kAlwaysOnTopControllerKey, |
| 826 | always_on_top_controller); |
[email protected] | 8674b31 | 2012-10-12 19:02:44 | [diff] [blame] | 827 | if (GetPrimaryRootWindowController()->GetSystemModalLayoutManager(NULL)-> |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 828 | has_modal_background()) { |
[email protected] | 8674b31 | 2012-10-12 19:02:44 | [diff] [blame] | 829 | controller->GetSystemModalLayoutManager(NULL)->CreateModalBackground(); |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 830 | } |
[email protected] | 8fef743 | 2012-08-06 15:34:25 | [diff] [blame] | 831 | |
| 832 | window_cycle_controller_->OnRootWindowAdded(root_window); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 833 | } |
| 834 | |
[email protected] | 46ca363 | 2011-11-03 03:33:42 | [diff] [blame] | 835 | //////////////////////////////////////////////////////////////////////////////// |
| 836 | // Shell, private: |
| 837 | |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 838 | bool Shell::CanWindowReceiveEvents(aura::Window* window) { |
| 839 | RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 840 | for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 841 | iter != controllers.end(); ++iter) { |
[email protected] | 8674b31 | 2012-10-12 19:02:44 | [diff] [blame] | 842 | if ((*iter)->GetSystemModalLayoutManager(window)-> |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 843 | CanWindowReceiveEvents(window)) { |
| 844 | return true; |
| 845 | } |
| 846 | } |
| 847 | return false; |
| 848 | } |
| 849 | |
[email protected] | 5097e69 | 2012-10-30 22:08:41 | [diff] [blame] | 850 | bool Shell::CanAcceptEvents() { |
| 851 | return true; |
| 852 | } |
| 853 | |
| 854 | ui::EventTarget* Shell::GetParentTarget() { |
| 855 | return NULL; |
| 856 | } |
| 857 | |
[email protected] | 55f59335 | 2011-12-24 05:42:46 | [diff] [blame] | 858 | } // namespace ash |