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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 } | 121 } |
122 | 122 |
123 void ApplicationManager::TerminateShellConnections() { | 123 void ApplicationManager::TerminateShellConnections() { |
124 identity_to_shell_impl_.clear(); | 124 identity_to_shell_impl_.clear(); |
125 } | 125 } |
126 | 126 |
127 void ApplicationManager::ConnectToApplication( | 127 void ApplicationManager::ConnectToApplication( |
128 const GURL& requested_url, | 128 const GURL& requested_url, |
129 const GURL& requestor_url, | 129 const GURL& requestor_url, |
130 InterfaceRequest<ServiceProvider> services, | 130 InterfaceRequest<ServiceProvider> services, |
131 ServiceProviderPtr exposed_services, | 131 mojo::InterfaceHandle<ServiceProvider> exposed_services, |
132 const base::Closure& on_application_end) { | 132 const base::Closure& on_application_end) { |
133 ConnectToApplicationWithParameters( | 133 ConnectToApplicationWithParameters( |
134 requested_url, requestor_url, services.Pass(), exposed_services.Pass(), | 134 requested_url, requestor_url, services.Pass(), exposed_services.Pass(), |
135 on_application_end, std::vector<std::string>()); | 135 on_application_end, std::vector<std::string>()); |
136 } | 136 } |
137 | 137 |
138 void ApplicationManager::ConnectToApplicationWithParameters( | 138 void ApplicationManager::ConnectToApplicationWithParameters( |
139 const GURL& requested_url, | 139 const GURL& requested_url, |
140 const GURL& requestor_url, | 140 const GURL& requestor_url, |
141 InterfaceRequest<ServiceProvider> services, | 141 InterfaceRequest<ServiceProvider> services, |
142 ServiceProviderPtr exposed_services, | 142 mojo::InterfaceHandle<mojo::ServiceProvider> exposed_services, |
143 const base::Closure& on_application_end, | 143 const base::Closure& on_application_end, |
144 const std::vector<std::string>& pre_redirect_parameters) { | 144 const std::vector<std::string>& pre_redirect_parameters) { |
145 TRACE_EVENT_INSTANT2( | 145 TRACE_EVENT_INSTANT2( |
146 "mojo_shell", "ApplicationManager::ConnectToApplicationWithParameters", | 146 "mojo_shell", "ApplicationManager::ConnectToApplicationWithParameters", |
147 TRACE_EVENT_SCOPE_THREAD, "requested_url", requested_url.spec(), | 147 TRACE_EVENT_SCOPE_THREAD, "requested_url", requested_url.spec(), |
148 "requestor_url", requestor_url.spec()); | 148 "requestor_url", requestor_url.spec()); |
149 DCHECK(requested_url.is_valid()); | 149 DCHECK(requested_url.is_valid()); |
150 | 150 |
151 // We check both the mapped and resolved urls for existing shell_impls because | 151 // We check both the mapped and resolved urls for existing shell_impls because |
152 // external applications can be registered for the unresolved mojo:foo urls. | 152 // external applications can be registered for the unresolved mojo:foo urls. |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 | 236 |
237 new NetworkFetcher(options_.disable_cache, options_.force_offline_by_default, | 237 new NetworkFetcher(options_.disable_cache, options_.force_offline_by_default, |
238 resolved_url, url_response_disk_cache_.get(), | 238 resolved_url, url_response_disk_cache_.get(), |
239 network_service, callback); | 239 network_service, callback); |
240 } | 240 } |
241 | 241 |
242 bool ApplicationManager::ConnectToRunningApplication( | 242 bool ApplicationManager::ConnectToRunningApplication( |
243 const GURL& resolved_url, | 243 const GURL& resolved_url, |
244 const GURL& requestor_url, | 244 const GURL& requestor_url, |
245 InterfaceRequest<ServiceProvider>* services, | 245 InterfaceRequest<ServiceProvider>* services, |
246 ServiceProviderPtr* exposed_services) { | 246 mojo::InterfaceHandle<mojo::ServiceProvider>* exposed_services) { |
247 GURL application_url = GetBaseURLAndQuery(resolved_url, nullptr); | 247 GURL application_url = GetBaseURLAndQuery(resolved_url, nullptr); |
248 ShellImpl* shell_impl = GetShellImpl(application_url); | 248 ShellImpl* shell_impl = GetShellImpl(application_url); |
249 if (!shell_impl) | 249 if (!shell_impl) |
250 return false; | 250 return false; |
251 | 251 |
252 DCHECK(!GetNativeApplicationOptionsForURL(application_url) | 252 DCHECK(!GetNativeApplicationOptionsForURL(application_url) |
253 ->new_process_per_connection); | 253 ->new_process_per_connection); |
254 | 254 |
255 ConnectToClient(shell_impl, resolved_url, requestor_url, services->Pass(), | 255 ConnectToClient(shell_impl, resolved_url, requestor_url, services->Pass(), |
256 exposed_services->Pass()); | 256 exposed_services->Pass()); |
257 return true; | 257 return true; |
258 } | 258 } |
259 | 259 |
260 bool ApplicationManager::ConnectToApplicationWithLoader( | 260 bool ApplicationManager::ConnectToApplicationWithLoader( |
261 const GURL& resolved_url, | 261 const GURL& resolved_url, |
262 const GURL& requestor_url, | 262 const GURL& requestor_url, |
263 InterfaceRequest<ServiceProvider>* services, | 263 InterfaceRequest<ServiceProvider>* services, |
264 ServiceProviderPtr* exposed_services, | 264 mojo::InterfaceHandle<mojo::ServiceProvider>* exposed_services, |
265 const base::Closure& on_application_end, | 265 const base::Closure& on_application_end, |
266 const std::vector<std::string>& parameters, | 266 const std::vector<std::string>& parameters, |
267 ApplicationLoader* loader) { | 267 ApplicationLoader* loader) { |
268 if (!loader) | 268 if (!loader) |
269 return false; | 269 return false; |
270 | 270 |
271 loader->Load( | 271 loader->Load( |
272 resolved_url, | 272 resolved_url, |
273 RegisterShell(resolved_url, requestor_url, services->Pass(), | 273 RegisterShell(resolved_url, requestor_url, services->Pass(), |
274 exposed_services->Pass(), on_application_end, parameters)); | 274 exposed_services->Pass(), on_application_end, parameters)); |
(...skipping 10 matching lines...) Expand all Loading... |
285 ->new_process_per_connection; | 285 ->new_process_per_connection; |
286 return new_process_per_connection | 286 return new_process_per_connection |
287 ? Identity(url, base::Uint64ToString(unique_id_number++)) | 287 ? Identity(url, base::Uint64ToString(unique_id_number++)) |
288 : Identity(url); | 288 : Identity(url); |
289 } | 289 } |
290 | 290 |
291 InterfaceRequest<Application> ApplicationManager::RegisterShell( | 291 InterfaceRequest<Application> ApplicationManager::RegisterShell( |
292 const GURL& resolved_url, | 292 const GURL& resolved_url, |
293 const GURL& requestor_url, | 293 const GURL& requestor_url, |
294 InterfaceRequest<ServiceProvider> services, | 294 InterfaceRequest<ServiceProvider> services, |
295 ServiceProviderPtr exposed_services, | 295 mojo::InterfaceHandle<mojo::ServiceProvider> exposed_services, |
296 const base::Closure& on_application_end, | 296 const base::Closure& on_application_end, |
297 const std::vector<std::string>& parameters) { | 297 const std::vector<std::string>& parameters) { |
298 Identity app_identity = MakeApplicationIdentity(resolved_url); | 298 Identity app_identity = MakeApplicationIdentity(resolved_url); |
299 | 299 |
300 mojo::ApplicationPtr application; | 300 mojo::ApplicationPtr application; |
301 InterfaceRequest<Application> application_request = | 301 InterfaceRequest<Application> application_request = |
302 mojo::GetProxy(&application); | 302 mojo::GetProxy(&application); |
303 ShellImpl* shell = | 303 ShellImpl* shell = |
304 new ShellImpl(application.Pass(), this, app_identity, on_application_end); | 304 new ShellImpl(application.Pass(), this, app_identity, on_application_end); |
305 identity_to_shell_impl_[app_identity] = make_scoped_ptr(shell); | 305 identity_to_shell_impl_[app_identity] = make_scoped_ptr(shell); |
(...skipping 12 matching lines...) Expand all Loading... |
318 if (shell_it != identity_to_shell_impl_.end()) | 318 if (shell_it != identity_to_shell_impl_.end()) |
319 return shell_it->second.get(); | 319 return shell_it->second.get(); |
320 return nullptr; | 320 return nullptr; |
321 } | 321 } |
322 | 322 |
323 void ApplicationManager::ConnectToClient( | 323 void ApplicationManager::ConnectToClient( |
324 ShellImpl* shell_impl, | 324 ShellImpl* shell_impl, |
325 const GURL& resolved_url, | 325 const GURL& resolved_url, |
326 const GURL& requestor_url, | 326 const GURL& requestor_url, |
327 InterfaceRequest<ServiceProvider> services, | 327 InterfaceRequest<ServiceProvider> services, |
328 ServiceProviderPtr exposed_services) { | 328 mojo::InterfaceHandle<mojo::ServiceProvider> exposed_services) { |
329 shell_impl->ConnectToClient(resolved_url, requestor_url, services.Pass(), | 329 shell_impl->ConnectToClient(resolved_url, requestor_url, services.Pass(), |
330 exposed_services.Pass()); | 330 exposed_services.Pass()); |
331 } | 331 } |
332 | 332 |
333 void ApplicationManager::HandleFetchCallback( | 333 void ApplicationManager::HandleFetchCallback( |
334 const GURL& requestor_url, | 334 const GURL& requestor_url, |
335 InterfaceRequest<ServiceProvider> services, | 335 InterfaceRequest<ServiceProvider> services, |
336 ServiceProviderPtr exposed_services, | 336 mojo::InterfaceHandle<mojo::ServiceProvider> exposed_services, |
337 const base::Closure& on_application_end, | 337 const base::Closure& on_application_end, |
338 const std::vector<std::string>& parameters, | 338 const std::vector<std::string>& parameters, |
339 scoped_ptr<Fetcher> fetcher) { | 339 scoped_ptr<Fetcher> fetcher) { |
340 if (!fetcher) { | 340 if (!fetcher) { |
341 // Network error. Drop |application_request| to tell requestor. | 341 // Network error. Drop |application_request| to tell requestor. |
342 return; | 342 return; |
343 } | 343 } |
344 | 344 |
345 GURL redirect_url = fetcher->GetRedirectURL(); | 345 GURL redirect_url = fetcher->GetRedirectURL(); |
346 if (!redirect_url.is_empty()) { | 346 if (!redirect_url.is_empty()) { |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 return args_it->second; | 551 return args_it->second; |
552 return std::vector<std::string>(); | 552 return std::vector<std::string>(); |
553 } | 553 } |
554 | 554 |
555 void ApplicationManager::CleanupRunner(NativeRunner* runner) { | 555 void ApplicationManager::CleanupRunner(NativeRunner* runner) { |
556 native_runners_.erase( | 556 native_runners_.erase( |
557 std::find(native_runners_.begin(), native_runners_.end(), runner)); | 557 std::find(native_runners_.begin(), native_runners_.end(), runner)); |
558 } | 558 } |
559 | 559 |
560 } // namespace shell | 560 } // namespace shell |
OLD | NEW |