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/basictypes.h"
7 #include "mojo/public/c/system/main.h"
8 #include "mojo/public/cpp/application/application_delegate.h"
9 #include "mojo/public/cpp/application/application_impl.h"
10 #include "mojo/public/cpp/application/application_runner_chromium.h"
11 #include "mojo/public/interfaces/application/service_provider.mojom.h"
12 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h"
17 // ViewManagerInit is responsible for establishing the initial connection to
18 // the view manager. When established it loads |mojo_aura_demo|.
19 class ViewManagerInit
: public ApplicationDelegate
{
22 virtual ~ViewManagerInit() {}
24 virtual void Initialize(ApplicationImpl
* app
) MOJO_OVERRIDE
{
25 app
->ConnectToService("mojo:mojo_view_manager", &view_manager_init_
);
26 ServiceProviderPtr sp
;
27 view_manager_init_
->Embed("mojo:mojo_aura_demo", sp
.Pass(),
28 base::Bind(&ViewManagerInit::DidConnect
,
29 base::Unretained(this)));
33 void DidConnect(bool result
) {
35 VLOG(1) << "ViewManagerInit::DidConnection result=" << result
;
38 ViewManagerInitServicePtr view_manager_init_
;
40 DISALLOW_COPY_AND_ASSIGN(ViewManagerInit
);
43 } // namespace examples
46 MojoResult
MojoMain(MojoHandle shell_handle
) {
47 mojo::ApplicationRunnerChromium
runner(new mojo::examples::ViewManagerInit
);
48 return runner
.Run(shell_handle
);