Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / mojo / examples / aura_demo / view_manager_init.cc
blobf9a6149e75b1fd078aa249e5ac0ad47fcd798a7e
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"
6 #include "base/bind.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"
14 namespace mojo {
15 namespace examples {
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 {
20 public:
21 ViewManagerInit() {}
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)));
32 private:
33 void DidConnect(bool result) {
34 DCHECK(result);
35 VLOG(1) << "ViewManagerInit::DidConnection result=" << result;
38 ViewManagerInitServicePtr view_manager_init_;
40 DISALLOW_COPY_AND_ASSIGN(ViewManagerInit);
43 } // namespace examples
44 } // namespace mojo
46 MojoResult MojoMain(MojoHandle shell_handle) {
47 mojo::ApplicationRunnerChromium runner(new mojo::examples::ViewManagerInit);
48 return runner.Run(shell_handle);