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/logging.h" | 8 #include "base/logging.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 fetcher->AsURLResponse(blocking_pool_, 0)); | 281 fetcher->AsURLResponse(blocking_pool_, 0)); |
282 return; | 282 return; |
283 } | 283 } |
284 | 284 |
285 // TODO(aa): Sanity check that the thing we got looks vaguely like a mojo | 285 // TODO(aa): Sanity check that the thing we got looks vaguely like a mojo |
286 // application. That could either mean looking for the platform-specific dll | 286 // application. That could either mean looking for the platform-specific dll |
287 // header, or looking for some specific mojo signature prepended to the | 287 // header, or looking for some specific mojo signature prepended to the |
288 // library. | 288 // library. |
289 // TODO(vtl): (Maybe this should be done by the factory/runner?) | 289 // TODO(vtl): (Maybe this should be done by the factory/runner?) |
290 | 290 |
| 291 GURL base_resolved_url = GetBaseURLAndQuery(fetcher->GetURL(), nullptr); |
291 NativeRunnerFactory::Options options; | 292 NativeRunnerFactory::Options options; |
292 if (url_to_native_options_.find(fetcher->GetURL()) != | 293 if (url_to_native_options_.find(base_resolved_url) != |
293 url_to_native_options_.end()) { | 294 url_to_native_options_.end()) { |
294 DVLOG(2) << "Applying stored native options to resolved URL " | 295 DVLOG(2) << "Applying stored native options to resolved URL " |
295 << fetcher->GetURL() << " (requested URL " << requested_url << ")"; | 296 << fetcher->GetURL() << " (requested URL " << requested_url << ")"; |
296 options = url_to_native_options_[fetcher->GetURL()]; | 297 options = url_to_native_options_[base_resolved_url]; |
297 } | 298 } |
298 | 299 |
299 fetcher->AsPath( | 300 fetcher->AsPath( |
300 blocking_pool_, | 301 blocking_pool_, |
301 base::Bind(&ApplicationManager::RunNativeApplication, | 302 base::Bind(&ApplicationManager::RunNativeApplication, |
302 weak_ptr_factory_.GetWeakPtr(), base::Passed(request.Pass()), | 303 weak_ptr_factory_.GetWeakPtr(), base::Passed(request.Pass()), |
303 options, cleanup_behavior, base::Passed(fetcher.Pass()))); | 304 options, cleanup_behavior, base::Passed(fetcher.Pass()))); |
304 } | 305 } |
305 | 306 |
306 void ApplicationManager::RunNativeApplication( | 307 void ApplicationManager::RunNativeApplication( |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 } | 387 } |
387 | 388 |
388 void ApplicationManager::SetArgsForURL(const std::vector<std::string>& args, | 389 void ApplicationManager::SetArgsForURL(const std::vector<std::string>& args, |
389 const GURL& url) { | 390 const GURL& url) { |
390 url_to_args_[url] = args; | 391 url_to_args_[url] = args; |
391 } | 392 } |
392 | 393 |
393 void ApplicationManager::SetNativeOptionsForURL( | 394 void ApplicationManager::SetNativeOptionsForURL( |
394 const NativeRunnerFactory::Options& options, | 395 const NativeRunnerFactory::Options& options, |
395 const GURL& url) { | 396 const GURL& url) { |
| 397 DCHECK(!url.has_query()); // Precondition. |
396 // Apply mappings and resolution to get the resolved URL. | 398 // Apply mappings and resolution to get the resolved URL. |
397 GURL resolved_url = delegate_->ResolveURL(delegate_->ResolveMappings(url)); | 399 GURL resolved_url = delegate_->ResolveURL(delegate_->ResolveMappings(url)); |
| 400 DCHECK(!resolved_url.has_query()); // Still shouldn't have query. |
398 // TODO(vtl): We should probably also remove/disregard the query string (and | 401 // TODO(vtl): We should probably also remove/disregard the query string (and |
399 // maybe canonicalize in other ways). | 402 // maybe canonicalize in other ways). |
400 DVLOG(2) << "Storing native options for resolved URL " << resolved_url | 403 DVLOG(2) << "Storing native options for resolved URL " << resolved_url |
401 << " (original URL " << url << ")"; | 404 << " (original URL " << url << ")"; |
402 url_to_native_options_[resolved_url] = options; | 405 url_to_native_options_[resolved_url] = options; |
403 } | 406 } |
404 | 407 |
405 ApplicationLoader* ApplicationManager::GetLoaderForURL(const GURL& url) { | 408 ApplicationLoader* ApplicationManager::GetLoaderForURL(const GURL& url) { |
406 auto url_it = url_to_loader_.find(GetBaseURLAndQuery(url, nullptr)); | 409 auto url_it = url_to_loader_.find(GetBaseURLAndQuery(url, nullptr)); |
407 if (url_it != url_to_loader_.end()) | 410 if (url_it != url_to_loader_.end()) |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 return Array<String>(); | 454 return Array<String>(); |
452 } | 455 } |
453 | 456 |
454 void ApplicationManager::CleanupRunner(NativeRunner* runner) { | 457 void ApplicationManager::CleanupRunner(NativeRunner* runner) { |
455 native_runners_.erase( | 458 native_runners_.erase( |
456 std::find(native_runners_.begin(), native_runners_.end(), runner)); | 459 std::find(native_runners_.begin(), native_runners_.end(), runner)); |
457 } | 460 } |
458 | 461 |
459 } // namespace shell | 462 } // namespace shell |
460 } // namespace mojo | 463 } // namespace mojo |
OLD | NEW |