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, |
| 70 URLLoaderPtr url_loader) OVERRIDE { |
70 if (manager_) { | 71 if (manager_) { |
71 manager_->LoadWithContentHandler(requested_url_, | 72 manager_->LoadWithContentHandler(requested_url_, |
72 requestor_url_, | 73 requestor_url_, |
73 content_handler_url, | 74 content_handler_url, |
74 content.Pass(), | 75 url_response.Pass(), |
| 76 url_loader.Pass(), |
75 service_provider_.Pass()); | 77 service_provider_.Pass()); |
76 } | 78 } |
77 } | 79 } |
78 | 80 |
79 base::WeakPtr<ApplicationManager> manager_; | 81 base::WeakPtr<ApplicationManager> manager_; |
80 GURL requested_url_; | 82 GURL requested_url_; |
81 GURL requestor_url_; | 83 GURL requestor_url_; |
82 ServiceProviderPtr service_provider_; | 84 ServiceProviderPtr service_provider_; |
83 }; | 85 }; |
84 | 86 |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 *shell_handle = pipe.handle0.Pass(); | 227 *shell_handle = pipe.handle0.Pass(); |
226 } | 228 } |
227 | 229 |
228 ConnectToClient(shell_impl, url, requestor_url, service_provider.Pass()); | 230 ConnectToClient(shell_impl, url, requestor_url, service_provider.Pass()); |
229 } | 231 } |
230 | 232 |
231 void ApplicationManager::LoadWithContentHandler( | 233 void ApplicationManager::LoadWithContentHandler( |
232 const GURL& content_url, | 234 const GURL& content_url, |
233 const GURL& requestor_url, | 235 const GURL& requestor_url, |
234 const GURL& content_handler_url, | 236 const GURL& content_handler_url, |
235 URLResponsePtr content, | 237 URLResponsePtr url_response, |
| 238 URLLoaderPtr url_loader, |
236 ServiceProviderPtr service_provider) { | 239 ServiceProviderPtr service_provider) { |
237 ContentHandlerConnection* connection = NULL; | 240 ContentHandlerConnection* connection = NULL; |
238 URLToContentHandlerMap::iterator iter = | 241 URLToContentHandlerMap::iterator iter = |
239 url_to_content_handler_.find(content_handler_url); | 242 url_to_content_handler_.find(content_handler_url); |
240 if (iter != url_to_content_handler_.end()) { | 243 if (iter != url_to_content_handler_.end()) { |
241 connection = iter->second; | 244 connection = iter->second; |
242 } else { | 245 } else { |
243 connection = new ContentHandlerConnection(this, content_handler_url); | 246 connection = new ContentHandlerConnection(this, content_handler_url); |
244 url_to_content_handler_[content_handler_url] = connection; | 247 url_to_content_handler_[content_handler_url] = connection; |
245 } | 248 } |
| 249 |
| 250 InterfaceRequest<ServiceProvider> spir; |
| 251 spir.Bind(service_provider.PassMessagePipe()); |
| 252 |
| 253 ContentSourcePtr content_source(ContentSource::New()); |
| 254 content_source->response = url_response.Pass(); |
| 255 content_source->loader = url_loader.Pass(); |
| 256 |
246 connection->content_handler->OnConnect( | 257 connection->content_handler->OnConnect( |
247 content_url.spec(), content.Pass(), service_provider.Pass()); | 258 content_url.spec(), content_source.Pass(), spir.Pass()); |
248 } | 259 } |
249 | 260 |
250 void ApplicationManager::SetLoaderForURL(scoped_ptr<ApplicationLoader> loader, | 261 void ApplicationManager::SetLoaderForURL(scoped_ptr<ApplicationLoader> loader, |
251 const GURL& url) { | 262 const GURL& url) { |
252 URLToLoaderMap::iterator it = url_to_loader_.find(url); | 263 URLToLoaderMap::iterator it = url_to_loader_.find(url); |
253 if (it != url_to_loader_.end()) | 264 if (it != url_to_loader_.end()) |
254 delete it->second; | 265 delete it->second; |
255 url_to_loader_[url] = loader.release(); | 266 url_to_loader_[url] = loader.release(); |
256 } | 267 } |
257 | 268 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 StubServiceProvider* stub_sp = new StubServiceProvider; | 310 StubServiceProvider* stub_sp = new StubServiceProvider; |
300 ServiceProviderPtr spp; | 311 ServiceProviderPtr spp; |
301 BindToProxy(stub_sp, &spp); | 312 BindToProxy(stub_sp, &spp); |
302 ConnectToApplication(application_url, GURL(), spp.Pass()); | 313 ConnectToApplication(application_url, GURL(), spp.Pass()); |
303 MessagePipe pipe; | 314 MessagePipe pipe; |
304 stub_sp->GetRemoteServiceProvider()->ConnectToService(interface_name, | 315 stub_sp->GetRemoteServiceProvider()->ConnectToService(interface_name, |
305 pipe.handle1.Pass()); | 316 pipe.handle1.Pass()); |
306 return pipe.handle0.Pass(); | 317 return pipe.handle0.Pass(); |
307 } | 318 } |
308 } // namespace mojo | 319 } // namespace mojo |
OLD | NEW |