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 "shell/application_manager/application_manager.h" | 5 #include "shell/application_manager/application_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 | 178 |
179 if (resolved_url.SchemeIsFile()) { | 179 if (resolved_url.SchemeIsFile()) { |
180 new LocalFetcher(resolved_url, GetBaseURLAndQuery(resolved_url, nullptr), | 180 new LocalFetcher(resolved_url, GetBaseURLAndQuery(resolved_url, nullptr), |
181 callback); | 181 callback); |
182 return; | 182 return; |
183 } | 183 } |
184 | 184 |
185 if (!url_response_disk_cache_) { | 185 if (!url_response_disk_cache_) { |
186 ConnectToService(GURL("mojo:url_response_disk_cache"), | 186 ConnectToService(GURL("mojo:url_response_disk_cache"), |
187 &url_response_disk_cache_); | 187 &url_response_disk_cache_); |
| 188 ConnectToService(GURL("mojo:network_service"), &network_service_); |
| 189 ConnectToService(GURL("mojo:network_service"), |
| 190 &authenticating_network_service_); |
188 } | 191 } |
189 | 192 |
190 if (!network_service_) { | 193 mojo::NetworkService* network_service = authenticating_network_service_.get(); |
191 ConnectToService(GURL("mojo:network_service"), &network_service_); | |
192 } | |
193 | 194 |
194 // NOTE: Attempting to initialize the apps used authentication for while | 195 // NOTE: Attempting to initialize the apps used authentication for while |
195 // connecting to those apps would result in a recursive loop, so it has to be | 196 // connecting to those apps would result in a recursive loop, so it has to be |
196 // explicitly avoided here. What this means in practice is that these apps | 197 // explicitly avoided here. What this means in practice is that these apps |
197 // cannot themselves require authentication to obtain. | 198 // cannot themselves require authentication to obtain. |
198 if (!initialized_authentication_interceptor_ && | 199 if (EndsWith(resolved_url.path(), "/authentication.mojo", true) || |
199 !EndsWith(resolved_url.path(), "/authentication.mojo", true) && | 200 EndsWith(resolved_url.path(), |
200 !EndsWith(resolved_url.path(), | 201 "/authenticating_url_loader_interceptor.mojo", true)) { |
201 "/authenticating_url_loader_interceptor.mojo", true)) { | 202 network_service = network_service_.get(); |
| 203 } else if (!initialized_authentication_interceptor_) { |
202 authentication::AuthenticationServicePtr authentication_service; | 204 authentication::AuthenticationServicePtr authentication_service; |
203 ConnectToService(GURL("mojo:authentication"), &authentication_service); | 205 ConnectToService(GURL("mojo:authentication"), &authentication_service); |
204 mojo::AuthenticatingURLLoaderInterceptorMetaFactoryPtr | 206 mojo::AuthenticatingURLLoaderInterceptorMetaFactoryPtr |
205 interceptor_meta_factory; | 207 interceptor_meta_factory; |
206 ConnectToService(GURL("mojo:authenticating_url_loader_interceptor"), | 208 ConnectToService(GURL("mojo:authenticating_url_loader_interceptor"), |
207 &interceptor_meta_factory); | 209 &interceptor_meta_factory); |
208 mojo::URLLoaderInterceptorFactoryPtr interceptor_factory; | 210 mojo::URLLoaderInterceptorFactoryPtr interceptor_factory; |
209 interceptor_meta_factory->CreateURLLoaderInterceptorFactory( | 211 interceptor_meta_factory->CreateURLLoaderInterceptorFactory( |
210 GetProxy(&interceptor_factory), authentication_service.Pass()); | 212 GetProxy(&interceptor_factory), authentication_service.Pass()); |
211 network_service_->RegisterURLLoaderInterceptor(interceptor_factory.Pass()); | 213 authenticating_network_service_->RegisterURLLoaderInterceptor( |
| 214 interceptor_factory.Pass()); |
212 initialized_authentication_interceptor_ = true; | 215 initialized_authentication_interceptor_ = true; |
213 } | 216 } |
214 | 217 |
215 new NetworkFetcher(options_.disable_cache, resolved_url, | 218 new NetworkFetcher(options_.disable_cache, resolved_url, |
216 url_response_disk_cache_.get(), network_service_.get(), | 219 url_response_disk_cache_.get(), network_service, callback); |
217 callback); | |
218 } | 220 } |
219 | 221 |
220 bool ApplicationManager::ConnectToRunningApplication( | 222 bool ApplicationManager::ConnectToRunningApplication( |
221 const GURL& resolved_url, | 223 const GURL& resolved_url, |
222 const GURL& requestor_url, | 224 const GURL& requestor_url, |
223 InterfaceRequest<ServiceProvider>* services, | 225 InterfaceRequest<ServiceProvider>* services, |
224 ServiceProviderPtr* exposed_services) { | 226 ServiceProviderPtr* exposed_services) { |
225 GURL application_url = GetBaseURLAndQuery(resolved_url, nullptr); | 227 GURL application_url = GetBaseURLAndQuery(resolved_url, nullptr); |
226 ShellImpl* shell_impl = GetShellImpl(application_url); | 228 ShellImpl* shell_impl = GetShellImpl(application_url); |
227 if (!shell_impl) | 229 if (!shell_impl) |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 return args_it->second; | 510 return args_it->second; |
509 return std::vector<std::string>(); | 511 return std::vector<std::string>(); |
510 } | 512 } |
511 | 513 |
512 void ApplicationManager::CleanupRunner(NativeRunner* runner) { | 514 void ApplicationManager::CleanupRunner(NativeRunner* runner) { |
513 native_runners_.erase( | 515 native_runners_.erase( |
514 std::find(native_runners_.begin(), native_runners_.end(), runner)); | 516 std::find(native_runners_.begin(), native_runners_.end(), runner)); |
515 } | 517 } |
516 | 518 |
517 } // namespace shell | 519 } // namespace shell |
OLD | NEW |