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 "shell/application_manager/application_manager.h" | 5 #include "shell/application_manager/application_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 std::vector<std::string> result(v1); | 37 std::vector<std::string> result(v1); |
38 result.insert(result.end(), v1.begin(), v1.end()); | 38 result.insert(result.end(), v1.begin(), v1.end()); |
39 return result; | 39 return result; |
40 } | 40 } |
41 | 41 |
42 } // namespace | 42 } // namespace |
43 | 43 |
44 ApplicationManager::Delegate::~Delegate() { | 44 ApplicationManager::Delegate::~Delegate() { |
45 } | 45 } |
46 | 46 |
47 void ApplicationManager::Delegate::OnApplicationError(const GURL& url) { | |
48 LOG(ERROR) << "Communication error with application: " << url.spec(); | |
49 } | |
50 | |
51 GURL ApplicationManager::Delegate::ResolveURL(const GURL& url) { | 47 GURL ApplicationManager::Delegate::ResolveURL(const GURL& url) { |
52 return url; | 48 return url; |
53 } | 49 } |
54 | 50 |
55 GURL ApplicationManager::Delegate::ResolveMappings(const GURL& url) { | 51 GURL ApplicationManager::Delegate::ResolveMappings(const GURL& url) { |
56 return url; | 52 return url; |
57 } | 53 } |
58 | 54 |
59 class ApplicationManager::ContentHandlerConnection : public ErrorHandler { | 55 class ApplicationManager::ContentHandlerConnection : public ErrorHandler { |
60 public: | 56 public: |
61 ContentHandlerConnection(ApplicationManager* manager, | 57 ContentHandlerConnection(ApplicationManager* manager, |
62 const GURL& content_handler_url) | 58 const GURL& content_handler_url) |
63 : manager_(manager), content_handler_url_(content_handler_url) { | 59 : manager_(manager), content_handler_url_(content_handler_url) { |
64 ServiceProviderPtr services; | 60 ServiceProviderPtr services; |
65 manager->ConnectToApplication(content_handler_url, GURL(), | 61 manager->ConnectToApplication(content_handler_url, GURL(), |
66 GetProxy(&services), nullptr); | 62 GetProxy(&services), nullptr, |
| 63 base::Closure()); |
67 MessagePipe pipe; | 64 MessagePipe pipe; |
68 content_handler_.Bind(pipe.handle0.Pass()); | 65 content_handler_.Bind(pipe.handle0.Pass()); |
69 services->ConnectToService(ContentHandler::Name_, pipe.handle1.Pass()); | 66 services->ConnectToService(ContentHandler::Name_, pipe.handle1.Pass()); |
70 content_handler_.set_error_handler(this); | 67 content_handler_.set_error_handler(this); |
71 } | 68 } |
72 | 69 |
73 ContentHandler* content_handler() { return content_handler_.get(); } | 70 ContentHandler* content_handler() { return content_handler_.get(); } |
74 | 71 |
75 GURL content_handler_url() { return content_handler_url_; } | 72 GURL content_handler_url() { return content_handler_url_; } |
76 | 73 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 } | 111 } |
115 | 112 |
116 void ApplicationManager::TerminateShellConnections() { | 113 void ApplicationManager::TerminateShellConnections() { |
117 STLDeleteValues(&identity_to_shell_impl_); | 114 STLDeleteValues(&identity_to_shell_impl_); |
118 } | 115 } |
119 | 116 |
120 void ApplicationManager::ConnectToApplication( | 117 void ApplicationManager::ConnectToApplication( |
121 const GURL& requested_url, | 118 const GURL& requested_url, |
122 const GURL& requestor_url, | 119 const GURL& requestor_url, |
123 InterfaceRequest<ServiceProvider> services, | 120 InterfaceRequest<ServiceProvider> services, |
124 ServiceProviderPtr exposed_services) { | 121 ServiceProviderPtr exposed_services, |
125 ConnectToApplicationWithParameters(requested_url, requestor_url, | 122 const base::Closure& on_application_end) { |
126 services.Pass(), exposed_services.Pass(), | 123 ConnectToApplicationWithParameters( |
127 std::vector<std::string>()); | 124 requested_url, requestor_url, services.Pass(), exposed_services.Pass(), |
| 125 on_application_end, std::vector<std::string>()); |
128 } | 126 } |
129 | 127 |
130 void ApplicationManager::ConnectToApplicationWithParameters( | 128 void ApplicationManager::ConnectToApplicationWithParameters( |
131 const GURL& requested_url, | 129 const GURL& requested_url, |
132 const GURL& requestor_url, | 130 const GURL& requestor_url, |
133 InterfaceRequest<ServiceProvider> services, | 131 InterfaceRequest<ServiceProvider> services, |
134 ServiceProviderPtr exposed_services, | 132 ServiceProviderPtr exposed_services, |
| 133 const base::Closure& on_application_end, |
135 const std::vector<std::string>& parameters) { | 134 const std::vector<std::string>& parameters) { |
136 DCHECK(requested_url.is_valid()); | 135 DCHECK(requested_url.is_valid()); |
137 | 136 |
138 // We check both the mapped and resolved urls for existing shell_impls because | 137 // We check both the mapped and resolved urls for existing shell_impls because |
139 // external applications can be registered for the unresolved mojo:foo urls. | 138 // external applications can be registered for the unresolved mojo:foo urls. |
140 | 139 |
141 GURL mapped_url = delegate_->ResolveMappings(requested_url); | 140 GURL mapped_url = delegate_->ResolveMappings(requested_url); |
142 if (ConnectToRunningApplication(mapped_url, requestor_url, &services, | 141 if (ConnectToRunningApplication(mapped_url, requestor_url, &services, |
143 &exposed_services)) { | 142 &exposed_services)) { |
144 return; | 143 return; |
145 } | 144 } |
146 | 145 |
147 GURL resolved_url = delegate_->ResolveURL(mapped_url); | 146 GURL resolved_url = delegate_->ResolveURL(mapped_url); |
148 if (ConnectToRunningApplication(resolved_url, requestor_url, &services, | 147 if (ConnectToRunningApplication(resolved_url, requestor_url, &services, |
149 &exposed_services)) { | 148 &exposed_services)) { |
150 return; | 149 return; |
151 } | 150 } |
152 | 151 |
153 if (ConnectToApplicationWithLoader(requested_url, mapped_url, requestor_url, | 152 if (ConnectToApplicationWithLoader(mapped_url, requestor_url, &services, |
154 &services, &exposed_services, parameters, | 153 &exposed_services, on_application_end, |
155 GetLoaderForURL(mapped_url))) { | 154 parameters, GetLoaderForURL(mapped_url))) { |
156 return; | 155 return; |
157 } | 156 } |
158 | 157 |
159 if (ConnectToApplicationWithLoader(requested_url, resolved_url, requestor_url, | 158 if (ConnectToApplicationWithLoader( |
160 &services, &exposed_services, parameters, | 159 resolved_url, requestor_url, &services, &exposed_services, |
161 GetLoaderForURL(resolved_url))) { | 160 on_application_end, parameters, GetLoaderForURL(resolved_url))) { |
162 return; | 161 return; |
163 } | 162 } |
164 | 163 |
165 if (ConnectToApplicationWithLoader(requested_url, resolved_url, requestor_url, | 164 if (ConnectToApplicationWithLoader(resolved_url, requestor_url, &services, |
166 &services, &exposed_services, parameters, | 165 &exposed_services, on_application_end, |
167 default_loader_.get())) { | 166 parameters, default_loader_.get())) { |
168 return; | 167 return; |
169 } | 168 } |
170 | 169 |
171 auto callback = base::Bind( | 170 auto callback = base::Bind( |
172 &ApplicationManager::HandleFetchCallback, weak_ptr_factory_.GetWeakPtr(), | 171 &ApplicationManager::HandleFetchCallback, weak_ptr_factory_.GetWeakPtr(), |
173 requested_url, requestor_url, base::Passed(services.Pass()), | 172 requestor_url, base::Passed(services.Pass()), |
174 base::Passed(exposed_services.Pass()), | 173 base::Passed(exposed_services.Pass()), on_application_end, |
175 Concatenate(parameters, GetArgsForURL(resolved_url))); | 174 Concatenate(parameters, GetArgsForURL(resolved_url))); |
176 | 175 |
177 if (resolved_url.SchemeIsFile()) { | 176 if (resolved_url.SchemeIsFile()) { |
178 new LocalFetcher(resolved_url, GetBaseURLAndQuery(resolved_url, nullptr), | 177 new LocalFetcher(resolved_url, GetBaseURLAndQuery(resolved_url, nullptr), |
179 base::Bind(callback, NativeRunner::DontDeleteAppPath)); | 178 base::Bind(callback, NativeRunner::DontDeleteAppPath)); |
180 return; | 179 return; |
181 } | 180 } |
182 | 181 |
183 if (!network_service_) | 182 if (!network_service_) |
184 ConnectToService(GURL("mojo:network_service"), &network_service_); | 183 ConnectToService(GURL("mojo:network_service"), &network_service_); |
(...skipping 17 matching lines...) Expand all Loading... |
202 ShellImpl* shell_impl = GetShellImpl(application_url); | 201 ShellImpl* shell_impl = GetShellImpl(application_url); |
203 if (!shell_impl) | 202 if (!shell_impl) |
204 return false; | 203 return false; |
205 | 204 |
206 ConnectToClient(shell_impl, resolved_url, requestor_url, services->Pass(), | 205 ConnectToClient(shell_impl, resolved_url, requestor_url, services->Pass(), |
207 exposed_services->Pass()); | 206 exposed_services->Pass()); |
208 return true; | 207 return true; |
209 } | 208 } |
210 | 209 |
211 bool ApplicationManager::ConnectToApplicationWithLoader( | 210 bool ApplicationManager::ConnectToApplicationWithLoader( |
212 const GURL& requested_url, | |
213 const GURL& resolved_url, | 211 const GURL& resolved_url, |
214 const GURL& requestor_url, | 212 const GURL& requestor_url, |
215 InterfaceRequest<ServiceProvider>* services, | 213 InterfaceRequest<ServiceProvider>* services, |
216 ServiceProviderPtr* exposed_services, | 214 ServiceProviderPtr* exposed_services, |
| 215 const base::Closure& on_application_end, |
217 const std::vector<std::string>& parameters, | 216 const std::vector<std::string>& parameters, |
218 ApplicationLoader* loader) { | 217 ApplicationLoader* loader) { |
219 if (!loader) | 218 if (!loader) |
220 return false; | 219 return false; |
221 | 220 |
222 loader->Load( | 221 loader->Load( |
223 resolved_url, | 222 resolved_url, |
224 RegisterShell(requested_url, resolved_url, requestor_url, | 223 RegisterShell(resolved_url, requestor_url, services->Pass(), |
225 services->Pass(), exposed_services->Pass(), parameters)); | 224 exposed_services->Pass(), on_application_end, parameters)); |
226 return true; | 225 return true; |
227 } | 226 } |
228 | 227 |
229 InterfaceRequest<Application> ApplicationManager::RegisterShell( | 228 InterfaceRequest<Application> ApplicationManager::RegisterShell( |
230 const GURL& original_url, | |
231 const GURL& resolved_url, | 229 const GURL& resolved_url, |
232 const GURL& requestor_url, | 230 const GURL& requestor_url, |
233 InterfaceRequest<ServiceProvider> services, | 231 InterfaceRequest<ServiceProvider> services, |
234 ServiceProviderPtr exposed_services, | 232 ServiceProviderPtr exposed_services, |
| 233 const base::Closure& on_application_end, |
235 const std::vector<std::string>& parameters) { | 234 const std::vector<std::string>& parameters) { |
236 Identity app_identity(resolved_url); | 235 Identity app_identity(resolved_url); |
237 | 236 |
238 ApplicationPtr application; | 237 ApplicationPtr application; |
239 InterfaceRequest<Application> application_request = GetProxy(&application); | 238 InterfaceRequest<Application> application_request = GetProxy(&application); |
240 ShellImpl* shell = | 239 ShellImpl* shell = |
241 new ShellImpl(application.Pass(), this, original_url, app_identity); | 240 new ShellImpl(application.Pass(), this, app_identity, on_application_end); |
242 identity_to_shell_impl_[app_identity] = shell; | 241 identity_to_shell_impl_[app_identity] = shell; |
243 shell->InitializeApplication(Array<String>::From( | 242 shell->InitializeApplication(Array<String>::From( |
244 Concatenate(parameters, GetArgsForURL(app_identity.url)))); | 243 Concatenate(parameters, GetArgsForURL(app_identity.url)))); |
245 ConnectToClient(shell, resolved_url, requestor_url, services.Pass(), | 244 ConnectToClient(shell, resolved_url, requestor_url, services.Pass(), |
246 exposed_services.Pass()); | 245 exposed_services.Pass()); |
247 return application_request.Pass(); | 246 return application_request.Pass(); |
248 } | 247 } |
249 | 248 |
250 ShellImpl* ApplicationManager::GetShellImpl(const GURL& url) { | 249 ShellImpl* ApplicationManager::GetShellImpl(const GURL& url) { |
251 const auto& shell_it = identity_to_shell_impl_.find(Identity(url)); | 250 const auto& shell_it = identity_to_shell_impl_.find(Identity(url)); |
252 if (shell_it != identity_to_shell_impl_.end()) | 251 if (shell_it != identity_to_shell_impl_.end()) |
253 return shell_it->second; | 252 return shell_it->second; |
254 return nullptr; | 253 return nullptr; |
255 } | 254 } |
256 | 255 |
257 void ApplicationManager::ConnectToClient( | 256 void ApplicationManager::ConnectToClient( |
258 ShellImpl* shell_impl, | 257 ShellImpl* shell_impl, |
259 const GURL& resolved_url, | 258 const GURL& resolved_url, |
260 const GURL& requestor_url, | 259 const GURL& requestor_url, |
261 InterfaceRequest<ServiceProvider> services, | 260 InterfaceRequest<ServiceProvider> services, |
262 ServiceProviderPtr exposed_services) { | 261 ServiceProviderPtr exposed_services) { |
263 shell_impl->ConnectToClient(resolved_url, requestor_url, services.Pass(), | 262 shell_impl->ConnectToClient(resolved_url, requestor_url, services.Pass(), |
264 exposed_services.Pass()); | 263 exposed_services.Pass()); |
265 } | 264 } |
266 | 265 |
267 void ApplicationManager::HandleFetchCallback( | 266 void ApplicationManager::HandleFetchCallback( |
268 const GURL& requested_url, | |
269 const GURL& requestor_url, | 267 const GURL& requestor_url, |
270 InterfaceRequest<ServiceProvider> services, | 268 InterfaceRequest<ServiceProvider> services, |
271 ServiceProviderPtr exposed_services, | 269 ServiceProviderPtr exposed_services, |
| 270 const base::Closure& on_application_end, |
272 const std::vector<std::string>& parameters, | 271 const std::vector<std::string>& parameters, |
273 NativeRunner::CleanupBehavior cleanup_behavior, | 272 NativeRunner::CleanupBehavior cleanup_behavior, |
274 scoped_ptr<Fetcher> fetcher) { | 273 scoped_ptr<Fetcher> fetcher) { |
275 if (!fetcher) { | 274 if (!fetcher) { |
276 // Network error. Drop |application_request| to tell requestor. | 275 // Network error. Drop |application_request| to tell requestor. |
277 return; | 276 return; |
278 } | 277 } |
279 | 278 |
280 GURL redirect_url = fetcher->GetRedirectURL(); | 279 GURL redirect_url = fetcher->GetRedirectURL(); |
281 if (!redirect_url.is_empty()) { | 280 if (!redirect_url.is_empty()) { |
282 // And around we go again... Whee! | 281 // And around we go again... Whee! |
283 ConnectToApplicationWithParameters(redirect_url, requestor_url, | 282 ConnectToApplicationWithParameters(redirect_url, requestor_url, |
284 services.Pass(), exposed_services.Pass(), | 283 services.Pass(), exposed_services.Pass(), |
285 parameters); | 284 on_application_end, parameters); |
286 return; | 285 return; |
287 } | 286 } |
288 | 287 |
289 // We already checked if the application was running before we fetched it, but | 288 // We already checked if the application was running before we fetched it, but |
290 // it might have started while the fetch was outstanding. We don't want to | 289 // it might have started while the fetch was outstanding. We don't want to |
291 // have two copies of the app running, so check again. | 290 // have two copies of the app running, so check again. |
292 // | 291 // |
293 // Also, it's possible the original URL was redirected to an app that is | 292 // Also, it's possible the original URL was redirected to an app that is |
294 // already running. | 293 // already running. |
295 if (ConnectToRunningApplication(fetcher->GetURL(), requestor_url, &services, | 294 if (ConnectToRunningApplication(fetcher->GetURL(), requestor_url, &services, |
296 &exposed_services)) { | 295 &exposed_services)) { |
297 return; | 296 return; |
298 } | 297 } |
299 | 298 |
300 InterfaceRequest<Application> request( | 299 InterfaceRequest<Application> request( |
301 RegisterShell(requested_url, fetcher->GetURL(), requestor_url, | 300 RegisterShell(fetcher->GetURL(), requestor_url, services.Pass(), |
302 services.Pass(), exposed_services.Pass(), parameters)); | 301 exposed_services.Pass(), on_application_end, parameters)); |
303 | 302 |
304 // If the response begins with a #!mojo <content-handler-url>, use it. | 303 // If the response begins with a #!mojo <content-handler-url>, use it. |
305 GURL content_handler_url; | 304 GURL content_handler_url; |
306 std::string shebang; | 305 std::string shebang; |
307 if (fetcher->PeekContentHandler(&shebang, &content_handler_url)) { | 306 if (fetcher->PeekContentHandler(&shebang, &content_handler_url)) { |
308 LoadWithContentHandler( | 307 LoadWithContentHandler( |
309 content_handler_url, request.Pass(), | 308 content_handler_url, request.Pass(), |
310 fetcher->AsURLResponse(blocking_pool_, | 309 fetcher->AsURLResponse(blocking_pool_, |
311 static_cast<int>(shebang.size()))); | 310 static_cast<int>(shebang.size()))); |
312 return; | 311 return; |
(...skipping 10 matching lines...) Expand all Loading... |
323 // application. That could either mean looking for the platform-specific dll | 322 // application. That could either mean looking for the platform-specific dll |
324 // header, or looking for some specific mojo signature prepended to the | 323 // header, or looking for some specific mojo signature prepended to the |
325 // library. | 324 // library. |
326 // TODO(vtl): (Maybe this should be done by the factory/runner?) | 325 // TODO(vtl): (Maybe this should be done by the factory/runner?) |
327 | 326 |
328 GURL base_resolved_url = GetBaseURLAndQuery(fetcher->GetURL(), nullptr); | 327 GURL base_resolved_url = GetBaseURLAndQuery(fetcher->GetURL(), nullptr); |
329 NativeRunnerFactory::Options options; | 328 NativeRunnerFactory::Options options; |
330 if (url_to_native_options_.find(base_resolved_url) != | 329 if (url_to_native_options_.find(base_resolved_url) != |
331 url_to_native_options_.end()) { | 330 url_to_native_options_.end()) { |
332 DVLOG(2) << "Applying stored native options to resolved URL " | 331 DVLOG(2) << "Applying stored native options to resolved URL " |
333 << fetcher->GetURL() << " (requested URL " << requested_url << ")"; | 332 << fetcher->GetURL(); |
334 options = url_to_native_options_[base_resolved_url]; | 333 options = url_to_native_options_[base_resolved_url]; |
335 } | 334 } |
336 | 335 |
337 fetcher->AsPath( | 336 fetcher->AsPath( |
338 blocking_pool_, | 337 blocking_pool_, |
339 base::Bind(&ApplicationManager::RunNativeApplication, | 338 base::Bind(&ApplicationManager::RunNativeApplication, |
340 weak_ptr_factory_.GetWeakPtr(), base::Passed(request.Pass()), | 339 weak_ptr_factory_.GetWeakPtr(), base::Passed(request.Pass()), |
341 options, cleanup_behavior, base::Passed(fetcher.Pass()))); | 340 options, cleanup_behavior, base::Passed(fetcher.Pass()))); |
342 } | 341 } |
343 | 342 |
(...skipping 26 matching lines...) Expand all Loading... |
370 const GURL& url, | 369 const GURL& url, |
371 const std::vector<std::string>& args, | 370 const std::vector<std::string>& args, |
372 ApplicationPtr application) { | 371 ApplicationPtr application) { |
373 const auto& args_it = url_to_args_.find(url); | 372 const auto& args_it = url_to_args_.find(url); |
374 if (args_it != url_to_args_.end()) { | 373 if (args_it != url_to_args_.end()) { |
375 LOG(WARNING) << "--args-for provided for external application " << url | 374 LOG(WARNING) << "--args-for provided for external application " << url |
376 << " <ignored>"; | 375 << " <ignored>"; |
377 } | 376 } |
378 Identity identity(url); | 377 Identity identity(url); |
379 ShellImpl* shell_impl = | 378 ShellImpl* shell_impl = |
380 new ShellImpl(application.Pass(), this, url, identity); | 379 new ShellImpl(application.Pass(), this, identity, base::Closure()); |
381 identity_to_shell_impl_[identity] = shell_impl; | 380 identity_to_shell_impl_[identity] = shell_impl; |
382 shell_impl->InitializeApplication(Array<String>::From(args)); | 381 shell_impl->InitializeApplication(Array<String>::From(args)); |
383 } | 382 } |
384 | 383 |
385 void ApplicationManager::RegisterContentHandler( | 384 void ApplicationManager::RegisterContentHandler( |
386 const std::string& mime_type, | 385 const std::string& mime_type, |
387 const GURL& content_handler_url) { | 386 const GURL& content_handler_url) { |
388 DCHECK(content_handler_url.is_valid()) | 387 DCHECK(content_handler_url.is_valid()) |
389 << "Content handler URL is invalid for mime type " << mime_type; | 388 << "Content handler URL is invalid for mime type " << mime_type; |
390 mime_type_to_url_[mime_type] = content_handler_url; | 389 mime_type_to_url_[mime_type] = content_handler_url; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 return url_it->second; | 459 return url_it->second; |
461 auto scheme_it = scheme_to_loader_.find(url.scheme()); | 460 auto scheme_it = scheme_to_loader_.find(url.scheme()); |
462 if (scheme_it != scheme_to_loader_.end()) | 461 if (scheme_it != scheme_to_loader_.end()) |
463 return scheme_it->second; | 462 return scheme_it->second; |
464 return nullptr; | 463 return nullptr; |
465 } | 464 } |
466 | 465 |
467 void ApplicationManager::OnShellImplError(ShellImpl* shell_impl) { | 466 void ApplicationManager::OnShellImplError(ShellImpl* shell_impl) { |
468 // Called from ~ShellImpl, so we do not need to call Destroy here. | 467 // Called from ~ShellImpl, so we do not need to call Destroy here. |
469 const Identity identity = shell_impl->identity(); | 468 const Identity identity = shell_impl->identity(); |
470 const GURL requested_url = shell_impl->requested_url(); | 469 base::Closure on_application_end = shell_impl->on_application_end(); |
471 // Remove the shell. | 470 // Remove the shell. |
472 auto it = identity_to_shell_impl_.find(identity); | 471 auto it = identity_to_shell_impl_.find(identity); |
473 DCHECK(it != identity_to_shell_impl_.end()); | 472 DCHECK(it != identity_to_shell_impl_.end()); |
474 delete it->second; | 473 delete it->second; |
475 identity_to_shell_impl_.erase(it); | 474 identity_to_shell_impl_.erase(it); |
476 delegate_->OnApplicationError(requested_url); | 475 if (!on_application_end.is_null()) |
| 476 on_application_end.Run(); |
477 } | 477 } |
478 | 478 |
479 void ApplicationManager::OnContentHandlerError( | 479 void ApplicationManager::OnContentHandlerError( |
480 ContentHandlerConnection* content_handler) { | 480 ContentHandlerConnection* content_handler) { |
481 // Remove the mapping to the content handler. | 481 // Remove the mapping to the content handler. |
482 auto it = | 482 auto it = |
483 url_to_content_handler_.find(content_handler->content_handler_url()); | 483 url_to_content_handler_.find(content_handler->content_handler_url()); |
484 DCHECK(it != url_to_content_handler_.end()); | 484 DCHECK(it != url_to_content_handler_.end()); |
485 delete it->second; | 485 delete it->second; |
486 url_to_content_handler_.erase(it); | 486 url_to_content_handler_.erase(it); |
487 } | 487 } |
488 | 488 |
489 ScopedMessagePipeHandle ApplicationManager::ConnectToServiceByName( | 489 ScopedMessagePipeHandle ApplicationManager::ConnectToServiceByName( |
490 const GURL& application_url, | 490 const GURL& application_url, |
491 const std::string& interface_name) { | 491 const std::string& interface_name) { |
492 ServiceProviderPtr services; | 492 ServiceProviderPtr services; |
493 ConnectToApplication(application_url, GURL(), GetProxy(&services), nullptr); | 493 ConnectToApplication(application_url, GURL(), GetProxy(&services), nullptr, |
| 494 base::Closure()); |
494 MessagePipe pipe; | 495 MessagePipe pipe; |
495 services->ConnectToService(interface_name, pipe.handle1.Pass()); | 496 services->ConnectToService(interface_name, pipe.handle1.Pass()); |
496 return pipe.handle0.Pass(); | 497 return pipe.handle0.Pass(); |
497 } | 498 } |
498 | 499 |
499 std::vector<std::string> ApplicationManager::GetArgsForURL(const GURL& url) { | 500 std::vector<std::string> ApplicationManager::GetArgsForURL(const GURL& url) { |
500 const auto& args_it = url_to_args_.find(url); | 501 const auto& args_it = url_to_args_.find(url); |
501 if (args_it != url_to_args_.end()) | 502 if (args_it != url_to_args_.end()) |
502 return args_it->second; | 503 return args_it->second; |
503 return std::vector<std::string>(); | 504 return std::vector<std::string>(); |
504 } | 505 } |
505 | 506 |
506 void ApplicationManager::CleanupRunner(NativeRunner* runner) { | 507 void ApplicationManager::CleanupRunner(NativeRunner* runner) { |
507 native_runners_.erase( | 508 native_runners_.erase( |
508 std::find(native_runners_.begin(), native_runners_.end(), runner)); | 509 std::find(native_runners_.begin(), native_runners_.end(), runner)); |
509 } | 510 } |
510 | 511 |
511 } // namespace shell | 512 } // namespace shell |
512 } // namespace mojo | 513 } // namespace mojo |
OLD | NEW |