| 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 "content/browser/mojo/mojo_shell_context.h" | 5 #include "content/browser/mojo/mojo_shell_context.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 : shell_context_(shell_context), | 152 : shell_context_(shell_context), |
| 153 task_runner_(base::ThreadTaskRunnerHandle::Get()) {} | 153 task_runner_(base::ThreadTaskRunnerHandle::Get()) {} |
| 154 | 154 |
| 155 ~Proxy() {} | 155 ~Proxy() {} |
| 156 | 156 |
| 157 void ConnectToApplication( | 157 void ConnectToApplication( |
| 158 const GURL& url, | 158 const GURL& url, |
| 159 const GURL& requestor_url, | 159 const GURL& requestor_url, |
| 160 mojo::shell::mojom::InterfaceProviderRequest request, | 160 mojo::shell::mojom::InterfaceProviderRequest request, |
| 161 mojo::shell::mojom::InterfaceProviderPtr exposed_services, | 161 mojo::shell::mojom::InterfaceProviderPtr exposed_services, |
| 162 const mojo::shell::CapabilityFilter& filter, | |
| 163 const mojo::shell::mojom::Connector::ConnectCallback& callback) { | 162 const mojo::shell::mojom::Connector::ConnectCallback& callback) { |
| 164 if (task_runner_ == base::ThreadTaskRunnerHandle::Get()) { | 163 if (task_runner_ == base::ThreadTaskRunnerHandle::Get()) { |
| 165 if (shell_context_) { | 164 if (shell_context_) { |
| 166 shell_context_->ConnectToApplicationOnOwnThread( | 165 shell_context_->ConnectToApplicationOnOwnThread( |
| 167 url, requestor_url, std::move(request), std::move(exposed_services), | 166 url, requestor_url, std::move(request), std::move(exposed_services), |
| 168 filter, callback); | 167 callback); |
| 169 } | 168 } |
| 170 } else { | 169 } else { |
| 171 // |shell_context_| outlives the main MessageLoop, so it's safe for it to | 170 // |shell_context_| outlives the main MessageLoop, so it's safe for it to |
| 172 // be unretained here. | 171 // be unretained here. |
| 173 task_runner_->PostTask( | 172 task_runner_->PostTask( |
| 174 FROM_HERE, | 173 FROM_HERE, |
| 175 base::Bind(&MojoShellContext::ConnectToApplicationOnOwnThread, | 174 base::Bind(&MojoShellContext::ConnectToApplicationOnOwnThread, |
| 176 base::Unretained(shell_context_), url, requestor_url, | 175 base::Unretained(shell_context_), url, requestor_url, |
| 177 base::Passed(&request), base::Passed(&exposed_services), | 176 base::Passed(&request), base::Passed(&exposed_services), |
| 178 filter, callback)); | 177 callback)); |
| 179 } | 178 } |
| 180 } | 179 } |
| 181 | 180 |
| 182 private: | 181 private: |
| 183 MojoShellContext* shell_context_; | 182 MojoShellContext* shell_context_; |
| 184 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 183 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 185 | 184 |
| 186 DISALLOW_COPY_AND_ASSIGN(Proxy); | 185 DISALLOW_COPY_AND_ASSIGN(Proxy); |
| 187 }; | 186 }; |
| 188 | 187 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 | 253 |
| 255 MojoShellContext::~MojoShellContext() { | 254 MojoShellContext::~MojoShellContext() { |
| 256 } | 255 } |
| 257 | 256 |
| 258 // static | 257 // static |
| 259 void MojoShellContext::ConnectToApplication( | 258 void MojoShellContext::ConnectToApplication( |
| 260 const GURL& url, | 259 const GURL& url, |
| 261 const GURL& requestor_url, | 260 const GURL& requestor_url, |
| 262 mojo::shell::mojom::InterfaceProviderRequest request, | 261 mojo::shell::mojom::InterfaceProviderRequest request, |
| 263 mojo::shell::mojom::InterfaceProviderPtr exposed_services, | 262 mojo::shell::mojom::InterfaceProviderPtr exposed_services, |
| 264 const mojo::shell::CapabilityFilter& filter, | |
| 265 const mojo::shell::mojom::Connector::ConnectCallback& callback) { | 263 const mojo::shell::mojom::Connector::ConnectCallback& callback) { |
| 266 proxy_.Get()->ConnectToApplication(url, requestor_url, std::move(request), | 264 proxy_.Get()->ConnectToApplication(url, requestor_url, std::move(request), |
| 267 std::move(exposed_services), filter, | 265 std::move(exposed_services), callback); |
| 268 callback); | |
| 269 } | 266 } |
| 270 | 267 |
| 271 void MojoShellContext::ConnectToApplicationOnOwnThread( | 268 void MojoShellContext::ConnectToApplicationOnOwnThread( |
| 272 const GURL& url, | 269 const GURL& url, |
| 273 const GURL& requestor_url, | 270 const GURL& requestor_url, |
| 274 mojo::shell::mojom::InterfaceProviderRequest request, | 271 mojo::shell::mojom::InterfaceProviderRequest request, |
| 275 mojo::shell::mojom::InterfaceProviderPtr exposed_services, | 272 mojo::shell::mojom::InterfaceProviderPtr exposed_services, |
| 276 const mojo::shell::CapabilityFilter& filter, | |
| 277 const mojo::shell::mojom::Connector::ConnectCallback& callback) { | 273 const mojo::shell::mojom::Connector::ConnectCallback& callback) { |
| 278 scoped_ptr<mojo::shell::ConnectParams> params(new mojo::shell::ConnectParams); | 274 scoped_ptr<mojo::shell::ConnectParams> params(new mojo::shell::ConnectParams); |
| 279 // TODO(beng): kUserRoot is obviously wrong. | 275 // TODO(beng): kUserRoot is obviously wrong. |
| 280 params->set_source( | 276 // TODO(beng): We need to set a permissive filter here temporarily because |
| 281 mojo::shell::Identity(requestor_url, std::string(), | 277 // content is known as a bogus system: URL that the application |
| 282 mojo::shell::mojom::Connector::kUserRoot, | 278 // manager doesn't understand. |
| 283 mojo::shell::GetPermissiveCapabilityFilter())); | 279 mojo::shell::Identity source_id( |
| 280 requestor_url, std::string(), mojo::shell::mojom::Connector::kUserRoot); |
| 281 source_id.SetFilter(mojo::shell::GetPermissiveCapabilityFilter()); |
| 282 params->set_source(source_id); |
| 284 params->set_target(mojo::shell::Identity( | 283 params->set_target(mojo::shell::Identity( |
| 285 url, std::string(), mojo::shell::mojom::Connector::kUserRoot, filter)); | 284 url, std::string(), mojo::shell::mojom::Connector::kUserRoot)); |
| 286 params->set_remote_interfaces(std::move(request)); | 285 params->set_remote_interfaces(std::move(request)); |
| 287 params->set_local_interfaces(std::move(exposed_services)); | 286 params->set_local_interfaces(std::move(exposed_services)); |
| 288 params->set_connect_callback(callback); | 287 params->set_connect_callback(callback); |
| 289 application_manager_->Connect(std::move(params)); | 288 application_manager_->Connect(std::move(params)); |
| 290 } | 289 } |
| 291 | 290 |
| 292 } // namespace content | 291 } // namespace content |
| OLD | NEW |