OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stdio.h> | 5 #include <stdio.h> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "mojo/aura/context_factory_mojo.h" | 9 #include "mojo/aura/context_factory_mojo.h" |
10 #include "mojo/aura/screen_mojo.h" | 10 #include "mojo/aura/screen_mojo.h" |
11 #include "mojo/aura/window_tree_host_mojo.h" | 11 #include "mojo/aura/window_tree_host_mojo.h" |
12 #include "mojo/aura/window_tree_host_mojo_delegate.h" | 12 #include "mojo/aura/window_tree_host_mojo_delegate.h" |
13 #include "mojo/public/c/system/main.h" | 13 #include "mojo/public/c/system/main.h" |
14 #include "mojo/public/cpp/application/application_connection.h" | 14 #include "mojo/public/cpp/application/application_connection.h" |
15 #include "mojo/public/cpp/application/application_delegate.h" | 15 #include "mojo/public/cpp/application/application_delegate.h" |
| 16 #include "mojo/public/cpp/application/application_impl.h" |
16 #include "mojo/public/cpp/application/application_runner_chromium.h" | 17 #include "mojo/public/cpp/application/application_runner_chromium.h" |
17 #include "mojo/public/cpp/system/core.h" | 18 #include "mojo/public/cpp/system/core.h" |
18 #include "mojo/services/public/cpp/view_manager/view.h" | 19 #include "mojo/services/public/cpp/view_manager/view.h" |
19 #include "mojo/services/public/cpp/view_manager/view_manager.h" | 20 #include "mojo/services/public/cpp/view_manager/view_manager.h" |
20 #include "mojo/services/public/cpp/view_manager/view_manager_client_factory.h" | 21 #include "mojo/services/public/cpp/view_manager/view_manager_client_factory.h" |
21 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" | 22 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" |
22 #include "mojo/services/public/interfaces/native_viewport/native_viewport.mojom.
h" | 23 #include "mojo/services/public/interfaces/native_viewport/native_viewport.mojom.
h" |
23 #include "ui/aura/client/default_capture_client.h" | 24 #include "ui/aura/client/default_capture_client.h" |
24 #include "ui/aura/client/window_tree_client.h" | 25 #include "ui/aura/client/window_tree_client.h" |
25 #include "ui/aura/env.h" | 26 #include "ui/aura/env.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 aura::Window* window_; | 103 aura::Window* window_; |
103 scoped_ptr<aura::client::DefaultCaptureClient> capture_client_; | 104 scoped_ptr<aura::client::DefaultCaptureClient> capture_client_; |
104 | 105 |
105 DISALLOW_COPY_AND_ASSIGN(DemoWindowTreeClient); | 106 DISALLOW_COPY_AND_ASSIGN(DemoWindowTreeClient); |
106 }; | 107 }; |
107 | 108 |
108 class AuraDemo : public ApplicationDelegate, | 109 class AuraDemo : public ApplicationDelegate, |
109 public WindowTreeHostMojoDelegate, | 110 public WindowTreeHostMojoDelegate, |
110 public ViewManagerDelegate { | 111 public ViewManagerDelegate { |
111 public: | 112 public: |
112 AuraDemo() | 113 AuraDemo() : window1_(NULL), window2_(NULL), window21_(NULL) {} |
113 : window1_(NULL), | |
114 window2_(NULL), | |
115 window21_(NULL), | |
116 view_manager_client_factory_(this) {} | |
117 virtual ~AuraDemo() {} | 114 virtual ~AuraDemo() {} |
118 | 115 |
119 private: | 116 private: |
120 // Overridden from ViewManagerDelegate: | 117 // Overridden from ViewManagerDelegate: |
121 virtual void OnEmbed(ViewManager* view_manager, | 118 virtual void OnEmbed(ViewManager* view_manager, |
122 View* root, | 119 View* root, |
123 ServiceProviderImpl* exported_services, | 120 ServiceProviderImpl* exported_services, |
124 scoped_ptr<ServiceProvider> imported_services) OVERRIDE { | 121 scoped_ptr<ServiceProvider> imported_services) OVERRIDE { |
125 // TODO(beng): this function could be called multiple times! | 122 // TODO(beng): this function could be called multiple times! |
126 root_ = root; | 123 root_ = root; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 ViewManager* view_manager) OVERRIDE { | 155 ViewManager* view_manager) OVERRIDE { |
159 base::MessageLoop::current()->Quit(); | 156 base::MessageLoop::current()->Quit(); |
160 } | 157 } |
161 | 158 |
162 // WindowTreeHostMojoDelegate: | 159 // WindowTreeHostMojoDelegate: |
163 virtual void CompositorContentsChanged(const SkBitmap& bitmap) OVERRIDE { | 160 virtual void CompositorContentsChanged(const SkBitmap& bitmap) OVERRIDE { |
164 root_->SetContents(bitmap); | 161 root_->SetContents(bitmap); |
165 } | 162 } |
166 | 163 |
167 virtual void Initialize(ApplicationImpl* app) MOJO_OVERRIDE { | 164 virtual void Initialize(ApplicationImpl* app) MOJO_OVERRIDE { |
| 165 view_manager_client_factory_.reset( |
| 166 new ViewManagerClientFactory(app->shell(), this)); |
168 aura::Env::CreateInstance(true); | 167 aura::Env::CreateInstance(true); |
169 context_factory_.reset(new ContextFactoryMojo); | 168 context_factory_.reset(new ContextFactoryMojo); |
170 aura::Env::GetInstance()->set_context_factory(context_factory_.get()); | 169 aura::Env::GetInstance()->set_context_factory(context_factory_.get()); |
171 screen_.reset(ScreenMojo::Create()); | 170 screen_.reset(ScreenMojo::Create()); |
172 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); | 171 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); |
173 } | 172 } |
174 | 173 |
175 virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) | 174 virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) |
176 MOJO_OVERRIDE { | 175 MOJO_OVERRIDE { |
177 connection->AddService(&view_manager_client_factory_); | 176 connection->AddService(view_manager_client_factory_.get()); |
178 return true; | 177 return true; |
179 } | 178 } |
180 | 179 |
181 scoped_ptr<DemoWindowTreeClient> window_tree_client_; | 180 scoped_ptr<DemoWindowTreeClient> window_tree_client_; |
182 | 181 |
183 scoped_ptr<ui::ContextFactory> context_factory_; | 182 scoped_ptr<ui::ContextFactory> context_factory_; |
184 | 183 |
185 scoped_ptr<ScreenMojo> screen_; | 184 scoped_ptr<ScreenMojo> screen_; |
186 | 185 |
187 scoped_ptr<DemoWindowDelegate> delegate1_; | 186 scoped_ptr<DemoWindowDelegate> delegate1_; |
188 scoped_ptr<DemoWindowDelegate> delegate2_; | 187 scoped_ptr<DemoWindowDelegate> delegate2_; |
189 scoped_ptr<DemoWindowDelegate> delegate21_; | 188 scoped_ptr<DemoWindowDelegate> delegate21_; |
190 | 189 |
191 aura::Window* window1_; | 190 aura::Window* window1_; |
192 aura::Window* window2_; | 191 aura::Window* window2_; |
193 aura::Window* window21_; | 192 aura::Window* window21_; |
194 | 193 |
195 View* root_; | 194 View* root_; |
196 | 195 |
197 ViewManagerClientFactory view_manager_client_factory_; | 196 scoped_ptr<ViewManagerClientFactory> view_manager_client_factory_; |
198 | 197 |
199 scoped_ptr<aura::WindowTreeHost> window_tree_host_; | 198 scoped_ptr<aura::WindowTreeHost> window_tree_host_; |
200 | 199 |
201 DISALLOW_COPY_AND_ASSIGN(AuraDemo); | 200 DISALLOW_COPY_AND_ASSIGN(AuraDemo); |
202 }; | 201 }; |
203 | 202 |
204 } // namespace examples | 203 } // namespace examples |
205 } // namespace mojo | 204 } // namespace mojo |
206 | 205 |
207 MojoResult MojoMain(MojoHandle shell_handle) { | 206 MojoResult MojoMain(MojoHandle shell_handle) { |
208 mojo::ApplicationRunnerChromium runner(new mojo::examples::AuraDemo); | 207 mojo::ApplicationRunnerChromium runner(new mojo::examples::AuraDemo); |
209 return runner.Run(shell_handle); | 208 return runner.Run(shell_handle); |
210 } | 209 } |
OLD | NEW |