| 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 "mojo/examples/surfaces_app/child_impl.h" | 5 #include "mojo/examples/surfaces_app/child_impl.h" |
| 6 #include "mojo/public/cpp/application/application_connection.h" | 6 #include "mojo/public/cpp/application/application_connection.h" |
| 7 #include "mojo/public/cpp/application/application_delegate.h" | 7 #include "mojo/public/cpp/application/application_delegate.h" |
| 8 #include "mojo/public/cpp/application/application_impl.h" | 8 #include "mojo/public/cpp/application/application_impl.h" |
| 9 #include "mojo/public/cpp/bindings/string.h" | 9 #include "mojo/public/cpp/bindings/string.h" |
| 10 | 10 |
| 11 namespace mojo { | 11 namespace mojo { |
| 12 namespace examples { | 12 namespace examples { |
| 13 | 13 |
| 14 class ChildApp : public ApplicationDelegate, public ChildImpl::Context { | 14 class ChildApp : public ApplicationDelegate, public InterfaceFactory<Child> { |
| 15 public: | 15 public: |
| 16 ChildApp() {} | 16 ChildApp() {} |
| 17 virtual ~ChildApp() {} | 17 virtual ~ChildApp() {} |
| 18 | 18 |
| 19 virtual void Initialize(ApplicationImpl* app) OVERRIDE { app_ = app; } | 19 virtual void Initialize(ApplicationImpl* app) OVERRIDE { |
| 20 surfaces_service_connection_ = |
| 21 app->ConnectToApplication("mojo:mojo_surfaces_service"); |
| 22 } |
| 20 | 23 |
| 21 // ApplicationDelegate implementation. | 24 // ApplicationDelegate implementation. |
| 22 virtual bool ConfigureIncomingConnection( | 25 virtual bool ConfigureIncomingConnection( |
| 23 ApplicationConnection* connection) OVERRIDE { | 26 ApplicationConnection* connection) OVERRIDE { |
| 24 connection->AddService<ChildImpl, ChildImpl::Context>(this); | 27 connection->AddService(this); |
| 25 return true; | 28 return true; |
| 26 } | 29 } |
| 27 | 30 |
| 28 // ChildImpl::Context implementation. | 31 // InterfaceFactory<Child> implementation. |
| 29 virtual ApplicationConnection* ShellConnection( | 32 virtual void Create(ApplicationConnection* connection, |
| 30 const mojo::String& application_url) OVERRIDE { | 33 InterfaceRequest<Child> request) OVERRIDE { |
| 31 return app_->ConnectToApplication(application_url); | 34 mojo::BindToRequest(new ChildImpl(surfaces_service_connection_), &request); |
| 32 } | 35 } |
| 33 | 36 |
| 34 private: | 37 private: |
| 35 ApplicationImpl* app_; | 38 ApplicationConnection* surfaces_service_connection_; |
| 36 | 39 |
| 37 DISALLOW_COPY_AND_ASSIGN(ChildApp); | 40 DISALLOW_COPY_AND_ASSIGN(ChildApp); |
| 38 }; | 41 }; |
| 39 | 42 |
| 40 } // namespace examples | 43 } // namespace examples |
| 41 | 44 |
| 42 // static | 45 // static |
| 43 ApplicationDelegate* ApplicationDelegate::Create() { | 46 ApplicationDelegate* ApplicationDelegate::Create() { |
| 44 return new examples::ChildApp(); | 47 return new examples::ChildApp(); |
| 45 } | 48 } |
| 46 | 49 |
| 47 } // namespace mojo | 50 } // namespace mojo |
| OLD | NEW |