| 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/cpp/application/application_connection.h" |
| 13 #include "mojo/public/cpp/application/application_delegate.h" | 14 #include "mojo/public/cpp/application/application_delegate.h" |
| 14 #include "mojo/public/cpp/system/core.h" | 15 #include "mojo/public/cpp/system/core.h" |
| 15 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h" | 16 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h" |
| 16 #include "mojo/services/public/cpp/view_manager/node.h" | 17 #include "mojo/services/public/cpp/view_manager/node.h" |
| 17 #include "mojo/services/public/cpp/view_manager/view.h" | 18 #include "mojo/services/public/cpp/view_manager/view.h" |
| 18 #include "mojo/services/public/cpp/view_manager/view_manager.h" | 19 #include "mojo/services/public/cpp/view_manager/view_manager.h" |
| 20 #include "mojo/services/public/cpp/view_manager/view_manager_client_factory.h" |
| 19 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" | 21 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" |
| 20 #include "mojo/services/public/interfaces/native_viewport/native_viewport.mojom.
h" | 22 #include "mojo/services/public/interfaces/native_viewport/native_viewport.mojom.
h" |
| 21 #include "ui/aura/client/default_capture_client.h" | 23 #include "ui/aura/client/default_capture_client.h" |
| 22 #include "ui/aura/client/window_tree_client.h" | 24 #include "ui/aura/client/window_tree_client.h" |
| 23 #include "ui/aura/env.h" | 25 #include "ui/aura/env.h" |
| 24 #include "ui/aura/window.h" | 26 #include "ui/aura/window.h" |
| 25 #include "ui/aura/window_delegate.h" | 27 #include "ui/aura/window_delegate.h" |
| 26 #include "ui/base/hit_test.h" | 28 #include "ui/base/hit_test.h" |
| 27 #include "ui/gfx/canvas.h" | 29 #include "ui/gfx/canvas.h" |
| 28 #include "ui/gfx/codec/png_codec.h" | 30 #include "ui/gfx/codec/png_codec.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 }; | 106 }; |
| 105 | 107 |
| 106 class AuraDemo : public ApplicationDelegate, | 108 class AuraDemo : public ApplicationDelegate, |
| 107 public WindowTreeHostMojoDelegate, | 109 public WindowTreeHostMojoDelegate, |
| 108 public view_manager::ViewManagerDelegate { | 110 public view_manager::ViewManagerDelegate { |
| 109 public: | 111 public: |
| 110 AuraDemo() | 112 AuraDemo() |
| 111 : window1_(NULL), | 113 : window1_(NULL), |
| 112 window2_(NULL), | 114 window2_(NULL), |
| 113 window21_(NULL), | 115 window21_(NULL), |
| 114 view_(NULL) { | 116 view_(NULL), |
| 115 } | 117 view_manager_client_factory_(this) {} |
| 116 virtual ~AuraDemo() {} | 118 virtual ~AuraDemo() {} |
| 117 | 119 |
| 118 private: | 120 private: |
| 119 // Overridden from view_manager::ViewManagerDelegate: | 121 // Overridden from view_manager::ViewManagerDelegate: |
| 120 virtual void OnRootAdded(view_manager::ViewManager* view_manager, | 122 virtual void OnRootAdded(view_manager::ViewManager* view_manager, |
| 121 view_manager::Node* root) OVERRIDE { | 123 view_manager::Node* root) OVERRIDE { |
| 122 // TODO(beng): this function could be called multiple times! | 124 // TODO(beng): this function could be called multiple times! |
| 123 view_ = view_manager::View::Create(view_manager); | 125 view_ = view_manager::View::Create(view_manager); |
| 124 root->SetActiveView(view_); | 126 root->SetActiveView(view_); |
| 125 | 127 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 virtual void Initialize(ApplicationImpl* app) MOJO_OVERRIDE { | 167 virtual void Initialize(ApplicationImpl* app) MOJO_OVERRIDE { |
| 166 aura::Env::CreateInstance(true); | 168 aura::Env::CreateInstance(true); |
| 167 context_factory_.reset(new ContextFactoryMojo); | 169 context_factory_.reset(new ContextFactoryMojo); |
| 168 aura::Env::GetInstance()->set_context_factory(context_factory_.get()); | 170 aura::Env::GetInstance()->set_context_factory(context_factory_.get()); |
| 169 screen_.reset(ScreenMojo::Create()); | 171 screen_.reset(ScreenMojo::Create()); |
| 170 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); | 172 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); |
| 171 } | 173 } |
| 172 | 174 |
| 173 virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) | 175 virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) |
| 174 MOJO_OVERRIDE { | 176 MOJO_OVERRIDE { |
| 175 view_manager::ViewManager::ConfigureIncomingConnection(connection, this); | 177 connection->AddService(&view_manager_client_factory_); |
| 176 return true; | 178 return true; |
| 177 } | 179 } |
| 178 | 180 |
| 179 scoped_ptr<DemoWindowTreeClient> window_tree_client_; | 181 scoped_ptr<DemoWindowTreeClient> window_tree_client_; |
| 180 | 182 |
| 181 scoped_ptr<ui::ContextFactory> context_factory_; | 183 scoped_ptr<ui::ContextFactory> context_factory_; |
| 182 | 184 |
| 183 scoped_ptr<ScreenMojo> screen_; | 185 scoped_ptr<ScreenMojo> screen_; |
| 184 | 186 |
| 185 scoped_ptr<DemoWindowDelegate> delegate1_; | 187 scoped_ptr<DemoWindowDelegate> delegate1_; |
| 186 scoped_ptr<DemoWindowDelegate> delegate2_; | 188 scoped_ptr<DemoWindowDelegate> delegate2_; |
| 187 scoped_ptr<DemoWindowDelegate> delegate21_; | 189 scoped_ptr<DemoWindowDelegate> delegate21_; |
| 188 | 190 |
| 189 aura::Window* window1_; | 191 aura::Window* window1_; |
| 190 aura::Window* window2_; | 192 aura::Window* window2_; |
| 191 aura::Window* window21_; | 193 aura::Window* window21_; |
| 192 | 194 |
| 193 view_manager::View* view_; | 195 view_manager::View* view_; |
| 194 | 196 |
| 197 view_manager::ViewManagerClientFactory view_manager_client_factory_; |
| 198 |
| 195 scoped_ptr<aura::WindowTreeHost> window_tree_host_; | 199 scoped_ptr<aura::WindowTreeHost> window_tree_host_; |
| 196 | 200 |
| 197 DISALLOW_COPY_AND_ASSIGN(AuraDemo); | 201 DISALLOW_COPY_AND_ASSIGN(AuraDemo); |
| 198 }; | 202 }; |
| 199 | 203 |
| 200 } // namespace examples | 204 } // namespace examples |
| 201 | 205 |
| 202 // static | 206 // static |
| 203 ApplicationDelegate* ApplicationDelegate::Create() { | 207 ApplicationDelegate* ApplicationDelegate::Create() { |
| 204 return new examples::AuraDemo(); | 208 return new examples::AuraDemo(); |
| 205 } | 209 } |
| 206 | 210 |
| 207 } // namespace mojo | 211 } // namespace mojo |
| OLD | NEW |