| 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 "services/shell/shell.h" | 5 #include "services/shell/shell.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 namespace { | 33 namespace { |
| 34 | 34 |
| 35 const char kCatalogName[] = "mojo:catalog"; | 35 const char kCatalogName[] = "mojo:catalog"; |
| 36 const char kShellName[] = "mojo:shell"; | 36 const char kShellName[] = "mojo:shell"; |
| 37 const char kCapabilityClass_UserID[] = "shell:user_id"; | 37 const char kCapabilityClass_UserID[] = "shell:user_id"; |
| 38 const char kCapabilityClass_ClientProcess[] = "shell:client_process"; | 38 const char kCapabilityClass_ClientProcess[] = "shell:client_process"; |
| 39 const char kCapabilityClass_InstanceName[] = "shell:instance_name"; | 39 const char kCapabilityClass_InstanceName[] = "shell:instance_name"; |
| 40 const char kCapabilityClass_AllUsers[] = "shell:all_users"; | 40 const char kCapabilityClass_AllUsers[] = "shell:all_users"; |
| 41 const char kCapabilityClass_ExplicitClass[] = "shell:explicit_class"; | 41 const char kCapabilityClass_ExplicitClass[] = "shell:explicit_class"; |
| 42 | 42 |
| 43 void EmptyResolverCallback(mojom::ResolveResultPtr result) {} | |
| 44 | |
| 45 } // namespace | 43 } // namespace |
| 46 | 44 |
| 47 Identity CreateShellIdentity() { | 45 Identity CreateShellIdentity() { |
| 48 return Identity(kShellName, mojom::kRootUserID); | 46 return Identity(kShellName, mojom::kRootUserID); |
| 49 } | 47 } |
| 50 | 48 |
| 51 Identity CreateCatalogIdentity() { | 49 Identity CreateCatalogIdentity() { |
| 52 return Identity(kCatalogName, mojom::kRootUserID); | 50 return Identity(kCatalogName, mojom::kRootUserID); |
| 53 } | 51 } |
| 54 | 52 |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 } | 522 } |
| 525 } | 523 } |
| 526 DCHECK(instance); | 524 DCHECK(instance); |
| 527 return instance->AcceptConnection(connection); | 525 return instance->AcceptConnection(connection); |
| 528 } | 526 } |
| 529 | 527 |
| 530 //////////////////////////////////////////////////////////////////////////////// | 528 //////////////////////////////////////////////////////////////////////////////// |
| 531 // Shell, private: | 529 // Shell, private: |
| 532 | 530 |
| 533 void Shell::InitCatalog(mojom::ShellClientPtr catalog) { | 531 void Shell::InitCatalog(mojom::ShellClientPtr catalog) { |
| 532 // TODO(beng): It'd be great to build this from the manifest, however there's |
| 533 // a bit of a chicken-and-egg problem. |
| 534 CapabilitySpec spec; |
| 535 Interfaces interfaces; |
| 536 interfaces.insert("filesystem::Directory"); |
| 537 spec.provided["app"] = interfaces; |
| 534 Instance* instance = CreateInstance(CreateShellIdentity(), | 538 Instance* instance = CreateInstance(CreateShellIdentity(), |
| 535 CreateCatalogIdentity(), | 539 CreateCatalogIdentity(), |
| 536 CapabilitySpec()); | 540 spec); |
| 537 singletons_.insert(kCatalogName); | 541 singletons_.insert(kCatalogName); |
| 538 instance->StartWithClient(std::move(catalog)); | 542 instance->StartWithClient(std::move(catalog)); |
| 539 | |
| 540 // TODO(beng): this doesn't work anymore. | |
| 541 // Seed the catalog with manifest info for the shell & catalog. | |
| 542 mojom::ShellResolverPtr resolver; | |
| 543 shell_connection_->connector()->ConnectToInterface(kCatalogName, &resolver); | |
| 544 resolver->ResolveMojoName(kCatalogName, base::Bind(&EmptyResolverCallback)); | |
| 545 resolver->ResolveMojoName(kShellName, base::Bind(&EmptyResolverCallback)); | |
| 546 } | 543 } |
| 547 | 544 |
| 548 mojom::ShellResolver* Shell::GetResolver(const Identity& identity) { | 545 mojom::ShellResolver* Shell::GetResolver(const Identity& identity) { |
| 549 auto iter = identity_to_resolver_.find(identity); | 546 auto iter = identity_to_resolver_.find(identity); |
| 550 if (iter != identity_to_resolver_.end()) | 547 if (iter != identity_to_resolver_.end()) |
| 551 return iter->second.get(); | 548 return iter->second.get(); |
| 552 | 549 |
| 553 mojom::ShellResolverPtr resolver_ptr; | 550 mojom::ShellResolverPtr resolver_ptr; |
| 554 ConnectToInterface(this, identity, CreateCatalogIdentity(), &resolver_ptr); | 551 ConnectToInterface(this, identity, CreateCatalogIdentity(), &resolver_ptr); |
| 555 mojom::ShellResolver* resolver = resolver_ptr.get(); | 552 mojom::ShellResolver* resolver = resolver_ptr.get(); |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 780 void Shell::CleanupRunner(NativeRunner* runner) { | 777 void Shell::CleanupRunner(NativeRunner* runner) { |
| 781 for (auto it = native_runners_.begin(); it != native_runners_.end(); ++it) { | 778 for (auto it = native_runners_.begin(); it != native_runners_.end(); ++it) { |
| 782 if (it->get() == runner) { | 779 if (it->get() == runner) { |
| 783 native_runners_.erase(it); | 780 native_runners_.erase(it); |
| 784 return; | 781 return; |
| 785 } | 782 } |
| 786 } | 783 } |
| 787 } | 784 } |
| 788 | 785 |
| 789 } // namespace shell | 786 } // namespace shell |
| OLD | NEW |