| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 | 79 |
| 80 #ifndef NDEBUG | 80 #ifndef NDEBUG |
| 81 scoped_refptr<base::SingleThreadTaskRunner> clone_task_runner_; | 81 scoped_refptr<base::SingleThreadTaskRunner> clone_task_runner_; |
| 82 #endif | 82 #endif |
| 83 | 83 |
| 84 DISALLOW_COPY_AND_ASSIGN(AppRefCountImpl); | 84 DISALLOW_COPY_AND_ASSIGN(AppRefCountImpl); |
| 85 }; | 85 }; |
| 86 | 86 |
| 87 | 87 |
| 88 ShellConnection::ConnectParams::ConnectParams(const std::string& url) | 88 ShellConnection::ConnectParams::ConnectParams(const std::string& url) |
| 89 : url_(url), filter_(shell::mojom::CapabilityFilter::New()) { | 89 : url_(url), |
| 90 filter_(shell::mojom::CapabilityFilter::New()), |
| 91 user_id_(shell::mojom::Shell::kUserInherit) { |
| 90 filter_->filter.SetToEmpty(); | 92 filter_->filter.SetToEmpty(); |
| 91 } | 93 } |
| 92 ShellConnection::ConnectParams::~ConnectParams() {} | 94 ShellConnection::ConnectParams::~ConnectParams() {} |
| 93 | 95 |
| 94 //////////////////////////////////////////////////////////////////////////////// | 96 //////////////////////////////////////////////////////////////////////////////// |
| 95 // ShellConnection, public: | 97 // ShellConnection, public: |
| 96 | 98 |
| 97 ShellConnection::ShellConnection( | 99 ShellConnection::ShellConnection( |
| 98 mojo::ShellClient* client, | 100 mojo::ShellClient* client, |
| 99 InterfaceRequest<shell::mojom::ShellClient> request) | 101 InterfaceRequest<shell::mojom::ShellClient> request) |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 std::set<std::string> allowed; | 142 std::set<std::string> allowed; |
| 141 allowed.insert("*"); | 143 allowed.insert("*"); |
| 142 shell::mojom::InterfaceProviderPtr local_interfaces; | 144 shell::mojom::InterfaceProviderPtr local_interfaces; |
| 143 shell::mojom::InterfaceProviderRequest local_request = | 145 shell::mojom::InterfaceProviderRequest local_request = |
| 144 GetProxy(&local_interfaces); | 146 GetProxy(&local_interfaces); |
| 145 shell::mojom::InterfaceProviderPtr remote_interfaces; | 147 shell::mojom::InterfaceProviderPtr remote_interfaces; |
| 146 shell::mojom::InterfaceProviderRequest remote_request = | 148 shell::mojom::InterfaceProviderRequest remote_request = |
| 147 GetProxy(&remote_interfaces); | 149 GetProxy(&remote_interfaces); |
| 148 scoped_ptr<internal::ConnectionImpl> registry(new internal::ConnectionImpl( | 150 scoped_ptr<internal::ConnectionImpl> registry(new internal::ConnectionImpl( |
| 149 application_url, application_url, | 151 application_url, application_url, |
| 150 shell::mojom::Shell::kInvalidApplicationID, std::move(remote_interfaces), | 152 shell::mojom::Shell::kInvalidApplicationID, params->user_id(), |
| 151 std::move(local_request), allowed)); | 153 std::move(remote_interfaces), std::move(local_request), allowed)); |
| 152 shell_->Connect(application_url, | 154 shell_->Connect(application_url, |
| 155 params->user_id(), |
| 153 std::move(remote_request), | 156 std::move(remote_request), |
| 154 std::move(local_interfaces), | 157 std::move(local_interfaces), |
| 155 params->TakeFilter(), | 158 params->TakeFilter(), |
| 156 registry->GetConnectCallback()); | 159 registry->GetConnectCallback()); |
| 157 return std::move(registry); | 160 return std::move(registry); |
| 158 } | 161 } |
| 159 | 162 |
| 160 void ShellConnection::Quit() { | 163 void ShellConnection::Quit() { |
| 161 // We can't quit immediately, since there could be in-flight requests from the | 164 // We can't quit immediately, since there could be in-flight requests from the |
| 162 // shell. So check with it first. | 165 // shell. So check with it first. |
| 163 if (shell_) { | 166 if (shell_) { |
| 164 quit_requested_ = true; | 167 quit_requested_ = true; |
| 165 shell_->QuitApplication(); | 168 shell_->QuitApplication(); |
| 166 } else { | 169 } else { |
| 167 QuitNow(); | 170 QuitNow(); |
| 168 } | 171 } |
| 169 } | 172 } |
| 170 | 173 |
| 171 scoped_ptr<AppRefCount> ShellConnection::CreateAppRefCount() { | 174 scoped_ptr<AppRefCount> ShellConnection::CreateAppRefCount() { |
| 172 AddRef(); | 175 AddRef(); |
| 173 return make_scoped_ptr( | 176 return make_scoped_ptr( |
| 174 new AppRefCountImpl(this, base::MessageLoop::current()->task_runner())); | 177 new AppRefCountImpl(this, base::MessageLoop::current()->task_runner())); |
| 175 } | 178 } |
| 176 | 179 |
| 177 //////////////////////////////////////////////////////////////////////////////// | 180 //////////////////////////////////////////////////////////////////////////////// |
| 178 // ShellConnection, shell::mojom::ShellClient implementation: | 181 // ShellConnection, shell::mojom::ShellClient implementation: |
| 179 | 182 |
| 180 void ShellConnection::Initialize(shell::mojom::ShellPtr shell, | 183 void ShellConnection::Initialize(shell::mojom::ShellPtr shell, |
| 181 const mojo::String& url, | 184 const mojo::String& url, |
| 182 uint32_t id) { | 185 uint32_t id, |
| 186 uint32_t user_id) { |
| 183 shell_ = std::move(shell); | 187 shell_ = std::move(shell); |
| 184 shell_.set_connection_error_handler([this]() { OnConnectionError(); }); | 188 shell_.set_connection_error_handler([this]() { OnConnectionError(); }); |
| 185 client_->Initialize(this, url, id); | 189 client_->Initialize(this, url, id, user_id); |
| 186 } | 190 } |
| 187 | 191 |
| 188 void ShellConnection::AcceptConnection( | 192 void ShellConnection::AcceptConnection( |
| 189 const String& requestor_url, | 193 const String& requestor_url, |
| 190 uint32_t requestor_id, | 194 uint32_t requestor_id, |
| 195 uint32_t requestor_user_id, |
| 191 shell::mojom::InterfaceProviderRequest local_interfaces, | 196 shell::mojom::InterfaceProviderRequest local_interfaces, |
| 192 shell::mojom::InterfaceProviderPtr remote_interfaces, | 197 shell::mojom::InterfaceProviderPtr remote_interfaces, |
| 193 Array<String> allowed_interfaces, | 198 Array<String> allowed_interfaces, |
| 194 const String& url) { | 199 const String& url) { |
| 195 scoped_ptr<Connection> registry(new internal::ConnectionImpl( | 200 scoped_ptr<Connection> registry(new internal::ConnectionImpl( |
| 196 url, requestor_url, requestor_id, std::move(remote_interfaces), | 201 url, requestor_url, requestor_id, requestor_user_id, |
| 197 std::move(local_interfaces), | 202 std::move(remote_interfaces), std::move(local_interfaces), |
| 198 allowed_interfaces.To<std::set<std::string>>())); | 203 allowed_interfaces.To<std::set<std::string>>())); |
| 199 if (!client_->AcceptConnection(registry.get())) | 204 if (!client_->AcceptConnection(registry.get())) |
| 200 return; | 205 return; |
| 201 | 206 |
| 202 // If we were quitting because we thought there were no more interfaces for | 207 // If we were quitting because we thought there were no more interfaces for |
| 203 // this app in use, then that has changed so cancel the quit request. | 208 // this app in use, then that has changed so cancel the quit request. |
| 204 if (quit_requested_) | 209 if (quit_requested_) |
| 205 quit_requested_ = false; | 210 quit_requested_ = false; |
| 206 | 211 |
| 207 incoming_connections_.push_back(std::move(registry)); | 212 incoming_connections_.push_back(std::move(registry)); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 shell::mojom::CapabilityFilterPtr CreatePermissiveCapabilityFilter() { | 263 shell::mojom::CapabilityFilterPtr CreatePermissiveCapabilityFilter() { |
| 259 shell::mojom::CapabilityFilterPtr filter( | 264 shell::mojom::CapabilityFilterPtr filter( |
| 260 shell::mojom::CapabilityFilter::New()); | 265 shell::mojom::CapabilityFilter::New()); |
| 261 Array<String> all_interfaces; | 266 Array<String> all_interfaces; |
| 262 all_interfaces.push_back("*"); | 267 all_interfaces.push_back("*"); |
| 263 filter->filter.insert("*", std::move(all_interfaces)); | 268 filter->filter.insert("*", std::move(all_interfaces)); |
| 264 return filter; | 269 return filter; |
| 265 } | 270 } |
| 266 | 271 |
| 267 } // namespace mojo | 272 } // namespace mojo |
| OLD | NEW |