| 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 16 matching lines...) Expand all Loading... |
| 27 #include "services/shell/public/interfaces/connector.mojom.h" | 27 #include "services/shell/public/interfaces/connector.mojom.h" |
| 28 #include "services/shell/public/interfaces/shell.mojom.h" | 28 #include "services/shell/public/interfaces/shell.mojom.h" |
| 29 #include "services/shell/public/interfaces/shell_client.mojom.h" | 29 #include "services/shell/public/interfaces/shell_client.mojom.h" |
| 30 | 30 |
| 31 namespace shell { | 31 namespace shell { |
| 32 | 32 |
| 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[] = "user_id"; |
| 38 const char kCapabilityClass_ClientProcess[] = "shell:client_process"; | 38 const char kCapabilityClass_ClientProcess[] = "client_process"; |
| 39 const char kCapabilityClass_InstanceName[] = "shell:instance_name"; | 39 const char kCapabilityClass_InstanceName[] = "instance_name"; |
| 40 const char kCapabilityClass_AllUsers[] = "shell:all_users"; | 40 const char kCapabilityClass_AllUsers[] = "all_users"; |
| 41 const char kCapabilityClass_ExplicitClass[] = "shell:explicit_class"; | |
| 42 | 41 |
| 43 void EmptyResolverCallback(mojom::ResolveResultPtr result) {} | 42 void EmptyResolverCallback(mojom::ResolveResultPtr result) {} |
| 44 | 43 |
| 45 } // namespace | 44 } // namespace |
| 46 | 45 |
| 47 Identity CreateShellIdentity() { | 46 Identity CreateShellIdentity() { |
| 48 return Identity(kShellName, mojom::kRootUserID); | 47 return Identity(kShellName, mojom::kRootUserID); |
| 49 } | 48 } |
| 50 | 49 |
| 51 Identity CreateCatalogIdentity() { | 50 Identity CreateCatalogIdentity() { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 DCHECK(it != children_.end()); | 143 DCHECK(it != children_.end()); |
| 145 children_.erase(it); | 144 children_.erase(it); |
| 146 child->parent_ = nullptr; | 145 child->parent_ = nullptr; |
| 147 } | 146 } |
| 148 | 147 |
| 149 void ConnectToClient(std::unique_ptr<ConnectParams> params) { | 148 void ConnectToClient(std::unique_ptr<ConnectParams> params) { |
| 150 CHECK(shell_client_.is_bound()); | 149 CHECK(shell_client_.is_bound()); |
| 151 params->connect_callback().Run(mojom::ConnectResult::SUCCEEDED, | 150 params->connect_callback().Run(mojom::ConnectResult::SUCCEEDED, |
| 152 identity_.user_id(), id_); | 151 identity_.user_id(), id_); |
| 153 uint32_t source_id = mojom::kInvalidInstanceID; | 152 uint32_t source_id = mojom::kInvalidInstanceID; |
| 154 CapabilityRequest request; | 153 CapabilityRequest spec; |
| 155 request.interfaces.insert("*"); | 154 spec.interfaces.insert("*"); |
| 156 Instance* source = shell_->GetExistingInstance(params->source()); | 155 Instance* source = shell_->GetExistingInstance(params->source()); |
| 157 if (source) { | 156 if (source) { |
| 158 request = GenerateCapabilityRequestForConnection( | 157 spec = GenerateCapabilityRequestForConnection( |
| 159 source->capability_spec_, identity_, capability_spec_); | 158 source->capability_spec_, identity_, capability_spec_); |
| 160 source_id = source->id(); | 159 source_id = source->id(); |
| 161 } | 160 } |
| 162 | |
| 163 // The target has specified that sources must request one of its provided | |
| 164 // classes instead of specifying a wild-card for interfaces or interfaces | |
| 165 // directly. | |
| 166 if (HasClass(capability_spec_, kCapabilityClass_ExplicitClass) && | |
| 167 (request.classes.empty() || request.interfaces.count("*") != 0)) { | |
| 168 request.interfaces = Interfaces(); | |
| 169 } | |
| 170 | |
| 171 shell_client_->AcceptConnection( | 161 shell_client_->AcceptConnection( |
| 172 mojom::Identity::From(params->source()), source_id, | 162 mojom::Identity::From(params->source()), source_id, |
| 173 params->TakeRemoteInterfaces(), params->TakeLocalInterfaces(), | 163 params->TakeRemoteInterfaces(), params->TakeLocalInterfaces(), |
| 174 mojom::CapabilityRequest::From(request), params->target().name()); | 164 mojom::CapabilityRequest::From(spec), params->target().name()); |
| 175 } | 165 } |
| 176 | 166 |
| 177 void StartWithClient(mojom::ShellClientPtr client) { | 167 void StartWithClient(mojom::ShellClientPtr client) { |
| 178 CHECK(!shell_client_); | 168 CHECK(!shell_client_); |
| 179 shell_client_ = std::move(client); | 169 shell_client_ = std::move(client); |
| 180 shell_client_.set_connection_error_handler( | 170 shell_client_.set_connection_error_handler( |
| 181 base::Bind(&Instance::OnShellClientLost, base::Unretained(this), | 171 base::Bind(&Instance::OnShellClientLost, base::Unretained(this), |
| 182 shell_->GetWeakPtr())); | 172 shell_->GetWeakPtr())); |
| 183 shell_client_->Initialize(mojom::Identity::From(identity_), id_, | 173 shell_client_->Initialize(mojom::Identity::From(identity_), id_, |
| 184 base::Bind(&Instance::OnInitializeResponse, | 174 base::Bind(&Instance::OnInitializeResponse, |
| (...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 761 void Shell::CleanupRunner(NativeRunner* runner) { | 751 void Shell::CleanupRunner(NativeRunner* runner) { |
| 762 for (auto it = native_runners_.begin(); it != native_runners_.end(); ++it) { | 752 for (auto it = native_runners_.begin(); it != native_runners_.end(); ++it) { |
| 763 if (it->get() == runner) { | 753 if (it->get() == runner) { |
| 764 native_runners_.erase(it); | 754 native_runners_.erase(it); |
| 765 return; | 755 return; |
| 766 } | 756 } |
| 767 } | 757 } |
| 768 } | 758 } |
| 769 | 759 |
| 770 } // namespace shell | 760 } // namespace shell |
| OLD | NEW |