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 "view_manager/public/cpp/view_manager_context.h" | 5 #include "view_manager/public/cpp/view_manager_context.h" |
6 | 6 |
7 #include "mojo/public/cpp/application/application_impl.h" | 7 #include "mojo/public/cpp/application/application_impl.h" |
8 #include "mojo/public/cpp/bindings/interface_request.h" | 8 #include "mojo/public/cpp/bindings/interface_request.h" |
9 #include "window_manager/public/interfaces/window_manager.mojom.h" | 9 #include "window_manager/public/interfaces/window_manager.mojom.h" |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 WindowManagerPtr wm_; | 24 WindowManagerPtr wm_; |
25 | 25 |
26 MOJO_DISALLOW_COPY_AND_ASSIGN(InternalState); | 26 MOJO_DISALLOW_COPY_AND_ASSIGN(InternalState); |
27 }; | 27 }; |
28 | 28 |
29 ViewManagerContext::ViewManagerContext(ApplicationImpl* application_impl) | 29 ViewManagerContext::ViewManagerContext(ApplicationImpl* application_impl) |
30 : state_(new InternalState(application_impl)) {} | 30 : state_(new InternalState(application_impl)) {} |
31 ViewManagerContext::~ViewManagerContext() {} | 31 ViewManagerContext::~ViewManagerContext() {} |
32 | 32 |
33 void ViewManagerContext::Embed(const String& url) { | 33 void ViewManagerContext::Embed(const String& url) { |
34 scoped_ptr<ServiceProviderImpl> spi(new ServiceProviderImpl); | 34 Embed(url, nullptr, nullptr); |
35 Embed(url, spi.Pass()); | |
36 } | 35 } |
37 | 36 |
38 scoped_ptr<ServiceProvider> ViewManagerContext::Embed( | 37 void ViewManagerContext::Embed(const String& url, |
39 const String& url, | 38 InterfaceRequest<ServiceProvider> services, |
40 scoped_ptr<ServiceProviderImpl> exported_services) { | 39 ServiceProviderPtr exposed_services) { |
41 scoped_ptr<ServiceProvider> imported_services; | 40 state_->wm()->Embed(url, services.Pass(), exposed_services.Pass()); |
42 // BindToProxy() takes ownership of |exported_services|. | |
43 ServiceProviderImpl* registry = exported_services.release(); | |
44 ServiceProviderPtr sp; | |
45 if (registry) { | |
46 BindToProxy(registry, &sp); | |
47 imported_services.reset(registry->CreateRemoteServiceProvider()); | |
48 } | |
49 state_->wm()->Embed(url, MakeRequest<ServiceProvider>(sp.PassMessagePipe())); | |
50 return imported_services.Pass(); | |
51 } | 41 } |
52 | 42 |
53 } // namespace mojo | 43 } // namespace mojo |
OLD | NEW |