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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "mojo/public/cpp/application/application_delegate.h" | 6 #include "mojo/public/cpp/application/application_delegate.h" |
7 #include "mojo/public/cpp/application/application_impl.h" | 7 #include "mojo/public/cpp/application/application_impl.h" |
| 8 #include "mojo/public/cpp/application/service_provider_impl.h" |
| 9 #include "mojo/public/interfaces/application/service_provider.mojom.h" |
8 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h" | 10 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h" |
9 | 11 |
10 namespace examples { | 12 namespace examples { |
11 namespace { | 13 namespace { |
12 void ConnectCallback(bool success) {} | 14 void ConnectCallback(bool success) {} |
13 } // namespace | 15 } // namespace |
14 | 16 |
15 // This application starts the view manager, embeds the window manager and then | 17 // This application starts the view manager, embeds the window manager and then |
16 // starts another app (wm_flow_app) which also connects to the view manager and | 18 // starts another app (wm_flow_app) which also connects to the view manager and |
17 // asks to be embedded without context. | 19 // asks to be embedded without context. |
18 class WMFlowInit : public mojo::ApplicationDelegate { | 20 class WMFlowInit : public mojo::ApplicationDelegate { |
19 public: | 21 public: |
20 WMFlowInit() {} | 22 WMFlowInit() {} |
21 virtual ~WMFlowInit() {} | 23 virtual ~WMFlowInit() {} |
22 | 24 |
23 private: | 25 private: |
24 // Overridden from Application: | 26 // Overridden from Application: |
25 virtual void Initialize(mojo::ApplicationImpl* app) MOJO_OVERRIDE { | 27 virtual void Initialize(mojo::ApplicationImpl* app) MOJO_OVERRIDE { |
26 app->ConnectToService("mojo:mojo_view_manager", &view_manager_init_); | 28 app->ConnectToService("mojo:mojo_view_manager", &view_manager_init_); |
27 view_manager_init_->Embed("mojo:mojo_wm_flow_wm", | 29 mojo::ServiceProviderPtr sp; |
| 30 mojo::BindToProxy(new mojo::ServiceProviderImpl, &sp); |
| 31 view_manager_init_->Embed("mojo:mojo_wm_flow_wm", sp.Pass(), |
28 base::Bind(&ConnectCallback)); | 32 base::Bind(&ConnectCallback)); |
29 app->ConnectToApplication("mojo:mojo_wm_flow_app"); | 33 app->ConnectToApplication("mojo:mojo_wm_flow_app"); |
30 } | 34 } |
31 | 35 |
32 void OnConnect(bool success) {} | 36 void OnConnect(bool success) {} |
33 | 37 |
34 mojo::ViewManagerInitServicePtr view_manager_init_; | 38 mojo::ViewManagerInitServicePtr view_manager_init_; |
35 | 39 |
36 DISALLOW_COPY_AND_ASSIGN(WMFlowInit); | 40 DISALLOW_COPY_AND_ASSIGN(WMFlowInit); |
37 }; | 41 }; |
38 | 42 |
39 } // namespace examples | 43 } // namespace examples |
40 | 44 |
41 namespace mojo { | 45 namespace mojo { |
42 | 46 |
43 // static | 47 // static |
44 ApplicationDelegate* ApplicationDelegate::Create() { | 48 ApplicationDelegate* ApplicationDelegate::Create() { |
45 return new examples::WMFlowInit; | 49 return new examples::WMFlowInit; |
46 } | 50 } |
47 | 51 |
48 } // namespace | 52 } // namespace |
OLD | NEW |