| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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() |
| 113 : window1_(NULL), | 114 : window1_(NULL), |
| 114 window2_(NULL), | 115 window2_(NULL), |
| 115 window21_(NULL), | 116 window21_(NULL) {} |
| 116 view_manager_client_factory_(this) {} | |
| 117 virtual ~AuraDemo() {} | 117 virtual ~AuraDemo() {} |
| 118 | 118 |
| 119 private: | 119 private: |
| 120 // Overridden from ViewManagerDelegate: | 120 // Overridden from ViewManagerDelegate: |
| 121 virtual void OnEmbed(ViewManager* view_manager, | 121 virtual void OnEmbed(ViewManager* view_manager, |
| 122 View* root, | 122 View* root, |
| 123 ServiceProviderImpl* exported_services, | 123 ServiceProviderImpl* exported_services, |
| 124 scoped_ptr<ServiceProvider> imported_services) OVERRIDE { | 124 scoped_ptr<ServiceProvider> imported_services) OVERRIDE { |
| 125 // TODO(beng): this function could be called multiple times! | 125 // TODO(beng): this function could be called multiple times! |
| 126 root_ = root; | 126 root_ = root; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 ViewManager* view_manager) OVERRIDE { | 158 ViewManager* view_manager) OVERRIDE { |
| 159 base::MessageLoop::current()->Quit(); | 159 base::MessageLoop::current()->Quit(); |
| 160 } | 160 } |
| 161 | 161 |
| 162 // WindowTreeHostMojoDelegate: | 162 // WindowTreeHostMojoDelegate: |
| 163 virtual void CompositorContentsChanged(const SkBitmap& bitmap) OVERRIDE { | 163 virtual void CompositorContentsChanged(const SkBitmap& bitmap) OVERRIDE { |
| 164 root_->SetContents(bitmap); | 164 root_->SetContents(bitmap); |
| 165 } | 165 } |
| 166 | 166 |
| 167 virtual void Initialize(ApplicationImpl* app) MOJO_OVERRIDE { | 167 virtual void Initialize(ApplicationImpl* app) MOJO_OVERRIDE { |
| 168 view_manager_client_factory_.reset( |
| 169 new ViewManagerClientFactory(app->shell(), this)); |
| 168 aura::Env::CreateInstance(true); | 170 aura::Env::CreateInstance(true); |
| 169 context_factory_.reset(new ContextFactoryMojo); | 171 context_factory_.reset(new ContextFactoryMojo); |
| 170 aura::Env::GetInstance()->set_context_factory(context_factory_.get()); | 172 aura::Env::GetInstance()->set_context_factory(context_factory_.get()); |
| 171 screen_.reset(ScreenMojo::Create()); | 173 screen_.reset(ScreenMojo::Create()); |
| 172 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); | 174 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); |
| 173 } | 175 } |
| 174 | 176 |
| 175 virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) | 177 virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) |
| 176 MOJO_OVERRIDE { | 178 MOJO_OVERRIDE { |
| 177 connection->AddService(&view_manager_client_factory_); | 179 connection->AddService(view_manager_client_factory_.get()); |
| 178 return true; | 180 return true; |
| 179 } | 181 } |
| 180 | 182 |
| 181 scoped_ptr<DemoWindowTreeClient> window_tree_client_; | 183 scoped_ptr<DemoWindowTreeClient> window_tree_client_; |
| 182 | 184 |
| 183 scoped_ptr<ui::ContextFactory> context_factory_; | 185 scoped_ptr<ui::ContextFactory> context_factory_; |
| 184 | 186 |
| 185 scoped_ptr<ScreenMojo> screen_; | 187 scoped_ptr<ScreenMojo> screen_; |
| 186 | 188 |
| 187 scoped_ptr<DemoWindowDelegate> delegate1_; | 189 scoped_ptr<DemoWindowDelegate> delegate1_; |
| 188 scoped_ptr<DemoWindowDelegate> delegate2_; | 190 scoped_ptr<DemoWindowDelegate> delegate2_; |
| 189 scoped_ptr<DemoWindowDelegate> delegate21_; | 191 scoped_ptr<DemoWindowDelegate> delegate21_; |
| 190 | 192 |
| 191 aura::Window* window1_; | 193 aura::Window* window1_; |
| 192 aura::Window* window2_; | 194 aura::Window* window2_; |
| 193 aura::Window* window21_; | 195 aura::Window* window21_; |
| 194 | 196 |
| 195 View* root_; | 197 View* root_; |
| 196 | 198 |
| 197 ViewManagerClientFactory view_manager_client_factory_; | 199 scoped_ptr<ViewManagerClientFactory> view_manager_client_factory_; |
| 198 | 200 |
| 199 scoped_ptr<aura::WindowTreeHost> window_tree_host_; | 201 scoped_ptr<aura::WindowTreeHost> window_tree_host_; |
| 200 | 202 |
| 201 DISALLOW_COPY_AND_ASSIGN(AuraDemo); | 203 DISALLOW_COPY_AND_ASSIGN(AuraDemo); |
| 202 }; | 204 }; |
| 203 | 205 |
| 204 } // namespace examples | 206 } // namespace examples |
| 205 } // namespace mojo | 207 } // namespace mojo |
| 206 | 208 |
| 207 MojoResult MojoMain(MojoHandle shell_handle) { | 209 MojoResult MojoMain(MojoHandle shell_handle) { |
| 208 mojo::ApplicationRunnerChromium runner(new mojo::examples::AuraDemo); | 210 mojo::ApplicationRunnerChromium runner(new mojo::examples::AuraDemo); |
| 209 return runner.Run(shell_handle); | 211 return runner.Run(shell_handle); |
| 210 } | 212 } |
| OLD | NEW |