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 "mojo/application_manager/application_manager.h" | 5 #include "mojo/application_manager/application_manager.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 if (manager_) { | 59 if (manager_) { |
60 manager_->RegisterLoadedApplication(requested_url_, | 60 manager_->RegisterLoadedApplication(requested_url_, |
61 requestor_url_, | 61 requestor_url_, |
62 service_provider_.Pass(), | 62 service_provider_.Pass(), |
63 &shell_handle); | 63 &shell_handle); |
64 } | 64 } |
65 return shell_handle.Pass(); | 65 return shell_handle.Pass(); |
66 } | 66 } |
67 | 67 |
68 virtual void LoadWithContentHandler(const GURL& content_handler_url, | 68 virtual void LoadWithContentHandler(const GURL& content_handler_url, |
69 URLResponsePtr content) OVERRIDE { | 69 URLResponsePtr url_response) OVERRIDE { |
70 if (manager_) { | 70 if (manager_) { |
71 manager_->LoadWithContentHandler(requested_url_, | 71 manager_->LoadWithContentHandler(requested_url_, |
72 requestor_url_, | 72 requestor_url_, |
73 content_handler_url, | 73 content_handler_url, |
74 content.Pass(), | 74 url_response.Pass(), |
75 service_provider_.Pass()); | 75 service_provider_.Pass()); |
76 } | 76 } |
77 } | 77 } |
78 | 78 |
79 base::WeakPtr<ApplicationManager> manager_; | 79 base::WeakPtr<ApplicationManager> manager_; |
80 GURL requested_url_; | 80 GURL requested_url_; |
81 GURL requestor_url_; | 81 GURL requestor_url_; |
82 ServiceProviderPtr service_provider_; | 82 ServiceProviderPtr service_provider_; |
83 }; | 83 }; |
84 | 84 |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 *shell_handle = pipe.handle0.Pass(); | 225 *shell_handle = pipe.handle0.Pass(); |
226 } | 226 } |
227 | 227 |
228 ConnectToClient(shell_impl, url, requestor_url, service_provider.Pass()); | 228 ConnectToClient(shell_impl, url, requestor_url, service_provider.Pass()); |
229 } | 229 } |
230 | 230 |
231 void ApplicationManager::LoadWithContentHandler( | 231 void ApplicationManager::LoadWithContentHandler( |
232 const GURL& content_url, | 232 const GURL& content_url, |
233 const GURL& requestor_url, | 233 const GURL& requestor_url, |
234 const GURL& content_handler_url, | 234 const GURL& content_handler_url, |
235 URLResponsePtr content, | 235 URLResponsePtr url_response, |
236 ServiceProviderPtr service_provider) { | 236 ServiceProviderPtr service_provider) { |
237 ContentHandlerConnection* connection = NULL; | 237 ContentHandlerConnection* connection = NULL; |
238 URLToContentHandlerMap::iterator iter = | 238 URLToContentHandlerMap::iterator iter = |
239 url_to_content_handler_.find(content_handler_url); | 239 url_to_content_handler_.find(content_handler_url); |
240 if (iter != url_to_content_handler_.end()) { | 240 if (iter != url_to_content_handler_.end()) { |
241 connection = iter->second; | 241 connection = iter->second; |
242 } else { | 242 } else { |
243 connection = new ContentHandlerConnection(this, content_handler_url); | 243 connection = new ContentHandlerConnection(this, content_handler_url); |
244 url_to_content_handler_[content_handler_url] = connection; | 244 url_to_content_handler_[content_handler_url] = connection; |
245 } | 245 } |
| 246 |
| 247 InterfaceRequest<ServiceProvider> spir; |
| 248 spir.Bind(service_provider.PassMessagePipe()); |
246 connection->content_handler->OnConnect( | 249 connection->content_handler->OnConnect( |
247 content_url.spec(), content.Pass(), service_provider.Pass()); | 250 content_url.spec(), url_response.Pass(), spir.Pass()); |
248 } | 251 } |
249 | 252 |
250 void ApplicationManager::SetLoaderForURL(scoped_ptr<ApplicationLoader> loader, | 253 void ApplicationManager::SetLoaderForURL(scoped_ptr<ApplicationLoader> loader, |
251 const GURL& url) { | 254 const GURL& url) { |
252 URLToLoaderMap::iterator it = url_to_loader_.find(url); | 255 URLToLoaderMap::iterator it = url_to_loader_.find(url); |
253 if (it != url_to_loader_.end()) | 256 if (it != url_to_loader_.end()) |
254 delete it->second; | 257 delete it->second; |
255 url_to_loader_[url] = loader.release(); | 258 url_to_loader_[url] = loader.release(); |
256 } | 259 } |
257 | 260 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 StubServiceProvider* stub_sp = new StubServiceProvider; | 302 StubServiceProvider* stub_sp = new StubServiceProvider; |
300 ServiceProviderPtr spp; | 303 ServiceProviderPtr spp; |
301 BindToProxy(stub_sp, &spp); | 304 BindToProxy(stub_sp, &spp); |
302 ConnectToApplication(application_url, GURL(), spp.Pass()); | 305 ConnectToApplication(application_url, GURL(), spp.Pass()); |
303 MessagePipe pipe; | 306 MessagePipe pipe; |
304 stub_sp->GetRemoteServiceProvider()->ConnectToService(interface_name, | 307 stub_sp->GetRemoteServiceProvider()->ConnectToService(interface_name, |
305 pipe.handle1.Pass()); | 308 pipe.handle1.Pass()); |
306 return pipe.handle0.Pass(); | 309 return pipe.handle0.Pass(); |
307 } | 310 } |
308 } // namespace mojo | 311 } // namespace mojo |
OLD | NEW |