| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ui/aura_shell/shell.h" | 5 #include "ui/aura_shell/shell.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "ui/aura/root_window.h" | 11 #include "ui/aura/root_window.h" |
| 12 #include "ui/aura/client/aura_constants.h" |
| 12 #include "ui/aura/layout_manager.h" | 13 #include "ui/aura/layout_manager.h" |
| 14 #include "ui/aura/root_window.h" |
| 13 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
| 14 #include "ui/aura_shell/activation_controller.h" | 16 #include "ui/aura_shell/activation_controller.h" |
| 15 #include "ui/aura_shell/app_list.h" | 17 #include "ui/aura_shell/app_list.h" |
| 16 #include "ui/aura_shell/aura_shell_switches.h" | 18 #include "ui/aura_shell/aura_shell_switches.h" |
| 17 #include "ui/aura_shell/compact_layout_manager.h" | 19 #include "ui/aura_shell/compact_layout_manager.h" |
| 18 #include "ui/aura_shell/compact_status_area_layout_manager.h" | 20 #include "ui/aura_shell/compact_status_area_layout_manager.h" |
| 19 #include "ui/aura_shell/default_container_event_filter.h" | 21 #include "ui/aura_shell/default_container_event_filter.h" |
| 20 #include "ui/aura_shell/default_container_layout_manager.h" | 22 #include "ui/aura_shell/default_container_layout_manager.h" |
| 23 #include "ui/aura_shell/drag_drop_controller.h" |
| 24 #include "ui/aura_shell/input_method_event_filter.h" |
| 25 #include "ui/aura_shell/launcher/launcher.h" |
| 26 #include "ui/aura_shell/modal_container_layout_manager.h" |
| 21 #include "ui/aura_shell/root_window_event_filter.h" | 27 #include "ui/aura_shell/root_window_event_filter.h" |
| 22 #include "ui/aura_shell/root_window_layout_manager.h" | 28 #include "ui/aura_shell/root_window_layout_manager.h" |
| 23 #include "ui/aura_shell/drag_drop_controller.h" | |
| 24 #include "ui/aura_shell/launcher/launcher.h" | |
| 25 #include "ui/aura_shell/modal_container_layout_manager.h" | |
| 26 #include "ui/aura_shell/shadow_controller.h" | 29 #include "ui/aura_shell/shadow_controller.h" |
| 27 #include "ui/aura_shell/shelf_layout_manager.h" | 30 #include "ui/aura_shell/shelf_layout_manager.h" |
| 28 #include "ui/aura_shell/shell_accelerator_controller.h" | 31 #include "ui/aura_shell/shell_accelerator_controller.h" |
| 29 #include "ui/aura_shell/shell_accelerator_filter.h" | 32 #include "ui/aura_shell/shell_accelerator_filter.h" |
| 30 #include "ui/aura_shell/shell_delegate.h" | 33 #include "ui/aura_shell/shell_delegate.h" |
| 31 #include "ui/aura_shell/shell_factory.h" | 34 #include "ui/aura_shell/shell_factory.h" |
| 32 #include "ui/aura_shell/shell_window_ids.h" | 35 #include "ui/aura_shell/shell_window_ids.h" |
| 33 #include "ui/aura_shell/stacking_controller.h" | 36 #include "ui/aura_shell/stacking_controller.h" |
| 34 #include "ui/aura_shell/status_area_layout_manager.h" | 37 #include "ui/aura_shell/status_area_layout_manager.h" |
| 35 #include "ui/aura_shell/tooltip_controller.h" | 38 #include "ui/aura_shell/tooltip_controller.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 | 121 |
| 119 Shell::Shell(ShellDelegate* delegate) | 122 Shell::Shell(ShellDelegate* delegate) |
| 120 : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), | 123 : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), |
| 121 accelerator_controller_(new ShellAcceleratorController), | 124 accelerator_controller_(new ShellAcceleratorController), |
| 122 delegate_(delegate) { | 125 delegate_(delegate) { |
| 123 aura::RootWindow::GetInstance()->SetEventFilter( | 126 aura::RootWindow::GetInstance()->SetEventFilter( |
| 124 new internal::RootWindowEventFilter); | 127 new internal::RootWindowEventFilter); |
| 125 } | 128 } |
| 126 | 129 |
| 127 Shell::~Shell() { | 130 Shell::~Shell() { |
| 131 RemoveRootWindowEventFilter(input_method_filter_.get()); |
| 128 RemoveRootWindowEventFilter(accelerator_filter_.get()); | 132 RemoveRootWindowEventFilter(accelerator_filter_.get()); |
| 129 | 133 |
| 130 // TooltipController needs a valid shell instance. We delete it before | 134 // TooltipController needs a valid shell instance. We delete it before |
| 131 // deleting the shell |instance_|. | 135 // deleting the shell |instance_|. |
| 132 RemoveRootWindowEventFilter(tooltip_controller_.get()); | 136 RemoveRootWindowEventFilter(tooltip_controller_.get()); |
| 133 | 137 |
| 134 // Make sure we delete WorkspaceController before launcher is | 138 // Make sure we delete WorkspaceController before launcher is |
| 135 // deleted as it has a reference to launcher model. | 139 // deleted as it has a reference to launcher model. |
| 136 workspace_controller_.reset(); | 140 workspace_controller_.reset(); |
| 137 launcher_.reset(); | 141 launcher_.reset(); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 | 197 |
| 194 InitLayoutManagers(root_window); | 198 InitLayoutManagers(root_window); |
| 195 | 199 |
| 196 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 200 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 197 if (!command_line->HasSwitch(switches::kAuraNoShadows)) | 201 if (!command_line->HasSwitch(switches::kAuraNoShadows)) |
| 198 shadow_controller_.reset(new internal::ShadowController()); | 202 shadow_controller_.reset(new internal::ShadowController()); |
| 199 | 203 |
| 200 // Force a layout. | 204 // Force a layout. |
| 201 root_window->layout_manager()->OnWindowResized(); | 205 root_window->layout_manager()->OnWindowResized(); |
| 202 | 206 |
| 207 // Initialize InputMethodEventFilter. The filter must be added first since it |
| 208 // has the highest priority. |
| 209 DCHECK(!GetRootWindowEventFilterCount()); |
| 210 input_method_filter_.reset(new internal::InputMethodEventFilter); |
| 211 AddRootWindowEventFilter(input_method_filter_.get()); |
| 212 |
| 203 // Initialize ShellAcceleratorFilter | 213 // Initialize ShellAcceleratorFilter |
| 204 accelerator_filter_.reset(new internal::ShellAcceleratorFilter); | 214 accelerator_filter_.reset(new internal::ShellAcceleratorFilter); |
| 205 AddRootWindowEventFilter(accelerator_filter_.get()); | 215 AddRootWindowEventFilter(accelerator_filter_.get()); |
| 206 | 216 |
| 207 // Initialize TooltipController. | 217 // Initialize TooltipController. |
| 208 tooltip_controller_.reset(new internal::TooltipController); | 218 tooltip_controller_.reset(new internal::TooltipController); |
| 209 AddRootWindowEventFilter(tooltip_controller_.get()); | 219 AddRootWindowEventFilter(tooltip_controller_.get()); |
| 210 | 220 |
| 211 // Initialize drag drop controller. | 221 // Initialize drag drop controller. |
| 212 drag_drop_controller_.reset(new internal::DragDropController); | 222 drag_drop_controller_.reset(new internal::DragDropController); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 void Shell::AddRootWindowEventFilter(aura::EventFilter* filter) { | 288 void Shell::AddRootWindowEventFilter(aura::EventFilter* filter) { |
| 279 static_cast<internal::RootWindowEventFilter*>( | 289 static_cast<internal::RootWindowEventFilter*>( |
| 280 aura::RootWindow::GetInstance()->event_filter())->AddFilter(filter); | 290 aura::RootWindow::GetInstance()->event_filter())->AddFilter(filter); |
| 281 } | 291 } |
| 282 | 292 |
| 283 void Shell::RemoveRootWindowEventFilter(aura::EventFilter* filter) { | 293 void Shell::RemoveRootWindowEventFilter(aura::EventFilter* filter) { |
| 284 static_cast<internal::RootWindowEventFilter*>( | 294 static_cast<internal::RootWindowEventFilter*>( |
| 285 aura::RootWindow::GetInstance()->event_filter())->RemoveFilter(filter); | 295 aura::RootWindow::GetInstance()->event_filter())->RemoveFilter(filter); |
| 286 } | 296 } |
| 287 | 297 |
| 298 size_t Shell::GetRootWindowEventFilterCount() const { |
| 299 return static_cast<internal::RootWindowEventFilter*>( |
| 300 aura::RootWindow::GetInstance()->event_filter())->GetFilterCount(); |
| 301 } |
| 302 |
| 288 void Shell::ToggleOverview() { | 303 void Shell::ToggleOverview() { |
| 289 if (workspace_controller_.get()) | 304 if (workspace_controller_.get()) |
| 290 workspace_controller_->ToggleOverview(); | 305 workspace_controller_->ToggleOverview(); |
| 291 } | 306 } |
| 292 | 307 |
| 293 void Shell::ToggleAppList() { | 308 void Shell::ToggleAppList() { |
| 294 if (!app_list_.get()) | 309 if (!app_list_.get()) |
| 295 app_list_.reset(new internal::AppList); | 310 app_list_.reset(new internal::AppList); |
| 296 app_list_->SetVisible(!app_list_->IsVisible()); | 311 app_list_->SetVisible(!app_list_->IsVisible()); |
| 297 } | 312 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 322 new internal::WorkspaceController(default_container)); | 337 new internal::WorkspaceController(default_container)); |
| 323 workspace_controller_->SetLauncherModel(launcher_->model()); | 338 workspace_controller_->SetLauncherModel(launcher_->model()); |
| 324 default_container->SetEventFilter( | 339 default_container->SetEventFilter( |
| 325 new internal::DefaultContainerEventFilter(default_container)); | 340 new internal::DefaultContainerEventFilter(default_container)); |
| 326 default_container->SetLayoutManager( | 341 default_container->SetLayoutManager( |
| 327 new internal::DefaultContainerLayoutManager( | 342 new internal::DefaultContainerLayoutManager( |
| 328 workspace_controller_->workspace_manager())); | 343 workspace_controller_->workspace_manager())); |
| 329 } | 344 } |
| 330 | 345 |
| 331 } // namespace aura_shell | 346 } // namespace aura_shell |
| OLD | NEW |