OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #include "mojo/services/public/cpp/view_manager/view_manager_context.h" |
| 6 |
| 7 #include "mojo/public/cpp/application/application_impl.h" |
| 8 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h" |
| 9 |
| 10 namespace mojo { |
| 11 class ApplicationImpl; |
| 12 |
| 13 void ConnectCallback(bool success) {} |
| 14 |
| 15 class ViewManagerContext::InternalState { |
| 16 public: |
| 17 InternalState(ApplicationImpl* application_impl) { |
| 18 application_impl->ConnectToService("mojo:mojo_view_manager", |
| 19 &init_service_); |
| 20 } |
| 21 ~InternalState() {} |
| 22 |
| 23 ViewManagerInitService* init_service() { return init_service_.get(); } |
| 24 |
| 25 private: |
| 26 ViewManagerInitServicePtr init_service_; |
| 27 |
| 28 MOJO_DISALLOW_COPY_AND_ASSIGN(InternalState); |
| 29 }; |
| 30 |
| 31 ViewManagerContext::ViewManagerContext(ApplicationImpl* application_impl) |
| 32 : state_(new InternalState(application_impl)) {} |
| 33 ViewManagerContext::~ViewManagerContext() {} |
| 34 |
| 35 void ViewManagerContext::Embed(const String& url) { |
| 36 scoped_ptr<ServiceProviderImpl> spi(new ServiceProviderImpl); |
| 37 Embed(url, spi.Pass()); |
| 38 } |
| 39 |
| 40 scoped_ptr<ServiceProvider> ViewManagerContext::Embed( |
| 41 const String& url, |
| 42 scoped_ptr<ServiceProviderImpl> exported_services) { |
| 43 scoped_ptr<ServiceProvider> imported_services; |
| 44 // BindToProxy() takes ownership of |exported_services|. |
| 45 ServiceProviderImpl* registry = exported_services.release(); |
| 46 ServiceProviderPtr sp; |
| 47 if (registry) { |
| 48 BindToProxy(registry, &sp); |
| 49 imported_services.reset(registry->CreateRemoteServiceProvider()); |
| 50 } |
| 51 state_->init_service()->Embed(url, sp.Pass(), base::Bind(&ConnectCallback)); |
| 52 return imported_services.Pass(); |
| 53 } |
| 54 |
| 55 } // namespace mojo |
OLD | NEW |