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

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

Issue 1734643003: Remove CapabilityFilter from Connect() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@13connector2
Patch Set: . Created 4 years, 10 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
« no previous file with comments | « mojo/shell/application_instance.cc ('k') | mojo/shell/background/background_shell.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 171
172 void ApplicationManager::CreateInstanceForHandle( 172 void ApplicationManager::CreateInstanceForHandle(
173 ScopedHandle channel, 173 ScopedHandle channel,
174 const String& url, 174 const String& url,
175 mojom::CapabilityFilterPtr filter, 175 mojom::CapabilityFilterPtr filter,
176 mojom::PIDReceiverRequest pid_receiver) { 176 mojom::PIDReceiverRequest pid_receiver) {
177 // We don't call ConnectToClient() here since the instance was created 177 // We don't call ConnectToClient() here since the instance was created
178 // manually by other code, not in response to a Connect() request. The newly 178 // manually by other code, not in response to a Connect() request. The newly
179 // created instance is identified by |url| and may be subsequently reached by 179 // created instance is identified by |url| and may be subsequently reached by
180 // client code using this identity. 180 // client code using this identity.
181 CapabilityFilter local_filter = filter->filter.To<CapabilityFilter>();
182 // TODO(beng): obtain userid from the inbound connection. 181 // TODO(beng): obtain userid from the inbound connection.
183 Identity target_id(url.To<GURL>(), std::string(), 182 Identity target_id(url.To<GURL>(), std::string(),
184 mojom::Connector::kUserInherit, local_filter); 183 mojom::Connector::kUserInherit);
184 target_id.SetFilter(filter->filter.To<CapabilityFilter>());
185 mojom::ShellClientRequest request; 185 mojom::ShellClientRequest request;
186 ApplicationInstance* instance = CreateInstance(target_id, &request); 186 ApplicationInstance* instance = CreateInstance(target_id, &request);
187 instance->BindPIDReceiver(std::move(pid_receiver)); 187 instance->BindPIDReceiver(std::move(pid_receiver));
188 scoped_ptr<NativeRunner> runner = 188 scoped_ptr<NativeRunner> runner =
189 native_runner_factory_->Create(base::FilePath()); 189 native_runner_factory_->Create(base::FilePath());
190 runner->InitHost(std::move(channel), std::move(request)); 190 runner->InitHost(std::move(channel), std::move(request));
191 instance->SetNativeRunner(runner.get()); 191 instance->SetNativeRunner(runner.get());
192 native_runners_.push_back(std::move(runner)); 192 native_runners_.push_back(std::move(runner));
193 } 193 }
194 194
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 const String& resolved_qualifier, 297 const String& resolved_qualifier,
298 mojom::CapabilityFilterPtr base_filter, 298 mojom::CapabilityFilterPtr base_filter,
299 const String& file_url) { 299 const String& file_url) {
300 // It's possible that when this manifest request was issued, another one was 300 // It's possible that when this manifest request was issued, another one was
301 // already in-progress and completed by the time this one did, and so the 301 // already in-progress and completed by the time this one did, and so the
302 // requested application may already be running. 302 // requested application may already be running.
303 if (ConnectToExistingInstance(&params)) 303 if (ConnectToExistingInstance(&params))
304 return; 304 return;
305 305
306 Identity source = params->source(); 306 Identity source = params->source();
307 CapabilityFilter filter = params->target().filter(); 307 // |base_filter| can be null when there is no manifest, e.g. for URL types
308 // TODO(beng): this clobbers the filter passed via Connect(). 308 // not resolvable by the resolver.
309 CapabilityFilter filter = GetPermissiveCapabilityFilter();
309 if (!base_filter.is_null()) 310 if (!base_filter.is_null())
310 filter = base_filter->filter.To<CapabilityFilter>(); 311 filter = base_filter->filter.To<CapabilityFilter>();
311 Identity target(params->target().url(), params->target().qualifier(), 312 Identity target = params->target();
312 params->target().user_id(), filter); 313 target.SetFilter(filter);
313 314
314 mojom::ShellClientRequest request; 315 mojom::ShellClientRequest request;
315 ApplicationInstance* instance = CreateInstance(target, &request); 316 ApplicationInstance* instance = CreateInstance(target, &request);
316 instance->ConnectToClient(std::move(params)); 317 instance->ConnectToClient(std::move(params));
317 318
318 if (LoadWithLoader(target, &request)) 319 if (LoadWithLoader(target, &request))
319 return; 320 return;
320 321
321 CHECK(!file_url.is_null() && !base_filter.is_null()); 322 CHECK(!file_url.is_null() && !base_filter.is_null());
322 323
323 GURL resolved_gurl = resolved_url.To<GURL>(); 324 GURL resolved_gurl = resolved_url.To<GURL>();
324 if (target.url().spec() != resolved_url) { 325 if (target.url().spec() != resolved_url) {
325 // In cases where a package alias is resolved, we have to use the qualifier 326 // In cases where a package alias is resolved, we have to use the qualifier
326 // from the original request rather than for the package itself, which will 327 // from the original request rather than for the package itself, which will
327 // always be the same. 328 // always be the same.
328 CreateShellClient(source, 329 CreateShellClient(
329 Identity(resolved_gurl, target.qualifier(), 330 source, Identity(resolved_gurl, target.qualifier(), target.user_id()),
330 target.user_id(), filter), 331 target.url(), std::move(request));
331 target.url(), std::move(request));
332 } else { 332 } else {
333 bool start_sandboxed = false; 333 bool start_sandboxed = false;
334 base::FilePath path = util::UrlToFilePath(file_url.To<GURL>()); 334 base::FilePath path = util::UrlToFilePath(file_url.To<GURL>());
335 scoped_ptr<NativeRunner> runner = native_runner_factory_->Create(path); 335 scoped_ptr<NativeRunner> runner = native_runner_factory_->Create(path);
336 runner->Start(path, target, start_sandboxed, std::move(request), 336 runner->Start(path, target, start_sandboxed, std::move(request),
337 base::Bind(&ApplicationManager::ApplicationPIDAvailable, 337 base::Bind(&ApplicationManager::ApplicationPIDAvailable,
338 weak_ptr_factory_.GetWeakPtr(), instance->id()), 338 weak_ptr_factory_.GetWeakPtr(), instance->id()),
339 base::Bind(&ApplicationManager::CleanupRunner, 339 base::Bind(&ApplicationManager::CleanupRunner,
340 weak_ptr_factory_.GetWeakPtr(), runner.get())); 340 weak_ptr_factory_.GetWeakPtr(), runner.get()));
341 instance->SetNativeRunner(runner.get()); 341 instance->SetNativeRunner(runner.get());
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 info->qualifier = instance->identity().qualifier(); 376 info->qualifier = instance->identity().qualifier();
377 if (instance->identity().url().spec() == "mojo://shell/") 377 if (instance->identity().url().spec() == "mojo://shell/")
378 info->pid = base::Process::Current().Pid(); 378 info->pid = base::Process::Current().Pid();
379 else 379 else
380 info->pid = instance->pid(); 380 info->pid = instance->pid();
381 return info; 381 return info;
382 } 382 }
383 383
384 } // namespace shell 384 } // namespace shell
385 } // namespace mojo 385 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/application_instance.cc ('k') | mojo/shell/background/background_shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698