OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "services/shell/shell.h" | 5 #include "services/shell/shell.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "services/shell/public/interfaces/connector.mojom.h" | 27 #include "services/shell/public/interfaces/connector.mojom.h" |
28 #include "services/shell/public/interfaces/shell.mojom.h" | 28 #include "services/shell/public/interfaces/shell.mojom.h" |
29 #include "services/shell/public/interfaces/shell_client.mojom.h" | 29 #include "services/shell/public/interfaces/shell_client.mojom.h" |
30 | 30 |
31 namespace shell { | 31 namespace shell { |
32 | 32 |
33 namespace { | 33 namespace { |
34 | 34 |
35 const char kCatalogName[] = "mojo:catalog"; | 35 const char kCatalogName[] = "mojo:catalog"; |
36 const char kShellName[] = "mojo:shell"; | 36 const char kShellName[] = "mojo:shell"; |
37 const char kCapabilityClass_UserID[] = "user_id"; | 37 const char kCapabilityClass_UserID[] = "shell:user_id"; |
38 const char kCapabilityClass_ClientProcess[] = "client_process"; | 38 const char kCapabilityClass_ClientProcess[] = "shell:client_process"; |
39 const char kCapabilityClass_InstanceName[] = "instance_name"; | 39 const char kCapabilityClass_InstanceName[] = "shell:instance_name"; |
40 const char kCapabilityClass_AllUsers[] = "all_users"; | 40 const char kCapabilityClass_AllUsers[] = "shell:all_users"; |
41 | 41 |
42 void EmptyResolverCallback(mojom::ResolveResultPtr result) {} | 42 void EmptyResolverCallback(mojom::ResolveResultPtr result) {} |
43 | 43 |
44 } // namespace | 44 } // namespace |
45 | 45 |
46 Identity CreateShellIdentity() { | 46 Identity CreateShellIdentity() { |
47 return Identity(kShellName, mojom::kRootUserID); | 47 return Identity(kShellName, mojom::kRootUserID); |
48 } | 48 } |
49 | 49 |
50 Identity CreateCatalogIdentity() { | 50 Identity CreateCatalogIdentity() { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 DCHECK(it != children_.end()); | 143 DCHECK(it != children_.end()); |
144 children_.erase(it); | 144 children_.erase(it); |
145 child->parent_ = nullptr; | 145 child->parent_ = nullptr; |
146 } | 146 } |
147 | 147 |
148 void ConnectToClient(std::unique_ptr<ConnectParams> params) { | 148 void ConnectToClient(std::unique_ptr<ConnectParams> params) { |
149 CHECK(shell_client_.is_bound()); | 149 CHECK(shell_client_.is_bound()); |
150 params->connect_callback().Run(mojom::ConnectResult::SUCCEEDED, | 150 params->connect_callback().Run(mojom::ConnectResult::SUCCEEDED, |
151 identity_.user_id(), id_); | 151 identity_.user_id(), id_); |
152 uint32_t source_id = mojom::kInvalidInstanceID; | 152 uint32_t source_id = mojom::kInvalidInstanceID; |
153 CapabilityRequest spec; | 153 CapabilityRequest request; |
154 spec.interfaces.insert("*"); | 154 request.interfaces.insert("*"); |
155 Instance* source = shell_->GetExistingInstance(params->source()); | 155 Instance* source = shell_->GetExistingInstance(params->source()); |
156 if (source) { | 156 if (source) { |
157 spec = GenerateCapabilityRequestForConnection( | 157 request = GenerateCapabilityRequestForConnection( |
158 source->capability_spec_, identity_, capability_spec_); | 158 source->capability_spec_, identity_, capability_spec_); |
159 source_id = source->id(); | 159 source_id = source->id(); |
160 } | 160 } |
161 shell_client_->AcceptConnection( | 161 shell_client_->AcceptConnection( |
162 mojom::Identity::From(params->source()), source_id, | 162 mojom::Identity::From(params->source()), source_id, |
163 params->TakeRemoteInterfaces(), params->TakeLocalInterfaces(), | 163 params->TakeRemoteInterfaces(), params->TakeLocalInterfaces(), |
164 mojom::CapabilityRequest::From(spec), params->target().name()); | 164 mojom::CapabilityRequest::From(request), params->target().name()); |
165 } | 165 } |
166 | 166 |
167 void StartWithClient(mojom::ShellClientPtr client) { | 167 void StartWithClient(mojom::ShellClientPtr client) { |
168 CHECK(!shell_client_); | 168 CHECK(!shell_client_); |
169 shell_client_ = std::move(client); | 169 shell_client_ = std::move(client); |
170 shell_client_.set_connection_error_handler( | 170 shell_client_.set_connection_error_handler( |
171 base::Bind(&Instance::OnShellClientLost, base::Unretained(this), | 171 base::Bind(&Instance::OnShellClientLost, base::Unretained(this), |
172 shell_->GetWeakPtr())); | 172 shell_->GetWeakPtr())); |
173 shell_client_->Initialize(mojom::Identity::From(identity_), id_, | 173 shell_client_->Initialize(mojom::Identity::From(identity_), id_, |
174 base::Bind(&Instance::OnInitializeResponse, | 174 base::Bind(&Instance::OnInitializeResponse, |
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
751 void Shell::CleanupRunner(NativeRunner* runner) { | 751 void Shell::CleanupRunner(NativeRunner* runner) { |
752 for (auto it = native_runners_.begin(); it != native_runners_.end(); ++it) { | 752 for (auto it = native_runners_.begin(); it != native_runners_.end(); ++it) { |
753 if (it->get() == runner) { | 753 if (it->get() == runner) { |
754 native_runners_.erase(it); | 754 native_runners_.erase(it); |
755 return; | 755 return; |
756 } | 756 } |
757 } | 757 } |
758 } | 758 } |
759 | 759 |
760 } // namespace shell | 760 } // namespace shell |
OLD | NEW |