OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "athena/screen/public/screen_manager.h" | 5 #include "athena/screen/public/screen_manager.h" |
6 | 6 |
7 #include "athena/screen/background_controller.h" | 7 #include "athena/screen/background_controller.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "ui/aura/client/window_tree_client.h" | 10 #include "ui/aura/client/window_tree_client.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 aura::Window* window, | 66 aura::Window* window, |
67 const gfx::Rect& bounds) OVERRIDE { | 67 const gfx::Rect& bounds) OVERRIDE { |
68 return container_; | 68 return container_; |
69 } | 69 } |
70 | 70 |
71 aura::Window* container_; | 71 aura::Window* container_; |
72 | 72 |
73 DISALLOW_COPY_AND_ASSIGN(AthenaWindowTreeClient); | 73 DISALLOW_COPY_AND_ASSIGN(AthenaWindowTreeClient); |
74 }; | 74 }; |
75 | 75 |
76 aura::Window* CreateContainer(aura::Window* parent, const std::string& name) { | 76 aura::Window* CreateContainerInternal(aura::Window* parent, |
| 77 const std::string& name) { |
77 aura::Window* container = new aura::Window(NULL); | 78 aura::Window* container = new aura::Window(NULL); |
78 container->Init(aura::WINDOW_LAYER_NOT_DRAWN); | 79 container->Init(aura::WINDOW_LAYER_NOT_DRAWN); |
79 container->SetName(name); | 80 container->SetName(name); |
80 parent->AddChild(container); | 81 parent->AddChild(container); |
81 container->Show(); | 82 container->Show(); |
82 return container; | 83 return container; |
83 } | 84 } |
84 | 85 |
85 class ScreenManagerImpl : public ScreenManager { | 86 class ScreenManagerImpl : public ScreenManager { |
86 public: | 87 public: |
87 explicit ScreenManagerImpl(aura::Window* root_window); | 88 explicit ScreenManagerImpl(aura::Window* root_window); |
88 virtual ~ScreenManagerImpl(); | 89 virtual ~ScreenManagerImpl(); |
89 | 90 |
90 void Init(); | 91 void Init(); |
91 | 92 |
92 private: | 93 private: |
93 // Screenmanager: | 94 // ScreenManager: |
94 virtual aura::Window* GetContainerWindow() OVERRIDE { return container_; } | 95 virtual aura::Window* CreateDefaultContainer( |
| 96 const std::string& name) OVERRIDE; |
| 97 virtual aura::Window* CreateContainer(const std::string& name) OVERRIDE; |
95 virtual aura::Window* GetContext() OVERRIDE { return root_window_; } | 98 virtual aura::Window* GetContext() OVERRIDE { return root_window_; } |
96 virtual void SetBackgroundImage(const gfx::ImageSkia& image) OVERRIDE; | 99 virtual void SetBackgroundImage(const gfx::ImageSkia& image) OVERRIDE; |
97 | 100 |
98 aura::Window* root_window_; | 101 aura::Window* root_window_; |
99 // A container used for apps/web windows. | |
100 aura::Window* container_; | |
101 aura::Window* background_window_; | 102 aura::Window* background_window_; |
| 103 |
102 scoped_ptr<BackgroundController> background_controller_; | 104 scoped_ptr<BackgroundController> background_controller_; |
103 scoped_ptr<aura::client::WindowTreeClient> window_tree_client_; | 105 scoped_ptr<aura::client::WindowTreeClient> window_tree_client_; |
104 | 106 |
105 DISALLOW_COPY_AND_ASSIGN(ScreenManagerImpl); | 107 DISALLOW_COPY_AND_ASSIGN(ScreenManagerImpl); |
106 }; | 108 }; |
107 | 109 |
108 void ScreenManagerImpl::Init() { | 110 void ScreenManagerImpl::Init() { |
109 root_window_->SetLayoutManager(new FillLayoutManager(root_window_)); | 111 root_window_->SetLayoutManager(new FillLayoutManager(root_window_)); |
110 background_window_ = CreateContainer(root_window_, "AthenaBackground"); | 112 background_window_ = |
| 113 CreateContainerInternal(root_window_, "AthenaBackground"); |
111 background_window_->SetLayoutManager( | 114 background_window_->SetLayoutManager( |
112 new FillLayoutManager(background_window_)); | 115 new FillLayoutManager(background_window_)); |
113 background_controller_.reset(new BackgroundController(background_window_)); | 116 background_controller_.reset(new BackgroundController(background_window_)); |
114 container_ = CreateContainer(root_window_, "AthenaContainer"); | 117 } |
115 | 118 |
116 window_tree_client_.reset(new AthenaWindowTreeClient(container_)); | 119 aura::Window* ScreenManagerImpl::CreateDefaultContainer( |
| 120 const std::string& name) { |
| 121 aura::Window* container = CreateContainerInternal(root_window_, name); |
| 122 window_tree_client_.reset(new AthenaWindowTreeClient(container)); |
117 aura::client::SetWindowTreeClient(root_window_, window_tree_client_.get()); | 123 aura::client::SetWindowTreeClient(root_window_, window_tree_client_.get()); |
| 124 return container; |
| 125 } |
| 126 |
| 127 aura::Window* ScreenManagerImpl::CreateContainer(const std::string& name) { |
| 128 return CreateContainerInternal(root_window_, name); |
118 } | 129 } |
119 | 130 |
120 void ScreenManagerImpl::SetBackgroundImage(const gfx::ImageSkia& image) { | 131 void ScreenManagerImpl::SetBackgroundImage(const gfx::ImageSkia& image) { |
121 background_controller_->SetImage(image); | 132 background_controller_->SetImage(image); |
122 } | 133 } |
123 | 134 |
124 ScreenManagerImpl::ScreenManagerImpl(aura::Window* root_window) | 135 ScreenManagerImpl::ScreenManagerImpl(aura::Window* root_window) |
125 : root_window_(root_window) { | 136 : root_window_(root_window) { |
126 DCHECK(root_window_); | 137 DCHECK(root_window_); |
127 DCHECK(!instance); | 138 DCHECK(!instance); |
(...skipping 21 matching lines...) Expand all Loading... |
149 } | 160 } |
150 | 161 |
151 // static | 162 // static |
152 void ScreenManager::Shutdown() { | 163 void ScreenManager::Shutdown() { |
153 DCHECK(instance); | 164 DCHECK(instance); |
154 delete instance; | 165 delete instance; |
155 DCHECK(!instance); | 166 DCHECK(!instance); |
156 } | 167 } |
157 | 168 |
158 } // namespace athena | 169 } // namespace athena |
OLD | NEW |