Chromium Code Reviews| 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 "ui/aura/aura_constants.h" | |
| 8 #include "ui/aura/desktop.h" | 9 #include "ui/aura/desktop.h" |
| 9 #include "ui/aura/screen_aura.h" | 10 #include "ui/aura/screen_aura.h" |
| 10 #include "ui/aura/toplevel_window_container.h" | 11 #include "ui/aura/toplevel_window_container.h" |
| 11 #include "ui/aura/window.h" | 12 #include "ui/aura/window.h" |
| 12 #include "ui/aura/window_types.h" | 13 #include "ui/aura/window_types.h" |
| 13 #include "ui/aura_shell/default_container_event_filter.h" | 14 #include "ui/aura_shell/default_container_event_filter.h" |
| 14 #include "ui/aura_shell/default_container_layout_manager.h" | 15 #include "ui/aura_shell/default_container_layout_manager.h" |
| 15 #include "ui/aura_shell/desktop_layout_manager.h" | 16 #include "ui/aura_shell/desktop_layout_manager.h" |
| 16 #include "ui/aura_shell/launcher/launcher.h" | 17 #include "ui/aura_shell/launcher/launcher.h" |
| 17 #include "ui/aura_shell/shell_delegate.h" | 18 #include "ui/aura_shell/shell_delegate.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 77 | 78 |
| 78 //////////////////////////////////////////////////////////////////////////////// | 79 //////////////////////////////////////////////////////////////////////////////// |
| 79 // Shell, public: | 80 // Shell, public: |
| 80 | 81 |
| 81 Shell::Shell() | 82 Shell::Shell() |
| 82 : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { | 83 : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { |
| 83 aura::Desktop::GetInstance()->SetDelegate(this); | 84 aura::Desktop::GetInstance()->SetDelegate(this); |
| 84 } | 85 } |
| 85 | 86 |
| 86 Shell::~Shell() { | 87 Shell::~Shell() { |
| 88 if (instance_ == this) | |
|
oshima
2011/11/04 18:14:11
There should be only one Shell instance, so DCHECK
xiyuan
2011/11/04 18:39:31
Done.
| |
| 89 instance_ = NULL; | |
| 87 } | 90 } |
| 88 | 91 |
| 89 // static | 92 // static |
| 90 Shell* Shell::GetInstance() { | 93 Shell* Shell::GetInstance() { |
| 91 if (!instance_) { | 94 if (!instance_) { |
| 92 instance_ = new Shell; | 95 instance_ = new Shell; |
| 93 instance_->Init(); | 96 instance_->Init(); |
| 94 } | 97 } |
| 95 return instance_; | 98 return instance_; |
| 96 } | 99 } |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 154 } | 157 } |
| 155 | 158 |
| 156 //////////////////////////////////////////////////////////////////////////////// | 159 //////////////////////////////////////////////////////////////////////////////// |
| 157 // Shell, aura::DesktopDelegate implementation: | 160 // Shell, aura::DesktopDelegate implementation: |
| 158 | 161 |
| 159 void Shell::AddChildToDefaultParent(aura::Window* window) { | 162 void Shell::AddChildToDefaultParent(aura::Window* window) { |
| 160 aura::Window* parent = NULL; | 163 aura::Window* parent = NULL; |
| 161 switch (window->type()) { | 164 switch (window->type()) { |
| 162 case aura::WINDOW_TYPE_NORMAL: | 165 case aura::WINDOW_TYPE_NORMAL: |
| 163 case aura::WINDOW_TYPE_POPUP: | 166 case aura::WINDOW_TYPE_POPUP: |
| 164 parent = GetContainer(internal::kShellWindowId_DefaultContainer); | 167 if (!!window->GetProperty(aura::kAlwaysOnTopKey)) |
| 168 parent = GetContainer(internal::kShellWindowId_AlwaysOnTopContainer); | |
| 169 else | |
| 170 parent = GetContainer(internal::kShellWindowId_DefaultContainer); | |
| 165 break; | 171 break; |
| 166 case aura::WINDOW_TYPE_MENU: | 172 case aura::WINDOW_TYPE_MENU: |
| 167 case aura::WINDOW_TYPE_TOOLTIP: | 173 case aura::WINDOW_TYPE_TOOLTIP: |
| 168 parent = GetContainer(internal::kShellWindowId_MenusAndTooltipsContainer); | 174 parent = GetContainer(internal::kShellWindowId_MenusAndTooltipsContainer); |
| 169 break; | 175 break; |
| 170 default: | 176 default: |
| 171 NOTREACHED() << "Window " << window->id() | 177 NOTREACHED() << "Window " << window->id() |
| 172 << " has unhandled type " << window->type(); | 178 << " has unhandled type " << window->type(); |
| 173 break; | 179 break; |
| 174 } | 180 } |
| 175 parent->AddChild(window); | 181 parent->AddChild(window); |
| 176 } | 182 } |
| 177 | 183 |
| 178 aura::Window* Shell::GetTopmostWindowToActivate(aura::Window* ignore) const { | 184 aura::Window* Shell::GetTopmostWindowToActivate(aura::Window* ignore) const { |
| 179 const aura::ToplevelWindowContainer* container = | 185 const aura::ToplevelWindowContainer* container = |
| 180 GetContainer(internal::kShellWindowId_DefaultContainer)-> | 186 GetContainer(internal::kShellWindowId_DefaultContainer)-> |
| 181 AsToplevelWindowContainer(); | 187 AsToplevelWindowContainer(); |
| 182 return container->GetTopmostWindowToActivate(ignore); | 188 return container->GetTopmostWindowToActivate(ignore); |
| 183 } | 189 } |
| 184 | 190 |
| 185 } // namespace aura_shell | 191 } // namespace aura_shell |
| OLD | NEW |