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 "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/desktop.h" | 10 #include "ui/aura/desktop.h" |
| 11 #include "ui/aura/toplevel_window_container.h" | 11 #include "ui/aura/toplevel_window_container.h" |
| 12 #include "ui/aura/window.h" | 12 #include "ui/aura/window.h" |
| 13 #include "ui/aura/window_types.h" | 13 #include "ui/aura/window_types.h" |
| 14 #include "ui/aura_shell/always_on_top_controller.h" | |
| 14 #include "ui/aura_shell/default_container_event_filter.h" | 15 #include "ui/aura_shell/default_container_event_filter.h" |
| 15 #include "ui/aura_shell/default_container_layout_manager.h" | 16 #include "ui/aura_shell/default_container_layout_manager.h" |
| 16 #include "ui/aura_shell/desktop_layout_manager.h" | 17 #include "ui/aura_shell/desktop_layout_manager.h" |
| 17 #include "ui/aura_shell/launcher/launcher.h" | 18 #include "ui/aura_shell/launcher/launcher.h" |
| 18 #include "ui/aura_shell/shelf_layout_controller.h" | 19 #include "ui/aura_shell/shelf_layout_controller.h" |
| 19 #include "ui/aura_shell/shell_delegate.h" | 20 #include "ui/aura_shell/shell_delegate.h" |
| 20 #include "ui/aura_shell/shell_factory.h" | 21 #include "ui/aura_shell/shell_factory.h" |
| 21 #include "ui/aura_shell/shell_window_ids.h" | 22 #include "ui/aura_shell/shell_window_ids.h" |
| 22 #include "ui/aura_shell/toplevel_layout_manager.h" | 23 #include "ui/aura_shell/toplevel_layout_manager.h" |
| 23 #include "ui/aura_shell/workspace/workspace_controller.h" | 24 #include "ui/aura_shell/workspace/workspace_controller.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 75 | 76 |
| 76 //////////////////////////////////////////////////////////////////////////////// | 77 //////////////////////////////////////////////////////////////////////////////// |
| 77 // Shell, public: | 78 // Shell, public: |
| 78 | 79 |
| 79 Shell::Shell() | 80 Shell::Shell() |
| 80 : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { | 81 : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { |
| 81 aura::Desktop::GetInstance()->SetDelegate(this); | 82 aura::Desktop::GetInstance()->SetDelegate(this); |
| 82 } | 83 } |
| 83 | 84 |
| 84 Shell::~Shell() { | 85 Shell::~Shell() { |
| 86 DCHECK(instance_ == this); | |
| 87 instance_ = NULL; | |
| 85 } | 88 } |
| 86 | 89 |
| 87 // static | 90 // static |
| 88 Shell* Shell::GetInstance() { | 91 Shell* Shell::GetInstance() { |
| 89 if (!instance_) { | 92 if (!instance_) { |
| 90 instance_ = new Shell; | 93 instance_ = new Shell; |
| 91 instance_->Init(); | 94 instance_->Init(); |
| 92 } | 95 } |
| 93 return instance_; | 96 return instance_; |
| 94 } | 97 } |
| 95 | 98 |
| 96 void Shell::Init() { | 99 void Shell::Init() { |
| 97 aura::Desktop* desktop_window = aura::Desktop::GetInstance(); | 100 aura::Desktop* desktop_window = aura::Desktop::GetInstance(); |
| 98 desktop_window->SetCursor(aura::kCursorPointer); | 101 desktop_window->SetCursor(aura::kCursorPointer); |
| 99 | 102 |
| 100 aura::Window::Windows containers; | 103 aura::Window::Windows containers; |
| 101 CreateSpecialContainers(&containers); | 104 CreateSpecialContainers(&containers); |
| 102 aura::Window::Windows::const_iterator i; | 105 aura::Window::Windows::const_iterator i; |
| 103 for (i = containers.begin(); i != containers.end(); ++i) { | 106 for (i = containers.begin(); i != containers.end(); ++i) { |
| 104 (*i)->Init(ui::Layer::LAYER_HAS_NO_TEXTURE); | 107 (*i)->Init(ui::Layer::LAYER_HAS_NO_TEXTURE); |
| 105 desktop_window->AddChild(*i); | 108 desktop_window->AddChild(*i); |
| 106 (*i)->Show(); | 109 (*i)->Show(); |
| 107 } | 110 } |
| 108 | 111 |
| 112 always_on_top_controller_.reset(new internal::AlwaysOnTopController); | |
| 113 always_on_top_controller_->SetContainers( | |
| 114 GetContainer(internal::kShellWindowId_DefaultContainer), | |
|
Ben Goodger (Google)
2011/11/09 17:18:09
nit: 4-space indent
xiyuan
2011/11/09 17:42:18
Done.
| |
| 115 GetContainer(internal::kShellWindowId_AlwaysOnTopContainer)); | |
| 116 | |
| 109 internal::DesktopLayoutManager* desktop_layout = | 117 internal::DesktopLayoutManager* desktop_layout = |
| 110 new internal::DesktopLayoutManager(desktop_window); | 118 new internal::DesktopLayoutManager(desktop_window); |
| 111 desktop_window->SetLayoutManager(desktop_layout); | 119 desktop_window->SetLayoutManager(desktop_layout); |
| 112 | 120 |
| 113 desktop_layout->set_background_widget(internal::CreateDesktopBackground()); | 121 desktop_layout->set_background_widget(internal::CreateDesktopBackground()); |
| 114 aura::ToplevelWindowContainer* toplevel_container = | 122 aura::ToplevelWindowContainer* toplevel_container = |
| 115 GetContainer(internal::kShellWindowId_DefaultContainer)-> | 123 GetContainer(internal::kShellWindowId_DefaultContainer)-> |
| 116 AsToplevelWindowContainer(); | 124 AsToplevelWindowContainer(); |
| 117 launcher_.reset(new Launcher(toplevel_container)); | 125 launcher_.reset(new Launcher(toplevel_container)); |
| 118 | 126 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 168 } | 176 } |
| 169 | 177 |
| 170 //////////////////////////////////////////////////////////////////////////////// | 178 //////////////////////////////////////////////////////////////////////////////// |
| 171 // Shell, aura::DesktopDelegate implementation: | 179 // Shell, aura::DesktopDelegate implementation: |
| 172 | 180 |
| 173 void Shell::AddChildToDefaultParent(aura::Window* window) { | 181 void Shell::AddChildToDefaultParent(aura::Window* window) { |
| 174 aura::Window* parent = NULL; | 182 aura::Window* parent = NULL; |
| 175 switch (window->type()) { | 183 switch (window->type()) { |
| 176 case aura::WINDOW_TYPE_NORMAL: | 184 case aura::WINDOW_TYPE_NORMAL: |
| 177 case aura::WINDOW_TYPE_POPUP: | 185 case aura::WINDOW_TYPE_POPUP: |
| 178 parent = GetContainer(internal::kShellWindowId_DefaultContainer); | 186 parent = always_on_top_controller_->GetContainer(window); |
| 179 break; | 187 break; |
| 180 case aura::WINDOW_TYPE_MENU: | 188 case aura::WINDOW_TYPE_MENU: |
| 181 case aura::WINDOW_TYPE_TOOLTIP: | 189 case aura::WINDOW_TYPE_TOOLTIP: |
| 182 parent = GetContainer(internal::kShellWindowId_MenusAndTooltipsContainer); | 190 parent = GetContainer(internal::kShellWindowId_MenusAndTooltipsContainer); |
| 183 break; | 191 break; |
| 184 default: | 192 default: |
| 185 NOTREACHED() << "Window " << window->id() | 193 NOTREACHED() << "Window " << window->id() |
| 186 << " has unhandled type " << window->type(); | 194 << " has unhandled type " << window->type(); |
| 187 break; | 195 break; |
| 188 } | 196 } |
| 189 parent->AddChild(window); | 197 parent->AddChild(window); |
| 190 } | 198 } |
| 191 | 199 |
| 192 aura::Window* Shell::GetTopmostWindowToActivate(aura::Window* ignore) const { | 200 aura::Window* Shell::GetTopmostWindowToActivate(aura::Window* ignore) const { |
| 193 const aura::ToplevelWindowContainer* container = | 201 const aura::ToplevelWindowContainer* container = |
| 194 GetContainer(internal::kShellWindowId_DefaultContainer)-> | 202 GetContainer(internal::kShellWindowId_DefaultContainer)-> |
| 195 AsToplevelWindowContainer(); | 203 AsToplevelWindowContainer(); |
| 196 return container->GetTopmostWindowToActivate(ignore); | 204 return container->GetTopmostWindowToActivate(ignore); |
| 197 } | 205 } |
| 198 | 206 |
| 199 } // namespace aura_shell | 207 } // namespace aura_shell |
| OLD | NEW |