| OLD | NEW |
| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "content/browser/mojo/constants.h" | 8 #include "content/browser/mojo/constants.h" |
| 9 #include "content/public/common/mojo_application_info.h" |
| 9 #include "services/shell/public/interfaces/connector.mojom.h" | 10 #include "services/shell/public/interfaces/connector.mojom.h" |
| 10 | 11 |
| 11 namespace content { | 12 namespace content { |
| 12 | 13 |
| 13 BrowserShellConnection::BrowserShellConnection() {} | 14 BrowserShellConnection::BrowserShellConnection() {} |
| 14 | 15 |
| 15 BrowserShellConnection::BrowserShellConnection( | 16 BrowserShellConnection::BrowserShellConnection( |
| 16 shell::mojom::ShellClientRequest request) | 17 shell::mojom::ShellClientRequest request) |
| 17 : shell_connection_(new shell::ShellConnection(this, std::move(request))) {} | 18 : shell_connection_(new shell::ShellConnection(this, std::move(request))) {} |
| 18 | 19 |
| 19 BrowserShellConnection::~BrowserShellConnection() {} | 20 BrowserShellConnection::~BrowserShellConnection() {} |
| 20 | 21 |
| 21 shell::Connector* BrowserShellConnection::GetConnector() { | 22 shell::Connector* BrowserShellConnection::GetConnector() { |
| 22 DCHECK(shell_connection_); | 23 DCHECK(shell_connection_); |
| 23 return shell_connection_->connector(); | 24 return shell_connection_->connector(); |
| 24 } | 25 } |
| 25 | 26 |
| 26 void BrowserShellConnection::AddEmbeddedApplication( | 27 void BrowserShellConnection::AddEmbeddedApplication( |
| 27 const base::StringPiece& name, | 28 const base::StringPiece& name, |
| 28 const EmbeddedApplicationRunner::FactoryCallback& callback, | 29 const MojoApplicationInfo& info) { |
| 29 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { | |
| 30 std::unique_ptr<EmbeddedApplicationRunner> app( | 30 std::unique_ptr<EmbeddedApplicationRunner> app( |
| 31 new EmbeddedApplicationRunner(callback, task_runner)); | 31 new EmbeddedApplicationRunner(name, info)); |
| 32 AddShellClientRequestHandler( | 32 AddShellClientRequestHandler( |
| 33 name, base::Bind(&EmbeddedApplicationRunner::BindShellClientRequest, | 33 name, base::Bind(&EmbeddedApplicationRunner::BindShellClientRequest, |
| 34 base::Unretained(app.get()))); | 34 base::Unretained(app.get()))); |
| 35 auto result = embedded_apps_.insert( | 35 auto result = embedded_apps_.insert( |
| 36 std::make_pair(name.as_string(), std::move(app))); | 36 std::make_pair(name.as_string(), std::move(app))); |
| 37 DCHECK(result.second); | 37 DCHECK(result.second); |
| 38 } | 38 } |
| 39 | 39 |
| 40 void BrowserShellConnection::AddShellClientRequestHandler( | 40 void BrowserShellConnection::AddShellClientRequestHandler( |
| 41 const base::StringPiece& name, | 41 const base::StringPiece& name, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 70 | 70 |
| 71 void BrowserShellConnection::CreateShellClient( | 71 void BrowserShellConnection::CreateShellClient( |
| 72 shell::mojom::ShellClientRequest request, | 72 shell::mojom::ShellClientRequest request, |
| 73 const mojo::String& name) { | 73 const mojo::String& name) { |
| 74 auto it = request_handlers_.find(name); | 74 auto it = request_handlers_.find(name); |
| 75 if (it != request_handlers_.end()) | 75 if (it != request_handlers_.end()) |
| 76 it->second.Run(std::move(request)); | 76 it->second.Run(std::move(request)); |
| 77 } | 77 } |
| 78 | 78 |
| 79 } // namespace content | 79 } // namespace content |
| OLD | NEW |