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 "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 Proxy(MojoShellContext* shell_context) | 91 Proxy(MojoShellContext* shell_context) |
92 : shell_context_(shell_context), | 92 : shell_context_(shell_context), |
93 task_runner_(base::ThreadTaskRunnerHandle::Get()) {} | 93 task_runner_(base::ThreadTaskRunnerHandle::Get()) {} |
94 | 94 |
95 ~Proxy() {} | 95 ~Proxy() {} |
96 | 96 |
97 void ConnectToApplication( | 97 void ConnectToApplication( |
98 const GURL& url, | 98 const GURL& url, |
99 const GURL& requestor_url, | 99 const GURL& requestor_url, |
100 mojo::InterfaceRequest<mojo::ServiceProvider> request, | 100 mojo::InterfaceRequest<mojo::ServiceProvider> request, |
101 mojo::ServiceProviderPtr exposed_services) { | 101 mojo::ServiceProviderPtr exposed_services, |
| 102 mojo::CapabilityFilterPtr filter) { |
102 if (task_runner_ == base::ThreadTaskRunnerHandle::Get()) { | 103 if (task_runner_ == base::ThreadTaskRunnerHandle::Get()) { |
103 if (shell_context_) { | 104 if (shell_context_) { |
104 shell_context_->ConnectToApplicationOnOwnThread( | 105 shell_context_->ConnectToApplicationOnOwnThread( |
105 url, requestor_url, request.Pass(), exposed_services.Pass()); | 106 url, requestor_url, request.Pass(), exposed_services.Pass(), |
| 107 filter.Pass()); |
106 } | 108 } |
107 } else { | 109 } else { |
108 // |shell_context_| outlives the main MessageLoop, so it's safe for it to | 110 // |shell_context_| outlives the main MessageLoop, so it's safe for it to |
109 // be unretained here. | 111 // be unretained here. |
110 task_runner_->PostTask( | 112 task_runner_->PostTask( |
111 FROM_HERE, | 113 FROM_HERE, |
112 base::Bind(&MojoShellContext::ConnectToApplicationOnOwnThread, | 114 base::Bind(&MojoShellContext::ConnectToApplicationOnOwnThread, |
113 base::Unretained(shell_context_), url, requestor_url, | 115 base::Unretained(shell_context_), url, requestor_url, |
114 base::Passed(&request), base::Passed(&exposed_services))); | 116 base::Passed(&request), base::Passed(&exposed_services), |
| 117 base::Passed(&filter))); |
115 } | 118 } |
116 } | 119 } |
117 | 120 |
118 private: | 121 private: |
119 MojoShellContext* shell_context_; | 122 MojoShellContext* shell_context_; |
120 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 123 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
121 | 124 |
122 DISALLOW_COPY_AND_ASSIGN(Proxy); | 125 DISALLOW_COPY_AND_ASSIGN(Proxy); |
123 }; | 126 }; |
124 | 127 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 } | 178 } |
176 | 179 |
177 MojoShellContext::~MojoShellContext() { | 180 MojoShellContext::~MojoShellContext() { |
178 } | 181 } |
179 | 182 |
180 // static | 183 // static |
181 void MojoShellContext::ConnectToApplication( | 184 void MojoShellContext::ConnectToApplication( |
182 const GURL& url, | 185 const GURL& url, |
183 const GURL& requestor_url, | 186 const GURL& requestor_url, |
184 mojo::InterfaceRequest<mojo::ServiceProvider> request, | 187 mojo::InterfaceRequest<mojo::ServiceProvider> request, |
185 mojo::ServiceProviderPtr exposed_services) { | 188 mojo::ServiceProviderPtr exposed_services, |
| 189 mojo::CapabilityFilterPtr filter) { |
186 proxy_.Get()->ConnectToApplication(url, requestor_url, request.Pass(), | 190 proxy_.Get()->ConnectToApplication(url, requestor_url, request.Pass(), |
187 exposed_services.Pass()); | 191 exposed_services.Pass(), filter.Pass()); |
188 } | 192 } |
189 | 193 |
190 void MojoShellContext::ConnectToApplicationOnOwnThread( | 194 void MojoShellContext::ConnectToApplicationOnOwnThread( |
191 const GURL& url, | 195 const GURL& url, |
192 const GURL& requestor_url, | 196 const GURL& requestor_url, |
193 mojo::InterfaceRequest<mojo::ServiceProvider> request, | 197 mojo::InterfaceRequest<mojo::ServiceProvider> request, |
194 mojo::ServiceProviderPtr exposed_services) { | 198 mojo::ServiceProviderPtr exposed_services, |
| 199 mojo::CapabilityFilterPtr filter) { |
195 mojo::URLRequestPtr url_request = mojo::URLRequest::New(); | 200 mojo::URLRequestPtr url_request = mojo::URLRequest::New(); |
196 url_request->url = mojo::String::From(url); | 201 url_request->url = mojo::String::From(url); |
197 application_manager_->ConnectToApplication( | 202 application_manager_->ConnectToApplication( |
198 url_request.Pass(), std::string(), requestor_url, request.Pass(), | 203 nullptr, url_request.Pass(), std::string(), requestor_url, request.Pass(), |
199 exposed_services.Pass(), base::Bind(&base::DoNothing)); | 204 exposed_services.Pass(), filter.Pass(), base::Bind(&base::DoNothing)); |
200 } | 205 } |
201 | 206 |
202 GURL MojoShellContext::ResolveMappings(const GURL& url) { | 207 GURL MojoShellContext::ResolveMappings(const GURL& url) { |
203 return url; | 208 return url; |
204 } | 209 } |
205 | 210 |
206 GURL MojoShellContext::ResolveMojoURL(const GURL& url) { | 211 GURL MojoShellContext::ResolveMojoURL(const GURL& url) { |
207 return url; | 212 return url; |
208 } | 213 } |
209 | 214 |
210 bool MojoShellContext::CreateFetcher( | 215 bool MojoShellContext::CreateFetcher( |
211 const GURL& url, | 216 const GURL& url, |
212 const mojo::shell::Fetcher::FetchCallback& loader_callback) { | 217 const mojo::shell::Fetcher::FetchCallback& loader_callback) { |
213 return false; | 218 return false; |
214 } | 219 } |
215 | 220 |
216 } // namespace content | 221 } // namespace content |
OLD | NEW |