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

Unified Diff: content/browser/mojo/browser_shell_connection.cc

Issue 1871223003: Use ShellClientFactory interface to load mojo:profile (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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 | « content/browser/mojo/browser_shell_connection.h ('k') | content/browser/mojo/mojo_shell_context.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/mojo/browser_shell_connection.cc
diff --git a/content/browser/mojo/browser_shell_connection.cc b/content/browser/mojo/browser_shell_connection.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8fb9121389cb43308cd8bbddc9777e3688cf180c
--- /dev/null
+++ b/content/browser/mojo/browser_shell_connection.cc
@@ -0,0 +1,65 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/mojo/browser_shell_connection.h"
+
+#include "content/browser/mojo/constants.h"
+#include "services/shell/public/interfaces/connector.mojom.h"
+
+namespace content {
+
+BrowserShellConnection::BrowserShellConnection(
+ mojo::shell::mojom::ShellClientRequest request)
+ : shell_connection_(new mojo::ShellConnection(this, std::move(request))) {}
+
+BrowserShellConnection::~BrowserShellConnection() {}
+
+mojo::Connector* BrowserShellConnection::GetConnector() {
+ return shell_connection_->connector();
+}
+
+void BrowserShellConnection::AddEmbeddedApplication(
+ const base::StringPiece& name,
+ const EmbeddedApplicationRunner::FactoryCallback& callback,
+ const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) {
+ std::unique_ptr<EmbeddedApplicationRunner> app(
+ new EmbeddedApplicationRunner(callback, task_runner));
+ auto result = embedded_apps_.insert(
+ std::make_pair(name.as_string(), std::move(app)));
+ DCHECK(result.second);
+}
+
+bool BrowserShellConnection::AcceptConnection(mojo::Connection* connection) {
+ std::string remote_app = connection->GetRemoteIdentity().name();
+ if (remote_app == "mojo:shell") {
+ // Only expose the SCF interface to the shell.
+ connection->AddInterface<mojo::shell::mojom::ShellClientFactory>(this);
+ return true;
+ }
+
+ // Allow connections from the root browser application.
+ if (remote_app == kBrowserMojoApplicationName &&
+ connection->GetRemoteIdentity().user_id() ==
+ mojo::shell::mojom::kRootUserID)
+ return true;
+
+ // Reject all other connections to this application.
+ return false;
+}
+
+void BrowserShellConnection::Create(
+ mojo::Connection* connection,
+ mojo::shell::mojom::ShellClientFactoryRequest request) {
+ factory_bindings_.AddBinding(this, std::move(request));
+}
+
+void BrowserShellConnection::CreateShellClient(
+ mojo::shell::mojom::ShellClientRequest request,
+ const mojo::String& name) {
+ auto it = embedded_apps_.find(name);
+ if (it != embedded_apps_.end())
+ it->second->BindShellClientRequest(std::move(request));
+}
+
+} // namespace content
« no previous file with comments | « content/browser/mojo/browser_shell_connection.h ('k') | content/browser/mojo/mojo_shell_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698