| 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/shell/application_manager.h" | 5 #include "mojo/shell/application_manager.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 void ApplicationManager::OnShellClientFactoryLost(const Identity& which) { | 294 void ApplicationManager::OnShellClientFactoryLost(const Identity& which) { |
| 295 // Remove the mapping. | 295 // Remove the mapping. |
| 296 auto it = shell_client_factories_.find(which); | 296 auto it = shell_client_factories_.find(which); |
| 297 DCHECK(it != shell_client_factories_.end()); | 297 DCHECK(it != shell_client_factories_.end()); |
| 298 shell_client_factories_.erase(it); | 298 shell_client_factories_.erase(it); |
| 299 } | 299 } |
| 300 | 300 |
| 301 void ApplicationManager::OnGotResolvedURL( | 301 void ApplicationManager::OnGotResolvedURL( |
| 302 scoped_ptr<ConnectParams> params, | 302 scoped_ptr<ConnectParams> params, |
| 303 const String& resolved_url, | 303 const String& resolved_url, |
| 304 const String& qualifier, | 304 const String& resolved_qualifier, |
| 305 mojom::CapabilityFilterPtr base_filter, | 305 mojom::CapabilityFilterPtr base_filter, |
| 306 const String& file_url) { | 306 const String& file_url) { |
| 307 // It's possible that when this manifest request was issued, another one was | 307 // It's possible that when this manifest request was issued, another one was |
| 308 // already in-progress and completed by the time this one did, and so the | 308 // already in-progress and completed by the time this one did, and so the |
| 309 // requested application may already be running. | 309 // requested application may already be running. |
| 310 if (ConnectToExistingInstance(¶ms)) | 310 if (ConnectToExistingInstance(¶ms)) |
| 311 return; | 311 return; |
| 312 | 312 |
| 313 Identity source = params->source(), target = params->target(); | 313 Identity source = params->source(); |
| 314 CapabilityFilter filter = params->target().filter(); |
| 315 // TODO(beng): this clobbers the filter passed via Connect(). |
| 316 if (!base_filter.is_null()) |
| 317 filter = base_filter->filter.To<CapabilityFilter>(); |
| 318 Identity target(params->target().url(), params->target().qualifier(), filter); |
| 319 |
| 314 mojom::ShellClientRequest request; | 320 mojom::ShellClientRequest request; |
| 315 ApplicationInstance* instance = CreateInstance(params->target(), &request); | 321 ApplicationInstance* instance = CreateInstance(target, &request); |
| 316 instance->ConnectToClient(std::move(params)); | 322 instance->ConnectToClient(std::move(params)); |
| 317 | 323 |
| 318 if (LoadWithLoader(target, &request)) | 324 if (LoadWithLoader(target, &request)) |
| 319 return; | 325 return; |
| 320 | 326 |
| 321 CHECK(!file_url.is_null() && !base_filter.is_null()); | 327 CHECK(!file_url.is_null() && !base_filter.is_null()); |
| 322 | 328 |
| 323 GURL resolved_gurl = resolved_url.To<GURL>(); | 329 GURL resolved_gurl = resolved_url.To<GURL>(); |
| 324 if (target.url().spec() != resolved_url) { | 330 if (target.url().spec() != resolved_url) { |
| 325 // TODO(beng): this clobbers the CapabilityFilter passed via Connect(). | 331 // In cases where a package alias is resolved, we have to use the qualifier |
| 326 CapabilityFilter capability_filter = GetPermissiveCapabilityFilter(); | 332 // from the original request rather than for the package itself, which will |
| 327 if (!base_filter.is_null()) | 333 // always be the same. |
| 328 capability_filter = base_filter->filter.To<CapabilityFilter>(); | |
| 329 | |
| 330 CreateShellClient(source, | 334 CreateShellClient(source, |
| 331 Identity(resolved_gurl, qualifier, capability_filter), | 335 Identity(resolved_gurl, target.qualifier(), filter), |
| 332 target.url(), std::move(request)); | 336 target.url(), std::move(request)); |
| 333 } else { | 337 } else { |
| 334 bool start_sandboxed = false; | 338 bool start_sandboxed = false; |
| 335 base::FilePath path = util::UrlToFilePath(file_url.To<GURL>()); | 339 base::FilePath path = util::UrlToFilePath(file_url.To<GURL>()); |
| 336 scoped_ptr<NativeRunner> runner = native_runner_factory_->Create(path); | 340 scoped_ptr<NativeRunner> runner = native_runner_factory_->Create(path); |
| 337 runner->Start(path, start_sandboxed, std::move(request), | 341 runner->Start(path, start_sandboxed, std::move(request), |
| 338 base::Bind(&ApplicationManager::ApplicationPIDAvailable, | 342 base::Bind(&ApplicationManager::ApplicationPIDAvailable, |
| 339 weak_ptr_factory_.GetWeakPtr(), instance->id()), | 343 weak_ptr_factory_.GetWeakPtr(), instance->id()), |
| 340 base::Bind(&ApplicationManager::CleanupRunner, | 344 base::Bind(&ApplicationManager::CleanupRunner, |
| 341 weak_ptr_factory_.GetWeakPtr(), runner.get())); | 345 weak_ptr_factory_.GetWeakPtr(), runner.get())); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 info->qualifier = instance->identity().qualifier(); | 381 info->qualifier = instance->identity().qualifier(); |
| 378 if (instance->identity().url().spec() == "mojo://shell/") | 382 if (instance->identity().url().spec() == "mojo://shell/") |
| 379 info->pid = base::Process::Current().Pid(); | 383 info->pid = base::Process::Current().Pid(); |
| 380 else | 384 else |
| 381 info->pid = instance->pid(); | 385 info->pid = instance->pid(); |
| 382 return info; | 386 return info; |
| 383 } | 387 } |
| 384 | 388 |
| 385 } // namespace shell | 389 } // namespace shell |
| 386 } // namespace mojo | 390 } // namespace mojo |
| OLD | NEW |