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

Side by Side Diff: content/browser/mojo/browser_shell_connection.cc

Issue 1882423004: Move shell service to toplevel shell namespace (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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "content/browser/mojo/browser_shell_connection.h" 5 #include "content/browser/mojo/browser_shell_connection.h"
6 6
7 #include "content/browser/mojo/constants.h" 7 #include "content/browser/mojo/constants.h"
8 #include "services/shell/public/interfaces/connector.mojom.h" 8 #include "services/shell/public/interfaces/connector.mojom.h"
9 9
10 namespace content { 10 namespace content {
11 11
12 BrowserShellConnection::BrowserShellConnection( 12 BrowserShellConnection::BrowserShellConnection(
13 mojo::shell::mojom::ShellClientRequest request) 13 shell::mojom::ShellClientRequest request)
14 : shell_connection_(new mojo::ShellConnection(this, std::move(request))) {} 14 : shell_connection_(new shell::ShellConnection(this, std::move(request))) {}
15 15
16 BrowserShellConnection::~BrowserShellConnection() {} 16 BrowserShellConnection::~BrowserShellConnection() {}
17 17
18 mojo::Connector* BrowserShellConnection::GetConnector() { 18 shell::Connector* BrowserShellConnection::GetConnector() {
19 return shell_connection_->connector(); 19 return shell_connection_->connector();
20 } 20 }
21 21
22 void BrowserShellConnection::AddEmbeddedApplication( 22 void BrowserShellConnection::AddEmbeddedApplication(
23 const base::StringPiece& name, 23 const base::StringPiece& name,
24 const EmbeddedApplicationRunner::FactoryCallback& callback, 24 const EmbeddedApplicationRunner::FactoryCallback& callback,
25 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { 25 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) {
26 std::unique_ptr<EmbeddedApplicationRunner> app( 26 std::unique_ptr<EmbeddedApplicationRunner> app(
27 new EmbeddedApplicationRunner(callback, task_runner)); 27 new EmbeddedApplicationRunner(callback, task_runner));
28 auto result = embedded_apps_.insert( 28 auto result = embedded_apps_.insert(
29 std::make_pair(name.as_string(), std::move(app))); 29 std::make_pair(name.as_string(), std::move(app)));
30 DCHECK(result.second); 30 DCHECK(result.second);
31 } 31 }
32 32
33 bool BrowserShellConnection::AcceptConnection(mojo::Connection* connection) { 33 bool BrowserShellConnection::AcceptConnection(shell::Connection* connection) {
34 std::string remote_app = connection->GetRemoteIdentity().name(); 34 std::string remote_app = connection->GetRemoteIdentity().name();
35 if (remote_app == "mojo:shell") { 35 if (remote_app == "mojo:shell") {
36 // Only expose the SCF interface to the shell. 36 // Only expose the SCF interface to the shell.
37 connection->AddInterface<mojo::shell::mojom::ShellClientFactory>(this); 37 connection->AddInterface<shell::mojom::ShellClientFactory>(this);
38 return true; 38 return true;
39 } 39 }
40 40
41 // Allow connections from the root browser application. 41 // Allow connections from the root browser application.
42 if (remote_app == kBrowserMojoApplicationName && 42 if (remote_app == kBrowserMojoApplicationName &&
43 connection->GetRemoteIdentity().user_id() == 43 connection->GetRemoteIdentity().user_id() == shell::mojom::kRootUserID)
44 mojo::shell::mojom::kRootUserID)
45 return true; 44 return true;
46 45
47 // Reject all other connections to this application. 46 // Reject all other connections to this application.
48 return false; 47 return false;
49 } 48 }
50 49
51 void BrowserShellConnection::Create( 50 void BrowserShellConnection::Create(
52 mojo::Connection* connection, 51 shell::Connection* connection,
53 mojo::shell::mojom::ShellClientFactoryRequest request) { 52 shell::mojom::ShellClientFactoryRequest request) {
54 factory_bindings_.AddBinding(this, std::move(request)); 53 factory_bindings_.AddBinding(this, std::move(request));
55 } 54 }
56 55
57 void BrowserShellConnection::CreateShellClient( 56 void BrowserShellConnection::CreateShellClient(
58 mojo::shell::mojom::ShellClientRequest request, 57 shell::mojom::ShellClientRequest request,
59 const mojo::String& name) { 58 const mojo::String& name) {
60 auto it = embedded_apps_.find(name); 59 auto it = embedded_apps_.find(name);
61 if (it != embedded_apps_.end()) 60 if (it != embedded_apps_.end())
62 it->second->BindShellClientRequest(std::move(request)); 61 it->second->BindShellClientRequest(std::move(request));
63 } 62 }
64 63
65 } // namespace content 64 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/mojo/browser_shell_connection.h ('k') | content/browser/mojo/mojo_app_connection_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698