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

Unified Diff: mojo/shell/application_manager.cc

Issue 1719193003: Add a user id parameter to connections (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/shell/application_manager.h ('k') | mojo/shell/background/background_shell.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/shell/application_manager.cc
diff --git a/mojo/shell/application_manager.cc b/mojo/shell/application_manager.cc
index 0ed616002feddf295972fdc456886eb9c728223f..aaae40a66c78c04d29c90e99db3732e8d2ab7b14 100644
--- a/mojo/shell/application_manager.cc
+++ b/mojo/shell/application_manager.cc
@@ -29,29 +29,6 @@
namespace mojo {
namespace shell {
-namespace {
-
-class ShellApplicationLoader : public ApplicationLoader {
- public:
- explicit ShellApplicationLoader(ApplicationManager* manager)
- : manager_(manager) {}
- ~ShellApplicationLoader() override {}
-
- private:
- // Overridden from ApplicationLoader:
- void Load(const GURL& url, mojom::ShellClientRequest request) override {
- DCHECK(request.is_pending());
- shell_connection_.reset(new ShellConnection(manager_, std::move(request)));
- }
-
- ApplicationManager* manager_;
- scoped_ptr<ShellConnection> shell_connection_;
-
- DISALLOW_COPY_AND_ASSIGN(ShellApplicationLoader);
-};
-
-} // namespace
-
// static
ApplicationManager::TestAPI::TestAPI(ApplicationManager* manager)
: manager_(manager) {
@@ -79,8 +56,9 @@ ApplicationManager::ApplicationManager(
: task_runner_(task_runner),
native_runner_factory_(std::move(native_runner_factory)),
weak_ptr_factory_(this) {
- SetLoaderForURL(make_scoped_ptr(new ShellApplicationLoader(this)),
- GURL("mojo://shell/"));
+ mojom::ShellClientRequest request;
+ CreateInstance(CreateShellIdentity(), &request);
+ shell_connection_.reset(new ShellConnection(this, std::move(request)));
InitPackageManager(register_mojo_url_schemes);
}
@@ -103,6 +81,15 @@ void ApplicationManager::Connect(scoped_ptr<ConnectParams> params) {
params->target().url().spec());
DCHECK(params->target().url().is_valid());
+ if (params->target().user_id() == mojom::Shell::kUserInherit) {
+ ApplicationInstance* source = GetApplicationInstance(params->source());
+ Identity target = params->target();
+ // TODO(beng): we should CHECK source.
+ target.set_user_id(source ? source->identity().user_id()
+ : mojom::Shell::kUserRoot);
+ params->set_target(target);
+ }
+
// Connect to an existing matching instance, if possible.
if (ConnectToExistingInstance(&params))
return;
@@ -194,7 +181,9 @@ void ApplicationManager::CreateInstanceForHandle(
// created instance is identified by |url| and may be subsequently reached by
// client code using this identity.
CapabilityFilter local_filter = filter->filter.To<CapabilityFilter>();
- Identity target_id(url.To<GURL>(), std::string(), local_filter);
+ // TODO(beng): obtain userid from the inbound connection.
+ Identity target_id(url.To<GURL>(), std::string(), mojom::Shell::kUserInherit,
+ local_filter);
mojom::ShellClientRequest request;
ApplicationInstance* instance = CreateInstance(target_id, &request);
instance->BindPIDReceiver(std::move(pid_receiver));
@@ -235,8 +224,12 @@ void ApplicationManager::InitPackageManager(bool register_mojo_url_schemes) {
bool ApplicationManager::ConnectToExistingInstance(
scoped_ptr<ConnectParams>* params) {
ApplicationInstance* instance = GetApplicationInstance((*params)->target());
- if (!instance)
- return false;
+ if (!instance) {
+ Identity root_identity = (*params)->target();
+ root_identity.set_user_id(mojom::Shell::kUserRoot);
+ instance = GetApplicationInstance(root_identity);
+ if (!instance) return false;
+ }
instance->ConnectToClient(std::move(*params));
return true;
}
@@ -315,7 +308,8 @@ void ApplicationManager::OnGotResolvedURL(
// TODO(beng): this clobbers the filter passed via Connect().
if (!base_filter.is_null())
filter = base_filter->filter.To<CapabilityFilter>();
- Identity target(params->target().url(), params->target().qualifier(), filter);
+ Identity target(params->target().url(), params->target().qualifier(),
+ params->target().user_id(), filter);
mojom::ShellClientRequest request;
ApplicationInstance* instance = CreateInstance(target, &request);
@@ -332,7 +326,8 @@ void ApplicationManager::OnGotResolvedURL(
// from the original request rather than for the package itself, which will
// always be the same.
CreateShellClient(source,
- Identity(resolved_gurl, target.qualifier(), filter),
+ Identity(resolved_gurl, target.qualifier(),
+ target.user_id(), filter),
target.url(), std::move(request));
} else {
bool start_sandboxed = false;
« no previous file with comments | « mojo/shell/application_manager.h ('k') | mojo/shell/background/background_shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698