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/application/application_runner_chromium.h" | 6 #include "mojo/application/application_runner_chromium.h" |
7 #include "mojo/examples/wm_flow/app/embedder.mojom.h" | 7 #include "mojo/examples/wm_flow/app/embedder.mojom.h" |
8 #include "mojo/examples/wm_flow/embedded/embeddee.mojom.h" | 8 #include "mojo/examples/wm_flow/embedded/embeddee.mojom.h" |
9 #include "mojo/public/cpp/application/application_connection.h" | 9 #include "mojo/public/cpp/application/application_connection.h" |
10 #include "mojo/public/cpp/application/application_delegate.h" | 10 #include "mojo/public/cpp/application/application_delegate.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 } // namespace | 38 } // namespace |
39 | 39 |
40 class WMFlowEmbedded : public mojo::ApplicationDelegate, | 40 class WMFlowEmbedded : public mojo::ApplicationDelegate, |
41 public mojo::ViewManagerDelegate { | 41 public mojo::ViewManagerDelegate { |
42 public: | 42 public: |
43 WMFlowEmbedded() {} | 43 WMFlowEmbedded() {} |
44 virtual ~WMFlowEmbedded() {} | 44 virtual ~WMFlowEmbedded() {} |
45 | 45 |
46 private: | 46 private: |
47 // Overridden from Application: | 47 // Overridden from Application: |
48 virtual void Initialize(mojo::ApplicationImpl* app) MOJO_OVERRIDE { | 48 virtual void Initialize(mojo::ApplicationImpl* app) override { |
49 view_manager_client_factory_.reset( | 49 view_manager_client_factory_.reset( |
50 new mojo::ViewManagerClientFactory(app->shell(), this)); | 50 new mojo::ViewManagerClientFactory(app->shell(), this)); |
51 } | 51 } |
52 virtual bool ConfigureIncomingConnection( | 52 virtual bool ConfigureIncomingConnection( |
53 mojo::ApplicationConnection* connection) MOJO_OVERRIDE { | 53 mojo::ApplicationConnection* connection) override { |
54 connection->AddService(view_manager_client_factory_.get()); | 54 connection->AddService(view_manager_client_factory_.get()); |
55 return true; | 55 return true; |
56 } | 56 } |
57 | 57 |
58 // Overridden from mojo::ViewManagerDelegate: | 58 // Overridden from mojo::ViewManagerDelegate: |
59 virtual void OnEmbed( | 59 virtual void OnEmbed( |
60 mojo::ViewManager* view_manager, | 60 mojo::ViewManager* view_manager, |
61 mojo::View* root, | 61 mojo::View* root, |
62 mojo::ServiceProviderImpl* exported_services, | 62 mojo::ServiceProviderImpl* exported_services, |
63 scoped_ptr<mojo::ServiceProvider> imported_services) MOJO_OVERRIDE { | 63 scoped_ptr<mojo::ServiceProvider> imported_services) override { |
64 root->SetColor(SK_ColorMAGENTA); | 64 root->SetColor(SK_ColorMAGENTA); |
65 | 65 |
66 exported_services->AddService(&embeddee_factory_); | 66 exported_services->AddService(&embeddee_factory_); |
67 mojo::ConnectToService(imported_services.get(), &embedder_); | 67 mojo::ConnectToService(imported_services.get(), &embedder_); |
68 embedder_->HelloWorld(base::Bind(&WMFlowEmbedded::HelloWorldAck, | 68 embedder_->HelloWorld(base::Bind(&WMFlowEmbedded::HelloWorldAck, |
69 base::Unretained(this))); | 69 base::Unretained(this))); |
70 } | 70 } |
71 virtual void OnViewManagerDisconnected( | 71 virtual void OnViewManagerDisconnected( |
72 mojo::ViewManager* view_manager) MOJO_OVERRIDE {} | 72 mojo::ViewManager* view_manager) override {} |
73 | 73 |
74 void HelloWorldAck() { | 74 void HelloWorldAck() { |
75 printf("HelloWorld() ack'ed\n"); | 75 printf("HelloWorld() ack'ed\n"); |
76 } | 76 } |
77 | 77 |
78 scoped_ptr<mojo::ViewManagerClientFactory> view_manager_client_factory_; | 78 scoped_ptr<mojo::ViewManagerClientFactory> view_manager_client_factory_; |
79 EmbedderPtr embedder_; | 79 EmbedderPtr embedder_; |
80 mojo::InterfaceFactoryImpl<EmbeddeeImpl> embeddee_factory_; | 80 mojo::InterfaceFactoryImpl<EmbeddeeImpl> embeddee_factory_; |
81 | 81 |
82 DISALLOW_COPY_AND_ASSIGN(WMFlowEmbedded); | 82 DISALLOW_COPY_AND_ASSIGN(WMFlowEmbedded); |
83 }; | 83 }; |
84 | 84 |
85 } // namespace examples | 85 } // namespace examples |
86 | 86 |
87 MojoResult MojoMain(MojoHandle shell_handle) { | 87 MojoResult MojoMain(MojoHandle shell_handle) { |
88 mojo::ApplicationRunnerChromium runner(new examples::WMFlowEmbedded); | 88 mojo::ApplicationRunnerChromium runner(new examples::WMFlowEmbedded); |
89 return runner.Run(shell_handle); | 89 return runner.Run(shell_handle); |
90 } | 90 } |
91 | 91 |
OLD | NEW |