Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / mojo / examples / demo_launcher / demo_launcher.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 "base/basictypes.h"
6 #include "base/bind.h"
7 #include "base/run_loop.h"
8 #include "mojo/public/cpp/application/application_connection.h"
9 #include "mojo/public/cpp/application/application_delegate.h"
10 #include "mojo/public/cpp/application/application_impl.h"
11 #include "mojo/public/cpp/application/service_provider_impl.h"
12 #include "mojo/public/interfaces/application/service_provider.mojom.h"
13 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h"
14
15 namespace mojo {
16 namespace examples {
17
18 class DemoLauncher : public ApplicationDelegate {
19  public:
20   DemoLauncher() {}
21   virtual ~DemoLauncher() {}
22
23  private:
24   virtual void Initialize(ApplicationImpl* app) MOJO_OVERRIDE {
25     app->ConnectToService("mojo:mojo_view_manager", &view_manager_init_);
26   }
27
28   virtual bool ConfigureIncomingConnection(ApplicationConnection* connection)
29       MOJO_OVERRIDE {
30     ServiceProviderPtr sp;
31     BindToProxy(new ServiceProviderImpl, &sp);
32     view_manager_init_->Embed("mojo:mojo_window_manager", sp.Pass(),
33                               base::Bind(&DemoLauncher::OnConnect,
34                                          base::Unretained(this)));
35     return true;
36   }
37
38   void OnConnect(bool success) {}
39
40   ViewManagerInitServicePtr view_manager_init_;
41
42   DISALLOW_COPY_AND_ASSIGN(DemoLauncher);
43 };
44
45 }  // namespace examples
46
47 // static
48 ApplicationDelegate* ApplicationDelegate::Create() {
49   return new examples::DemoLauncher;
50 }
51
52 }  // namespace mojo