| 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/aura_switches.h" | 11 #include "ui/aura/aura_switches.h" |
| 12 #include "ui/aura/client/aura_constants.h" | 12 #include "ui/aura/client/aura_constants.h" |
| 13 #include "ui/aura/client/drag_drop_client.h" | 13 #include "ui/aura/client/drag_drop_client.h" |
| 14 #include "ui/aura/layout_manager.h" |
| 14 #include "ui/aura/root_window.h" | 15 #include "ui/aura/root_window.h" |
| 15 #include "ui/aura/layout_manager.h" | |
| 16 #include "ui/aura/window.h" | 16 #include "ui/aura/window.h" |
| 17 #include "ui/aura/window_types.h" | 17 #include "ui/aura/window_types.h" |
| 18 #include "ui/aura_shell/activation_controller.h" | 18 #include "ui/aura_shell/activation_controller.h" |
| 19 #include "ui/aura_shell/app_list.h" | 19 #include "ui/aura_shell/app_list.h" |
| 20 #include "ui/aura_shell/default_container_event_filter.h" | 20 #include "ui/aura_shell/default_container_event_filter.h" |
| 21 #include "ui/aura_shell/default_container_layout_manager.h" | 21 #include "ui/aura_shell/default_container_layout_manager.h" |
| 22 #include "ui/aura_shell/root_window_event_filter.h" | |
| 23 #include "ui/aura_shell/root_window_layout_manager.h" | |
| 24 #include "ui/aura_shell/drag_drop_controller.h" | 22 #include "ui/aura_shell/drag_drop_controller.h" |
| 23 #include "ui/aura_shell/input_method_event_filter.h" |
| 25 #include "ui/aura_shell/laptop_mode_layout_manager.h" | 24 #include "ui/aura_shell/laptop_mode_layout_manager.h" |
| 26 #include "ui/aura_shell/launcher/launcher.h" | 25 #include "ui/aura_shell/launcher/launcher.h" |
| 27 #include "ui/aura_shell/modal_container_layout_manager.h" | 26 #include "ui/aura_shell/modal_container_layout_manager.h" |
| 27 #include "ui/aura_shell/root_window_event_filter.h" |
| 28 #include "ui/aura_shell/root_window_layout_manager.h" |
| 28 #include "ui/aura_shell/shadow_controller.h" | 29 #include "ui/aura_shell/shadow_controller.h" |
| 29 #include "ui/aura_shell/shelf_layout_manager.h" | 30 #include "ui/aura_shell/shelf_layout_manager.h" |
| 30 #include "ui/aura_shell/shell_accelerator_controller.h" | 31 #include "ui/aura_shell/shell_accelerator_controller.h" |
| 31 #include "ui/aura_shell/shell_accelerator_filter.h" | 32 #include "ui/aura_shell/shell_accelerator_filter.h" |
| 32 #include "ui/aura_shell/shell_delegate.h" | 33 #include "ui/aura_shell/shell_delegate.h" |
| 33 #include "ui/aura_shell/shell_factory.h" | 34 #include "ui/aura_shell/shell_factory.h" |
| 34 #include "ui/aura_shell/shell_tooltip_manager.h" | 35 #include "ui/aura_shell/shell_tooltip_manager.h" |
| 35 #include "ui/aura_shell/shell_window_ids.h" | 36 #include "ui/aura_shell/shell_window_ids.h" |
| 36 #include "ui/aura_shell/stacking_controller.h" | 37 #include "ui/aura_shell/stacking_controller.h" |
| 37 #include "ui/aura_shell/status_area_layout_manager.h" | 38 #include "ui/aura_shell/status_area_layout_manager.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 | 121 |
| 121 Shell::Shell(ShellDelegate* delegate) | 122 Shell::Shell(ShellDelegate* delegate) |
| 122 : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), | 123 : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), |
| 123 accelerator_controller_(new ShellAcceleratorController), | 124 accelerator_controller_(new ShellAcceleratorController), |
| 124 delegate_(delegate) { | 125 delegate_(delegate) { |
| 125 aura::RootWindow::GetInstance()->SetEventFilter( | 126 aura::RootWindow::GetInstance()->SetEventFilter( |
| 126 new internal::RootWindowEventFilter); | 127 new internal::RootWindowEventFilter); |
| 127 } | 128 } |
| 128 | 129 |
| 129 Shell::~Shell() { | 130 Shell::~Shell() { |
| 131 RemoveRootWindowEventFilter(input_method_filter_.get()); |
| 130 RemoveRootWindowEventFilter(accelerator_filter_.get()); | 132 RemoveRootWindowEventFilter(accelerator_filter_.get()); |
| 131 | 133 |
| 132 // ShellTooltipManager needs a valid shell instance. We delete it before | 134 // ShellTooltipManager needs a valid shell instance. We delete it before |
| 133 // deleting the shell |instance_|. | 135 // deleting the shell |instance_|. |
| 134 RemoveRootWindowEventFilter(tooltip_manager_.get()); | 136 RemoveRootWindowEventFilter(tooltip_manager_.get()); |
| 135 aura::RootWindow::GetInstance()->SetProperty( | 137 aura::RootWindow::GetInstance()->SetProperty( |
| 136 aura::kRootWindowTooltipClientKey, | 138 aura::kRootWindowTooltipClientKey, |
| 137 NULL); | 139 NULL); |
| 138 | 140 |
| 139 // Make sure we delete WorkspaceController before launcher is | 141 // Make sure we delete WorkspaceController before launcher is |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 | 200 |
| 199 InitLayoutManagers(root_window); | 201 InitLayoutManagers(root_window); |
| 200 | 202 |
| 201 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 203 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 202 if (!command_line->HasSwitch(switches::kAuraNoShadows)) | 204 if (!command_line->HasSwitch(switches::kAuraNoShadows)) |
| 203 shadow_controller_.reset(new internal::ShadowController()); | 205 shadow_controller_.reset(new internal::ShadowController()); |
| 204 | 206 |
| 205 // Force a layout. | 207 // Force a layout. |
| 206 root_window->layout_manager()->OnWindowResized(); | 208 root_window->layout_manager()->OnWindowResized(); |
| 207 | 209 |
| 210 // Initialize InputMethodEventFilter. The filter must be added first since it |
| 211 // has the highest priority. |
| 212 DCHECK(!GetNumRootWindowEventFilters()); |
| 213 input_method_filter_.reset(new internal::InputMethodEventFilter); |
| 214 AddRootWindowEventFilter(input_method_filter_.get()); |
| 215 |
| 208 // Initialize ShellAcceleratorFilter | 216 // Initialize ShellAcceleratorFilter |
| 209 accelerator_filter_.reset(new internal::ShellAcceleratorFilter); | 217 accelerator_filter_.reset(new internal::ShellAcceleratorFilter); |
| 210 AddRootWindowEventFilter(accelerator_filter_.get()); | 218 AddRootWindowEventFilter(accelerator_filter_.get()); |
| 211 | 219 |
| 212 // Initialize ShellTooltipManager | 220 // Initialize ShellTooltipManager |
| 213 tooltip_manager_.reset(new ShellTooltipManager); | 221 tooltip_manager_.reset(new ShellTooltipManager); |
| 214 aura::RootWindow::GetInstance()->SetProperty( | 222 aura::RootWindow::GetInstance()->SetProperty( |
| 215 aura::kRootWindowTooltipClientKey, | 223 aura::kRootWindowTooltipClientKey, |
| 216 static_cast<aura::TooltipClient*>(tooltip_manager_.get())); | 224 static_cast<aura::TooltipClient*>(tooltip_manager_.get())); |
| 217 AddRootWindowEventFilter(tooltip_manager_.get()); | 225 AddRootWindowEventFilter(tooltip_manager_.get()); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 void Shell::AddRootWindowEventFilter(aura::EventFilter* filter) { | 294 void Shell::AddRootWindowEventFilter(aura::EventFilter* filter) { |
| 287 static_cast<internal::RootWindowEventFilter*>( | 295 static_cast<internal::RootWindowEventFilter*>( |
| 288 aura::RootWindow::GetInstance()->event_filter())->AddFilter(filter); | 296 aura::RootWindow::GetInstance()->event_filter())->AddFilter(filter); |
| 289 } | 297 } |
| 290 | 298 |
| 291 void Shell::RemoveRootWindowEventFilter(aura::EventFilter* filter) { | 299 void Shell::RemoveRootWindowEventFilter(aura::EventFilter* filter) { |
| 292 static_cast<internal::RootWindowEventFilter*>( | 300 static_cast<internal::RootWindowEventFilter*>( |
| 293 aura::RootWindow::GetInstance()->event_filter())->RemoveFilter(filter); | 301 aura::RootWindow::GetInstance()->event_filter())->RemoveFilter(filter); |
| 294 } | 302 } |
| 295 | 303 |
| 304 size_t Shell::GetNumRootWindowEventFilters() const { |
| 305 return static_cast<internal::RootWindowEventFilter*>( |
| 306 aura::RootWindow::GetInstance()->event_filter())->GetNumFilters(); |
| 307 } |
| 308 |
| 296 void Shell::ToggleOverview() { | 309 void Shell::ToggleOverview() { |
| 297 if (workspace_controller_.get()) | 310 if (workspace_controller_.get()) |
| 298 workspace_controller_->ToggleOverview(); | 311 workspace_controller_->ToggleOverview(); |
| 299 } | 312 } |
| 300 | 313 |
| 301 void Shell::ToggleAppList() { | 314 void Shell::ToggleAppList() { |
| 302 if (!app_list_.get()) | 315 if (!app_list_.get()) |
| 303 app_list_.reset(new internal::AppList); | 316 app_list_.reset(new internal::AppList); |
| 304 app_list_->SetVisible(!app_list_->IsVisible()); | 317 app_list_->SetVisible(!app_list_->IsVisible()); |
| 305 } | 318 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 330 new internal::WorkspaceController(default_container)); | 343 new internal::WorkspaceController(default_container)); |
| 331 workspace_controller_->SetLauncherModel(launcher_->model()); | 344 workspace_controller_->SetLauncherModel(launcher_->model()); |
| 332 default_container->SetEventFilter( | 345 default_container->SetEventFilter( |
| 333 new internal::DefaultContainerEventFilter(default_container)); | 346 new internal::DefaultContainerEventFilter(default_container)); |
| 334 default_container->SetLayoutManager( | 347 default_container->SetLayoutManager( |
| 335 new internal::DefaultContainerLayoutManager( | 348 new internal::DefaultContainerLayoutManager( |
| 336 workspace_controller_->workspace_manager())); | 349 workspace_controller_->workspace_manager())); |
| 337 } | 350 } |
| 338 | 351 |
| 339 } // namespace aura_shell | 352 } // namespace aura_shell |
| OLD | NEW |