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 }; | |
sky
2014/09/22 22:20:00
nit: DISALLOW_...
| |
28 | |
29 ViewManagerContext::ViewManagerContext(ApplicationImpl* application_impl) | |
30 : state_(new InternalState(application_impl)) {} | |
31 ViewManagerContext::~ViewManagerContext() {} | |
32 | |
33 void ViewManagerContext::Embed(const String& url) { | |
34 scoped_ptr<ServiceProviderImpl> spi(new ServiceProviderImpl); | |
35 Embed(url, spi.Pass()); | |
36 } | |
37 | |
38 scoped_ptr<ServiceProvider> ViewManagerContext::Embed( | |
39 const String& url, | |
40 scoped_ptr<ServiceProviderImpl> exported_services) { | |
41 scoped_ptr<ServiceProvider> imported_services; | |
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_->init_service()->Embed(url, sp.Pass(), base::Bind(&ConnectCallback)); | |
50 return imported_services.Pass(); | |
51 } | |
52 | |
53 } // namespace mojo | |
OLD | NEW |