| 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 <map> | 5 #include <map> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "examples/bitmap_uploader/bitmap_uploader.h" | 10 #include "examples/bitmap_uploader/bitmap_uploader.h" |
| 11 #include "examples/wm_flow/app/embedder.mojom.h" | 11 #include "examples/wm_flow/app/embedder.mojom.h" |
| 12 #include "examples/wm_flow/embedded/embeddee.mojom.h" | 12 #include "examples/wm_flow/embedded/embeddee.mojom.h" |
| 13 #include "mojo/application/application_runner_chromium.h" | 13 #include "mojo/application/application_runner_chromium.h" |
| 14 #include "mojo/common/weak_binding_set.h" | 14 #include "mojo/common/weak_binding_set.h" |
| 15 #include "mojo/public/c/system/main.h" | 15 #include "mojo/public/c/system/main.h" |
| 16 #include "mojo/public/cpp/application/application_connection.h" | 16 #include "mojo/public/cpp/application/application_connection.h" |
| 17 #include "mojo/public/cpp/application/application_delegate.h" | 17 #include "mojo/public/cpp/application/application_delegate.h" |
| 18 #include "mojo/public/cpp/application/application_impl.h" | 18 #include "mojo/public/cpp/application/application_impl.h" |
| 19 #include "mojo/public/cpp/application/connect.h" | 19 #include "mojo/public/cpp/application/connect.h" |
| 20 #include "mojo/public/cpp/application/interface_factory_impl.h" | 20 #include "mojo/public/cpp/application/interface_factory_impl.h" |
| 21 #include "mojo/public/cpp/application/service_provider_impl.h" | 21 #include "mojo/public/cpp/application/service_provider_impl.h" |
| 22 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 22 #include "mojo/public/interfaces/application/service_provider.mojom.h" | 23 #include "mojo/public/interfaces/application/service_provider.mojom.h" |
| 23 #include "mojo/services/view_manager/public/cpp/view.h" | 24 #include "mojo/services/view_manager/public/cpp/view.h" |
| 24 #include "mojo/services/view_manager/public/cpp/view_manager.h" | 25 #include "mojo/services/view_manager/public/cpp/view_manager.h" |
| 25 #include "mojo/services/view_manager/public/cpp/view_manager_client_factory.h" | 26 #include "mojo/services/view_manager/public/cpp/view_manager_client_factory.h" |
| 26 #include "mojo/services/view_manager/public/cpp/view_manager_context.h" | 27 #include "mojo/services/view_manager/public/cpp/view_manager_context.h" |
| 27 #include "mojo/services/view_manager/public/cpp/view_manager_delegate.h" | 28 #include "mojo/services/view_manager/public/cpp/view_manager_delegate.h" |
| 28 #include "mojo/services/view_manager/public/cpp/view_observer.h" | 29 #include "mojo/services/view_manager/public/cpp/view_observer.h" |
| 29 #include "third_party/skia/include/core/SkColor.h" | 30 #include "third_party/skia/include/core/SkColor.h" |
| 30 #include "url/gurl.h" | 31 #include "url/gurl.h" |
| 31 | 32 |
| 32 namespace examples { | 33 namespace examples { |
| 33 namespace { | 34 namespace { |
| 34 | 35 |
| 35 const SkColor kColors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorYELLOW }; | 36 const SkColor kColors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorYELLOW }; |
| 36 | 37 |
| 37 class EmbedderImpl : public mojo::InterfaceImpl<Embedder> { | 38 class EmbedderImpl : public Embedder { |
| 38 public: | 39 public: |
| 39 EmbedderImpl() {} | 40 explicit EmbedderImpl(mojo::InterfaceRequest<Embedder> request) |
| 40 virtual ~EmbedderImpl() {} | 41 : binding_(this, request.Pass()) {} |
| 42 ~EmbedderImpl() override {} |
| 41 | 43 |
| 42 private: | 44 private: |
| 43 // Overridden from Embedder: | 45 // Overridden from Embedder: |
| 44 virtual void HelloWorld(const mojo::Callback<void()>& callback) override { | 46 void HelloWorld(const mojo::Callback<void()>& callback) override { |
| 45 callback.Run(); | 47 callback.Run(); |
| 46 } | 48 } |
| 47 | 49 |
| 50 mojo::StrongBinding<Embedder> binding_; |
| 48 DISALLOW_COPY_AND_ASSIGN(EmbedderImpl); | 51 DISALLOW_COPY_AND_ASSIGN(EmbedderImpl); |
| 49 }; | 52 }; |
| 50 | 53 |
| 51 class EmbedderImplProvider : public mojo::ServiceProvider { | 54 class EmbedderImplProvider : public mojo::ServiceProvider { |
| 52 public: | 55 public: |
| 53 EmbedderImplProvider() {} | 56 EmbedderImplProvider() {} |
| 54 ~EmbedderImplProvider() override {} | 57 ~EmbedderImplProvider() override {} |
| 55 | 58 |
| 56 void AddBinding(mojo::InterfaceRequest<mojo::ServiceProvider> request) { | 59 void AddBinding(mojo::InterfaceRequest<mojo::ServiceProvider> request) { |
| 57 embeddee_exposed_services_.AddBinding(this, request.Pass()); | 60 embeddee_exposed_services_.AddBinding(this, request.Pass()); |
| 58 } | 61 } |
| 59 | 62 |
| 60 private: | 63 private: |
| 61 // mojo::ServiceProvider implementation | 64 // mojo::ServiceProvider implementation |
| 62 void ConnectToService(const mojo::String& interface_name, | 65 void ConnectToService(const mojo::String& interface_name, |
| 63 mojo::ScopedMessagePipeHandle pipe_handle) override { | 66 mojo::ScopedMessagePipeHandle pipe_handle) override { |
| 64 if (interface_name != Embedder::Name_) | 67 if (interface_name != Embedder::Name_) |
| 65 return; | 68 return; |
| 66 auto request = mojo::MakeRequest<Embedder>(pipe_handle.Pass()); | 69 new EmbedderImpl(mojo::MakeRequest<Embedder>(pipe_handle.Pass())); |
| 67 mojo::BindToRequest(new EmbedderImpl, &request); | |
| 68 } | 70 } |
| 69 | 71 |
| 70 mojo::WeakBindingSet<mojo::ServiceProvider> embeddee_exposed_services_; | 72 mojo::WeakBindingSet<mojo::ServiceProvider> embeddee_exposed_services_; |
| 71 | 73 |
| 72 DISALLOW_COPY_AND_ASSIGN(EmbedderImplProvider); | 74 DISALLOW_COPY_AND_ASSIGN(EmbedderImplProvider); |
| 73 }; | 75 }; |
| 74 | 76 |
| 75 } // namespace | 77 } // namespace |
| 76 | 78 |
| 77 // This app starts its life via Connect() rather than by being embed, so it does | 79 // This app starts its life via Connect() rather than by being embed, so it does |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 | 187 |
| 186 DISALLOW_COPY_AND_ASSIGN(WMFlowApp); | 188 DISALLOW_COPY_AND_ASSIGN(WMFlowApp); |
| 187 }; | 189 }; |
| 188 | 190 |
| 189 } // namespace examples | 191 } // namespace examples |
| 190 | 192 |
| 191 MojoResult MojoMain(MojoHandle shell_handle) { | 193 MojoResult MojoMain(MojoHandle shell_handle) { |
| 192 mojo::ApplicationRunnerChromium runner(new examples::WMFlowApp); | 194 mojo::ApplicationRunnerChromium runner(new examples::WMFlowApp); |
| 193 return runner.Run(shell_handle); | 195 return runner.Run(shell_handle); |
| 194 } | 196 } |
| OLD | NEW |