| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "ui/aura/aura_switches.h" | 9 #include "ui/aura/aura_switches.h" |
| 10 #include "ui/aura/client/aura_constants.h" | 10 #include "ui/aura/client/aura_constants.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 } | 120 } |
| 121 | 121 |
| 122 Shell::~Shell() { | 122 Shell::~Shell() { |
| 123 RemoveDesktopEventFilter(accelerator_filter_.get()); | 123 RemoveDesktopEventFilter(accelerator_filter_.get()); |
| 124 | 124 |
| 125 // ShellTooltipManager needs a valid shell instance. We delete it before | 125 // ShellTooltipManager needs a valid shell instance. We delete it before |
| 126 // deleting the shell |instance_|. | 126 // deleting the shell |instance_|. |
| 127 RemoveDesktopEventFilter(tooltip_manager_.get()); | 127 RemoveDesktopEventFilter(tooltip_manager_.get()); |
| 128 aura::Desktop::GetInstance()->SetProperty(aura::kDesktopTooltipClientKey, | 128 aura::Desktop::GetInstance()->SetProperty(aura::kDesktopTooltipClientKey, |
| 129 NULL); | 129 NULL); |
| 130 |
| 131 // Make sure we delete WorkspaceController before launcher is |
| 132 // deleted as it has a reference to launcher model. |
| 133 workspace_controller_.reset(); |
| 134 launcher_.reset(); |
| 135 |
| 136 // Delete containers now so that child windows does not access |
| 137 // observers when they are destructed. This has to be after launcher |
| 138 // is destructed because launcher closes the widget in its destructor. |
| 139 aura::Desktop* desktop_window = aura::Desktop::GetInstance(); |
| 140 while (!desktop_window->children().empty()) { |
| 141 aura::Window* child = desktop_window->children()[0]; |
| 142 delete child; |
| 143 } |
| 144 |
| 130 tooltip_manager_.reset(); | 145 tooltip_manager_.reset(); |
| 131 | 146 |
| 132 // Drag drop controller needs a valid shell instance. We destroy it first. | 147 // Drag drop controller needs a valid shell instance. We destroy it first. |
| 133 drag_drop_controller_.reset(); | 148 drag_drop_controller_.reset(); |
| 134 | 149 |
| 135 DCHECK(instance_ == this); | 150 DCHECK(instance_ == this); |
| 136 instance_ = NULL; | 151 instance_ = NULL; |
| 137 | |
| 138 // Make sure we delete WorkspaceController before launcher is | |
| 139 // deleted as it has a reference to launcher model. | |
| 140 workspace_controller_.reset(); | |
| 141 } | 152 } |
| 142 | 153 |
| 143 // static | 154 // static |
| 144 Shell* Shell::CreateInstance(ShellDelegate* delegate) { | 155 Shell* Shell::CreateInstance(ShellDelegate* delegate) { |
| 145 CHECK(!instance_); | 156 CHECK(!instance_); |
| 146 instance_ = new Shell(delegate); | 157 instance_ = new Shell(delegate); |
| 147 instance_->Init(); | 158 instance_->Init(); |
| 148 return instance_; | 159 return instance_; |
| 149 } | 160 } |
| 150 | 161 |
| 151 // static | 162 // static |
| 152 Shell* Shell::GetInstance() { | 163 Shell* Shell::GetInstance() { |
| 153 DCHECK(instance_); | 164 DCHECK(instance_); |
| 154 return instance_; | 165 return instance_; |
| 155 } | 166 } |
| 156 | 167 |
| 157 // static | 168 // static |
| 158 void Shell::DeleteInstanceForTesting() { | 169 void Shell::DeleteInstance() { |
| 159 delete instance_; | 170 delete instance_; |
| 160 instance_ = NULL; | 171 instance_ = NULL; |
| 161 } | 172 } |
| 162 | 173 |
| 163 void Shell::Init() { | 174 void Shell::Init() { |
| 164 aura::Desktop* desktop_window = aura::Desktop::GetInstance(); | 175 aura::Desktop* desktop_window = aura::Desktop::GetInstance(); |
| 165 desktop_window->SetCursor(aura::kCursorPointer); | 176 desktop_window->SetCursor(aura::kCursorPointer); |
| 166 | 177 |
| 167 aura::Window::Windows containers; | 178 aura::Window::Windows containers; |
| 168 CreateSpecialContainers(&containers); | 179 CreateSpecialContainers(&containers); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 new internal::WorkspaceController(default_container)); | 280 new internal::WorkspaceController(default_container)); |
| 270 workspace_controller_->SetLauncherModel(launcher_->model()); | 281 workspace_controller_->SetLauncherModel(launcher_->model()); |
| 271 default_container->SetEventFilter( | 282 default_container->SetEventFilter( |
| 272 new internal::DefaultContainerEventFilter(default_container)); | 283 new internal::DefaultContainerEventFilter(default_container)); |
| 273 default_container->SetLayoutManager( | 284 default_container->SetLayoutManager( |
| 274 new internal::DefaultContainerLayoutManager( | 285 new internal::DefaultContainerLayoutManager( |
| 275 workspace_controller_->workspace_manager())); | 286 workspace_controller_->workspace_manager())); |
| 276 } | 287 } |
| 277 | 288 |
| 278 } // namespace aura_shell | 289 } // namespace aura_shell |
| OLD | NEW |