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