OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/shell_application_delegate.h" | 5 #include "mojo/shell/shell_application_delegate.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/process/process.h" | 9 #include "base/process/process.h" |
8 #include "mojo/application/public/cpp/application_connection.h" | 10 #include "mojo/application/public/cpp/application_connection.h" |
9 #include "mojo/shell/application_manager.h" | 11 #include "mojo/shell/application_manager.h" |
10 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" | 12 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" |
11 | 13 |
12 namespace mojo { | 14 namespace mojo { |
13 namespace shell { | 15 namespace shell { |
14 | 16 |
15 ShellApplicationDelegate::ShellApplicationDelegate( | 17 ShellApplicationDelegate::ShellApplicationDelegate( |
16 mojo::shell::ApplicationManager* manager) | 18 mojo::shell::ApplicationManager* manager) |
17 : manager_(manager) {} | 19 : manager_(manager) {} |
18 ShellApplicationDelegate::~ShellApplicationDelegate() {} | 20 ShellApplicationDelegate::~ShellApplicationDelegate() {} |
19 | 21 |
20 void ShellApplicationDelegate::Initialize(ApplicationImpl* app) {} | 22 void ShellApplicationDelegate::Initialize(ApplicationImpl* app) {} |
21 bool ShellApplicationDelegate::ConfigureIncomingConnection( | 23 bool ShellApplicationDelegate::ConfigureIncomingConnection( |
22 ApplicationConnection* connection) { | 24 ApplicationConnection* connection) { |
23 connection->AddService<mojom::ApplicationManager>(this); | 25 connection->AddService<mojom::ApplicationManager>(this); |
24 return true; | 26 return true; |
25 } | 27 } |
26 | 28 |
27 void ShellApplicationDelegate::Create( | 29 void ShellApplicationDelegate::Create( |
28 ApplicationConnection* connection, | 30 ApplicationConnection* connection, |
29 InterfaceRequest<mojom::ApplicationManager> request) { | 31 InterfaceRequest<mojom::ApplicationManager> request) { |
30 bindings_.AddBinding(this, request.Pass()); | 32 bindings_.AddBinding(this, std::move(request)); |
31 } | 33 } |
32 | 34 |
33 void ShellApplicationDelegate::CreateInstanceForHandle( | 35 void ShellApplicationDelegate::CreateInstanceForHandle( |
34 ScopedHandle channel, | 36 ScopedHandle channel, |
35 const String& url, | 37 const String& url, |
36 CapabilityFilterPtr filter) { | 38 CapabilityFilterPtr filter) { |
37 manager_->CreateInstanceForHandle(channel.Pass(), GURL(url), filter.Pass()); | 39 manager_->CreateInstanceForHandle(std::move(channel), GURL(url), |
| 40 std::move(filter)); |
38 } | 41 } |
39 | 42 |
40 void ShellApplicationDelegate::RegisterProcessWithBroker( | 43 void ShellApplicationDelegate::RegisterProcessWithBroker( |
41 uint32_t pid, ScopedHandle pipe) { | 44 uint32_t pid, ScopedHandle pipe) { |
42 // First, for security we want to verify that the given pid's grand parent | 45 // First, for security we want to verify that the given pid's grand parent |
43 // process is us. | 46 // process is us. |
44 base::Process process = base::Process::OpenWithExtraPrivileges( | 47 base::Process process = base::Process::OpenWithExtraPrivileges( |
45 static_cast<base::ProcessId>(pid)); | 48 static_cast<base::ProcessId>(pid)); |
46 if (!process.IsValid()) { | 49 if (!process.IsValid()) { |
47 NOTREACHED(); | 50 NOTREACHED(); |
(...skipping 17 matching lines...) Expand all Loading... |
65 { | 68 { |
66 NOTREACHED(); | 69 NOTREACHED(); |
67 return; | 70 return; |
68 } | 71 } |
69 } | 72 } |
70 | 73 |
71 embedder::ScopedPlatformHandle platform_pipe; | 74 embedder::ScopedPlatformHandle platform_pipe; |
72 MojoResult rv = embedder::PassWrappedPlatformHandle( | 75 MojoResult rv = embedder::PassWrappedPlatformHandle( |
73 pipe.release().value(), &platform_pipe); | 76 pipe.release().value(), &platform_pipe); |
74 CHECK_EQ(rv, MOJO_RESULT_OK); | 77 CHECK_EQ(rv, MOJO_RESULT_OK); |
75 embedder::ChildProcessLaunched(process.Handle(), platform_pipe.Pass()); | 78 embedder::ChildProcessLaunched(process.Handle(), std::move(platform_pipe)); |
76 } | 79 } |
77 | 80 |
78 void ShellApplicationDelegate::AddListener( | 81 void ShellApplicationDelegate::AddListener( |
79 mojom::ApplicationManagerListenerPtr listener) { | 82 mojom::ApplicationManagerListenerPtr listener) { |
80 manager_->AddListener(std::move(listener)); | 83 manager_->AddListener(std::move(listener)); |
81 } | 84 } |
82 | 85 |
83 } // namespace shell | 86 } // namespace shell |
84 } // namespace mojo | 87 } // namespace mojo |
OLD | NEW |