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

Side by Side Diff: services/shell/shell.cc

Issue 1910043002: Provide capability classes from Mus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 7 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 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
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 const char kCapabilityClass_ExplicitClass[] = "shell:explicit_class";
41 42
42 void EmptyResolverCallback(mojom::ResolveResultPtr result) {} 43 void EmptyResolverCallback(mojom::ResolveResultPtr result) {}
43 44
44 } // namespace 45 } // namespace
45 46
46 Identity CreateShellIdentity() { 47 Identity CreateShellIdentity() {
47 return Identity(kShellName, mojom::kRootUserID); 48 return Identity(kShellName, mojom::kRootUserID);
48 } 49 }
49 50
50 Identity CreateCatalogIdentity() { 51 Identity CreateCatalogIdentity() {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 DCHECK(it != children_.end()); 144 DCHECK(it != children_.end());
144 children_.erase(it); 145 children_.erase(it);
145 child->parent_ = nullptr; 146 child->parent_ = nullptr;
146 } 147 }
147 148
148 void ConnectToClient(std::unique_ptr<ConnectParams> params) { 149 void ConnectToClient(std::unique_ptr<ConnectParams> params) {
149 CHECK(shell_client_.is_bound()); 150 CHECK(shell_client_.is_bound());
150 params->connect_callback().Run(mojom::ConnectResult::SUCCEEDED, 151 params->connect_callback().Run(mojom::ConnectResult::SUCCEEDED,
151 identity_.user_id(), id_); 152 identity_.user_id(), id_);
152 uint32_t source_id = mojom::kInvalidInstanceID; 153 uint32_t source_id = mojom::kInvalidInstanceID;
153 CapabilityRequest spec; 154 CapabilityRequest request;
154 spec.interfaces.insert("*"); 155 request.interfaces.insert("*");
155 Instance* source = shell_->GetExistingInstance(params->source()); 156 Instance* source = shell_->GetExistingInstance(params->source());
156 if (source) { 157 if (source) {
157 spec = GenerateCapabilityRequestForConnection( 158 request = GenerateCapabilityRequestForConnection(
158 source->capability_spec_, identity_, capability_spec_); 159 source->capability_spec_, identity_, capability_spec_);
159 source_id = source->id(); 160 source_id = source->id();
160 } 161 }
162
163 // The target has specified that sources must request one of its provided
164 // classes instead of specifying a wild-card for interfaces or interfaces
165 // directly.
166 if (HasClass(capability_spec_, kCapabilityClass_ExplicitClass) &&
167 (request.classes.empty() || request.interfaces.count("*") != 0)) {
168 request.interfaces = Interfaces();
169 }
170
161 shell_client_->AcceptConnection( 171 shell_client_->AcceptConnection(
162 mojom::Identity::From(params->source()), source_id, 172 mojom::Identity::From(params->source()), source_id,
163 params->TakeRemoteInterfaces(), params->TakeLocalInterfaces(), 173 params->TakeRemoteInterfaces(), params->TakeLocalInterfaces(),
164 mojom::CapabilityRequest::From(spec), params->target().name()); 174 mojom::CapabilityRequest::From(request), params->target().name());
165 } 175 }
166 176
167 void StartWithClient(mojom::ShellClientPtr client) { 177 void StartWithClient(mojom::ShellClientPtr client) {
168 CHECK(!shell_client_); 178 CHECK(!shell_client_);
169 shell_client_ = std::move(client); 179 shell_client_ = std::move(client);
170 shell_client_.set_connection_error_handler( 180 shell_client_.set_connection_error_handler(
171 base::Bind(&Instance::OnShellClientLost, base::Unretained(this), 181 base::Bind(&Instance::OnShellClientLost, base::Unretained(this),
172 shell_->GetWeakPtr())); 182 shell_->GetWeakPtr()));
173 shell_client_->Initialize(mojom::Identity::From(identity_), id_, 183 shell_client_->Initialize(mojom::Identity::From(identity_), id_,
174 base::Bind(&Instance::OnInitializeResponse, 184 base::Bind(&Instance::OnInitializeResponse,
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 void Shell::CleanupRunner(NativeRunner* runner) { 761 void Shell::CleanupRunner(NativeRunner* runner) {
752 for (auto it = native_runners_.begin(); it != native_runners_.end(); ++it) { 762 for (auto it = native_runners_.begin(); it != native_runners_.end(); ++it) {
753 if (it->get() == runner) { 763 if (it->get() == runner) {
754 native_runners_.erase(it); 764 native_runners_.erase(it);
755 return; 765 return;
756 } 766 }
757 } 767 }
758 } 768 }
759 769
760 } // namespace shell 770 } // namespace shell
OLDNEW
« no previous file with comments | « services/shell/public/cpp/lib/interface_registry.cc ('k') | services/shell/tests/connect/connect_test_app_a_manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698