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