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

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, 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 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 19 matching lines...) Expand all
30 #include "services/shell/public/interfaces/shell.mojom.h" 30 #include "services/shell/public/interfaces/shell.mojom.h"
31 #include "services/shell/public/interfaces/shell_client.mojom.h" 31 #include "services/shell/public/interfaces/shell_client.mojom.h"
32 #include "url/gurl.h" 32 #include "url/gurl.h"
33 33
34 namespace shell { 34 namespace shell {
35 35
36 namespace { 36 namespace {
37 37
38 const char kCatalogName[] = "mojo:catalog"; 38 const char kCatalogName[] = "mojo:catalog";
39 const char kShellName[] = "mojo:shell"; 39 const char kShellName[] = "mojo:shell";
40 const char kCapabilityClass_UserID[] = "user_id"; 40 const char kCapabilityClass_UserID[] = "shell:user_id";
41 const char kCapabilityClass_ClientProcess[] = "client_process"; 41 const char kCapabilityClass_ClientProcess[] = "shell:client_process";
42 const char kCapabilityClass_InstanceName[] = "instance_name"; 42 const char kCapabilityClass_InstanceName[] = "shell:instance_name";
43 const char kCapabilityClass_AllUsers[] = "all_users"; 43 const char kCapabilityClass_AllUsers[] = "shell:all_users";
44 const char kCapabilityClass_ExplicitClass[] = "shell:explicit_class";
44 45
45 void EmptyResolverCallback(mojom::ResolveResultPtr result) {} 46 void EmptyResolverCallback(mojom::ResolveResultPtr result) {}
46 47
47 } // namespace 48 } // namespace
48 49
49 Identity CreateShellIdentity() { 50 Identity CreateShellIdentity() {
50 return Identity(kShellName, mojom::kRootUserID); 51 return Identity(kShellName, mojom::kRootUserID);
51 } 52 }
52 53
53 Identity CreateCatalogIdentity() { 54 Identity CreateCatalogIdentity() {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 DCHECK(it != children_.end()); 147 DCHECK(it != children_.end());
147 children_.erase(it); 148 children_.erase(it);
148 child->parent_ = nullptr; 149 child->parent_ = nullptr;
149 } 150 }
150 151
151 void ConnectToClient(std::unique_ptr<ConnectParams> params) { 152 void ConnectToClient(std::unique_ptr<ConnectParams> params) {
152 CHECK(shell_client_.is_bound()); 153 CHECK(shell_client_.is_bound());
153 params->connect_callback().Run(mojom::ConnectResult::SUCCEEDED, 154 params->connect_callback().Run(mojom::ConnectResult::SUCCEEDED,
154 identity_.user_id(), id_); 155 identity_.user_id(), id_);
155 uint32_t source_id = mojom::kInvalidInstanceID; 156 uint32_t source_id = mojom::kInvalidInstanceID;
156 CapabilityRequest spec; 157 CapabilityRequest request;
157 spec.interfaces.insert("*"); 158 request.interfaces.insert("*");
158 Instance* source = shell_->GetExistingInstance(params->source()); 159 Instance* source = shell_->GetExistingInstance(params->source());
159 if (source) { 160 if (source) {
160 spec = GenerateCapabilityRequestForConnection( 161 request = GenerateCapabilityRequestForConnection(
161 source->capability_spec_, identity_, capability_spec_); 162 source->capability_spec_, identity_, capability_spec_);
162 source_id = source->id(); 163 source_id = source->id();
163 } 164 }
165
166 // The target has specified that sources must request one of its provided
167 // classes instead of specifying a wild-card for interfaces or interfaces
168 // directly.
169 if (HasClass(capability_spec_, kCapabilityClass_ExplicitClass) &&
170 (request.classes.empty() || request.interfaces.count("*") != 0)) {
171 request.interfaces = Interfaces();
172 }
173
164 shell_client_->AcceptConnection( 174 shell_client_->AcceptConnection(
165 mojom::Identity::From(params->source()), source_id, 175 mojom::Identity::From(params->source()), source_id,
166 params->TakeRemoteInterfaces(), params->TakeLocalInterfaces(), 176 params->TakeRemoteInterfaces(), params->TakeLocalInterfaces(),
167 mojom::CapabilityRequest::From(spec), params->target().name()); 177 mojom::CapabilityRequest::From(request), params->target().name());
168 } 178 }
169 179
170 void StartWithClient(mojom::ShellClientPtr client) { 180 void StartWithClient(mojom::ShellClientPtr client) {
171 CHECK(!shell_client_); 181 CHECK(!shell_client_);
172 shell_client_ = std::move(client); 182 shell_client_ = std::move(client);
173 shell_client_.set_connection_error_handler( 183 shell_client_.set_connection_error_handler(
174 base::Bind(&Instance::OnShellClientLost, base::Unretained(this), 184 base::Bind(&Instance::OnShellClientLost, base::Unretained(this),
175 shell_->GetWeakPtr())); 185 shell_->GetWeakPtr()));
176 shell_client_->Initialize(mojom::Identity::From(identity_), id_, 186 shell_client_->Initialize(mojom::Identity::From(identity_), id_,
177 base::Bind(&Instance::OnInitializeResponse, 187 base::Bind(&Instance::OnInitializeResponse,
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 void Shell::CleanupRunner(NativeRunner* runner) { 765 void Shell::CleanupRunner(NativeRunner* runner) {
756 for (auto it = native_runners_.begin(); it != native_runners_.end(); ++it) { 766 for (auto it = native_runners_.begin(); it != native_runners_.end(); ++it) {
757 if (it->get() == runner) { 767 if (it->get() == runner) {
758 native_runners_.erase(it); 768 native_runners_.erase(it);
759 return; 769 return;
760 } 770 }
761 } 771 }
762 } 772 }
763 773
764 } // namespace shell 774 } // namespace shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698