OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/shell.h" | 5 #include "ash/shell.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "ash/accelerators/accelerator_controller.h" | 10 #include "ash/accelerators/accelerator_controller.h" |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 // static | 189 // static |
190 Shell* Shell::CreateInstance(const ShellInitParams& init_params) { | 190 Shell* Shell::CreateInstance(const ShellInitParams& init_params) { |
191 CHECK(!instance_); | 191 CHECK(!instance_); |
192 instance_ = new Shell(init_params.delegate); | 192 instance_ = new Shell(init_params.delegate); |
193 instance_->Init(init_params); | 193 instance_->Init(init_params); |
194 return instance_; | 194 return instance_; |
195 } | 195 } |
196 | 196 |
197 // static | 197 // static |
198 Shell* Shell::GetInstance() { | 198 Shell* Shell::GetInstance() { |
199 DCHECK(instance_); | 199 CHECK(instance_); |
200 return instance_; | 200 return instance_; |
201 } | 201 } |
202 | 202 |
203 // static | 203 // static |
204 bool Shell::HasInstance() { | 204 bool Shell::HasInstance() { |
205 return !!instance_; | 205 return !!instance_; |
206 } | 206 } |
207 | 207 |
208 // static | 208 // static |
209 void Shell::DeleteInstance() { | 209 void Shell::DeleteInstance() { |
210 delete instance_; | 210 delete instance_; |
211 instance_ = NULL; | 211 instance_ = NULL; |
212 } | 212 } |
213 | 213 |
214 // static | 214 // static |
215 RootWindowController* Shell::GetPrimaryRootWindowController() { | 215 RootWindowController* Shell::GetPrimaryRootWindowController() { |
| 216 CHECK(HasInstance()); |
216 return GetRootWindowController(GetPrimaryRootWindow()); | 217 return GetRootWindowController(GetPrimaryRootWindow()); |
217 } | 218 } |
218 | 219 |
219 // static | 220 // static |
220 Shell::RootWindowControllerList Shell::GetAllRootWindowControllers() { | 221 Shell::RootWindowControllerList Shell::GetAllRootWindowControllers() { |
| 222 CHECK(HasInstance()); |
221 return Shell::GetInstance()->display_controller()-> | 223 return Shell::GetInstance()->display_controller()-> |
222 GetAllRootWindowControllers(); | 224 GetAllRootWindowControllers(); |
223 } | 225 } |
224 | 226 |
225 // static | 227 // static |
226 aura::Window* Shell::GetPrimaryRootWindow() { | 228 aura::Window* Shell::GetPrimaryRootWindow() { |
| 229 CHECK(HasInstance()); |
227 return GetInstance()->display_controller()->GetPrimaryRootWindow(); | 230 return GetInstance()->display_controller()->GetPrimaryRootWindow(); |
228 } | 231 } |
229 | 232 |
230 // static | 233 // static |
231 aura::Window* Shell::GetTargetRootWindow() { | 234 aura::Window* Shell::GetTargetRootWindow() { |
| 235 CHECK(HasInstance()); |
232 Shell* shell = GetInstance(); | 236 Shell* shell = GetInstance(); |
233 if (shell->scoped_target_root_window_) | 237 if (shell->scoped_target_root_window_) |
234 return shell->scoped_target_root_window_; | 238 return shell->scoped_target_root_window_; |
235 return shell->target_root_window_; | 239 return shell->target_root_window_; |
236 } | 240 } |
237 | 241 |
238 // static | 242 // static |
239 gfx::Screen* Shell::GetScreen() { | 243 gfx::Screen* Shell::GetScreen() { |
240 return gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE); | 244 return gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE); |
241 } | 245 } |
242 | 246 |
243 // static | 247 // static |
244 aura::Window::Windows Shell::GetAllRootWindows() { | 248 aura::Window::Windows Shell::GetAllRootWindows() { |
| 249 CHECK(HasInstance()); |
245 return Shell::GetInstance()->display_controller()-> | 250 return Shell::GetInstance()->display_controller()-> |
246 GetAllRootWindows(); | 251 GetAllRootWindows(); |
247 } | 252 } |
248 | 253 |
249 // static | 254 // static |
250 aura::Window* Shell::GetContainer(aura::Window* root_window, | 255 aura::Window* Shell::GetContainer(aura::Window* root_window, |
251 int container_id) { | 256 int container_id) { |
252 return root_window->GetChildById(container_id); | 257 return root_window->GetChildById(container_id); |
253 } | 258 } |
254 | 259 |
(...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1154 //////////////////////////////////////////////////////////////////////////////// | 1159 //////////////////////////////////////////////////////////////////////////////// |
1155 // Shell, aura::client::ActivationChangeObserver implementation: | 1160 // Shell, aura::client::ActivationChangeObserver implementation: |
1156 | 1161 |
1157 void Shell::OnWindowActivated(aura::Window* gained_active, | 1162 void Shell::OnWindowActivated(aura::Window* gained_active, |
1158 aura::Window* lost_active) { | 1163 aura::Window* lost_active) { |
1159 if (gained_active) | 1164 if (gained_active) |
1160 target_root_window_ = gained_active->GetRootWindow(); | 1165 target_root_window_ = gained_active->GetRootWindow(); |
1161 } | 1166 } |
1162 | 1167 |
1163 } // namespace ash | 1168 } // namespace ash |
OLD | NEW |