Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / mojo / examples / wm_flow / init / init.cc
blob3aa595fa9438434bb47dbf076e24bbb483d65aa0
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.
5 #include "base/bind.h"
6 #include "mojo/public/c/system/main.h"
7 #include "mojo/public/cpp/application/application_delegate.h"
8 #include "mojo/public/cpp/application/application_impl.h"
9 #include "mojo/public/cpp/application/application_runner_chromium.h"
10 #include "mojo/public/cpp/application/service_provider_impl.h"
11 #include "mojo/public/interfaces/application/service_provider.mojom.h"
12 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h"
14 namespace examples {
15 namespace {
16 void ConnectCallback(bool success) {}
17 } // namespace
19 // This application starts the view manager, embeds the window manager and then
20 // starts another app (wm_flow_app) which also connects to the view manager and
21 // asks to be embedded without context.
22 class WMFlowInit : public mojo::ApplicationDelegate {
23 public:
24 WMFlowInit() {}
25 virtual ~WMFlowInit() {}
27 private:
28 // Overridden from Application:
29 virtual void Initialize(mojo::ApplicationImpl* app) MOJO_OVERRIDE {
30 app->ConnectToService("mojo:mojo_view_manager", &view_manager_init_);
31 mojo::ServiceProviderPtr sp;
32 mojo::BindToProxy(new mojo::ServiceProviderImpl, &sp);
33 view_manager_init_->Embed("mojo:mojo_wm_flow_wm", sp.Pass(),
34 base::Bind(&ConnectCallback));
35 app->ConnectToApplication("mojo:mojo_wm_flow_app");
38 void OnConnect(bool success) {}
40 mojo::ViewManagerInitServicePtr view_manager_init_;
42 DISALLOW_COPY_AND_ASSIGN(WMFlowInit);
45 } // namespace examples
47 MojoResult MojoMain(MojoHandle shell_handle) {
48 mojo::ApplicationRunnerChromium runner(new examples::WMFlowInit);
49 return runner.Run(shell_handle);