Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: mojo/shell/shell.cc

Issue 1775813002: Eliminate CapabilityFilter parameter from CreateInstance, instead reading it from the associated ma… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@41qual
Patch Set: . Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/shell.h" 5 #include "mojo/shell/shell.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 206
207 // InterfaceFactory<mojom::Shell>: 207 // InterfaceFactory<mojom::Shell>:
208 void Create(Connection* connection, 208 void Create(Connection* connection,
209 mojom::ShellRequest request) override { 209 mojom::ShellRequest request) override {
210 shell_bindings_.AddBinding(this, std::move(request)); 210 shell_bindings_.AddBinding(this, std::move(request));
211 } 211 }
212 212
213 // mojom::Shell implementation: 213 // mojom::Shell implementation:
214 void CreateInstance(mojom::ShellClientFactoryPtr factory, 214 void CreateInstance(mojom::ShellClientFactoryPtr factory,
215 mojom::IdentityPtr target, 215 mojom::IdentityPtr target,
216 mojom::CapabilityFilterPtr filter,
217 mojom::PIDReceiverRequest pid_receiver, 216 mojom::PIDReceiverRequest pid_receiver,
218 const CreateInstanceCallback& callback) override { 217 const CreateInstanceCallback& callback) override {
218 // We need to bounce through the package manager to load the
219 // CapabilityFilter.
220 std::string name = target->name;
221 shell_->shell_resolver_->ResolveMojoName(name, base::Bind(
222 &mojo::shell::Shell::Instance::OnResolvedNameForCreateInstance,
223 weak_factory_.GetWeakPtr(), base::Passed(std::move(factory)),
224 base::Passed(std::move(target)), base::Passed(std::move(pid_receiver)),
225 callback));
226 }
227 void AddInstanceListener(mojom::InstanceListenerPtr listener) override {
228 // TODO(beng): this should only track the instances matching this user, and
229 // root.
230 shell_->AddInstanceListener(std::move(listener));
231 }
232
233 void OnResolvedNameForCreateInstance(mojom::ShellClientFactoryPtr factory,
234 mojom::IdentityPtr target,
235 mojom::PIDReceiverRequest pid_receiver,
236 const CreateInstanceCallback& callback,
237 const String& resolved_name,
238 const String& resolved_instance,
239 mojom::CapabilityFilterPtr filter,
240 const String& file_url) {
219 if (!base::IsValidGUID(target->user_id)) 241 if (!base::IsValidGUID(target->user_id))
220 callback.Run(mojom::ConnectResult::INVALID_ARGUMENT); 242 callback.Run(mojom::ConnectResult::INVALID_ARGUMENT);
221 243
222 Identity target_id = target.To<Identity>(); 244 Identity target_id = target.To<Identity>();
223 245
224 // TODO(beng): perform checking on policy of whether this instance is 246 // TODO(beng): perform checking on policy of whether this instance is
225 // allowed to pass different user_ids. 247 // allowed to pass different user_ids.
226 if (target_id.user_id() == mojom::kInheritUserID) 248 if (target_id.user_id() == mojom::kInheritUserID)
227 target_id.set_user_id(identity_.user_id()); 249 target_id.set_user_id(identity_.user_id());
228 250
229 mojom::ShellClientRequest request; 251 mojom::ShellClientRequest request;
230 Instance* instance = shell_->CreateInstance( 252 Instance* instance = shell_->CreateInstance(
231 target_id, filter->filter.To<CapabilityFilter>(), &request); 253 target_id, filter->filter.To<CapabilityFilter>(), &request);
232 instance->pid_receiver_binding_.Bind(std::move(pid_receiver)); 254 instance->pid_receiver_binding_.Bind(std::move(pid_receiver));
233 instance->factory_ = std::move(factory); 255 instance->factory_ = std::move(factory);
234 instance->factory_->CreateShellClient(std::move(request), target->name); 256 instance->factory_->CreateShellClient(std::move(request), target->name);
235 callback.Run(mojom::ConnectResult::SUCCEEDED); 257 callback.Run(mojom::ConnectResult::SUCCEEDED);
236 // We don't call ConnectToClient() here since the instance was created 258 // We don't call ConnectToClient() here since the instance was created
237 // manually by other code, not in response to a Connect() request. The newly 259 // manually by other code, not in response to a Connect() request. The newly
238 // created instance is identified by |name| and may be subsequently reached 260 // created instance is identified by |name| and may be subsequently reached
239 // by client code using this identity. 261 // by client code using this identity.
240 } 262 }
241 void AddInstanceListener(mojom::InstanceListenerPtr listener) override {
242 // TODO(beng): this should only track the instances matching this user, and
243 // root.
244 shell_->AddInstanceListener(std::move(listener));
245 }
246 263
247 uint32_t GenerateUniqueID() const { 264 uint32_t GenerateUniqueID() const {
248 static uint32_t id = mojom::kInvalidInstanceID; 265 static uint32_t id = mojom::kInvalidInstanceID;
249 ++id; 266 ++id;
250 CHECK_NE(mojom::kInvalidInstanceID, id); 267 CHECK_NE(mojom::kInvalidInstanceID, id);
251 return id; 268 return id;
252 } 269 }
253 270
254 void PIDAvailable(base::ProcessId pid) { 271 void PIDAvailable(base::ProcessId pid) {
255 pid_ = pid; 272 pid_ = pid;
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 for (auto it = native_runners_.begin(); it != native_runners_.end(); ++it) { 612 for (auto it = native_runners_.begin(); it != native_runners_.end(); ++it) {
596 if (it->get() == runner) { 613 if (it->get() == runner) {
597 native_runners_.erase(it); 614 native_runners_.erase(it);
598 return; 615 return;
599 } 616 }
600 } 617 }
601 } 618 }
602 619
603 } // namespace shell 620 } // namespace shell
604 } // namespace mojo 621 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698