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 "mojo/shell/application_manager.h" | 5 #include "mojo/shell/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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
306 return; | 306 return; |
307 } | 307 } |
308 | 308 |
309 MimeTypeToURLMap::iterator iter = mime_type_to_url_.find(fetcher->MimeType()); | 309 MimeTypeToURLMap::iterator iter = mime_type_to_url_.find(fetcher->MimeType()); |
310 if (iter != mime_type_to_url_.end()) { | 310 if (iter != mime_type_to_url_.end()) { |
311 LoadWithContentHandler(iter->second, request.Pass(), | 311 LoadWithContentHandler(iter->second, request.Pass(), |
312 fetcher->AsURLResponse(blocking_pool_, 0)); | 312 fetcher->AsURLResponse(blocking_pool_, 0)); |
313 return; | 313 return; |
314 } | 314 } |
315 | 315 |
316 auto redirect_iter = application_package_redirect_.find(app_url); | |
317 if (redirect_iter != application_package_redirect_.end()) { | |
318 URLResponsePtr response(URLResponse::New()); | |
319 response->url = String::From(app_url.spec()); | |
320 LoadWithContentHandler(redirect_iter->second, | |
sky
2015/04/30 21:59:08
Doing it like you have here means multiple calls t
Elliot Glaysher
2015/05/01 17:00:04
I don't believe this is the case. Above, RegisterS
| |
321 request.Pass(), | |
322 response.Pass()); | |
323 return; | |
324 } | |
325 | |
316 // TODO(aa): Sanity check that the thing we got looks vaguely like a mojo | 326 // TODO(aa): Sanity check that the thing we got looks vaguely like a mojo |
317 // application. That could either mean looking for the platform-specific dll | 327 // application. That could either mean looking for the platform-specific dll |
318 // header, or looking for some specific mojo signature prepended to the | 328 // header, or looking for some specific mojo signature prepended to the |
319 // library. | 329 // library. |
320 // TODO(vtl): (Maybe this should be done by the factory/runner?) | 330 // TODO(vtl): (Maybe this should be done by the factory/runner?) |
321 | 331 |
322 GURL base_resolved_url = GetBaseURLAndQuery(fetcher->GetURL(), nullptr); | 332 GURL base_resolved_url = GetBaseURLAndQuery(fetcher->GetURL(), nullptr); |
323 NativeRunnerFactory::Options options; | 333 NativeRunnerFactory::Options options; |
324 if (url_to_native_options_.find(base_resolved_url) != | 334 if (url_to_native_options_.find(base_resolved_url) != |
325 url_to_native_options_.end()) { | 335 url_to_native_options_.end()) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
363 } | 373 } |
364 | 374 |
365 void ApplicationManager::RegisterContentHandler( | 375 void ApplicationManager::RegisterContentHandler( |
366 const std::string& mime_type, | 376 const std::string& mime_type, |
367 const GURL& content_handler_url) { | 377 const GURL& content_handler_url) { |
368 DCHECK(content_handler_url.is_valid()) | 378 DCHECK(content_handler_url.is_valid()) |
369 << "Content handler URL is invalid for mime type " << mime_type; | 379 << "Content handler URL is invalid for mime type " << mime_type; |
370 mime_type_to_url_[mime_type] = content_handler_url; | 380 mime_type_to_url_[mime_type] = content_handler_url; |
371 } | 381 } |
372 | 382 |
383 | |
384 void ApplicationManager::RegisterApplicationPackageRedirect( | |
385 const GURL& alias, | |
386 const GURL& content_handler_package) { | |
387 application_package_redirect_[alias] = content_handler_package; | |
388 } | |
389 | |
373 void ApplicationManager::LoadWithContentHandler( | 390 void ApplicationManager::LoadWithContentHandler( |
374 const GURL& content_handler_url, | 391 const GURL& content_handler_url, |
375 InterfaceRequest<Application> application_request, | 392 InterfaceRequest<Application> application_request, |
376 URLResponsePtr url_response) { | 393 URLResponsePtr url_response) { |
377 ContentHandlerConnection* connection = nullptr; | 394 ContentHandlerConnection* connection = nullptr; |
378 URLToContentHandlerMap::iterator iter = | 395 URLToContentHandlerMap::iterator iter = |
379 url_to_content_handler_.find(content_handler_url); | 396 url_to_content_handler_.find(content_handler_url); |
380 if (iter != url_to_content_handler_.end()) { | 397 if (iter != url_to_content_handler_.end()) { |
381 connection = iter->second; | 398 connection = iter->second; |
382 } else { | 399 } else { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
464 return pipe.handle0.Pass(); | 481 return pipe.handle0.Pass(); |
465 } | 482 } |
466 | 483 |
467 void ApplicationManager::CleanupRunner(NativeRunner* runner) { | 484 void ApplicationManager::CleanupRunner(NativeRunner* runner) { |
468 native_runners_.erase( | 485 native_runners_.erase( |
469 std::find(native_runners_.begin(), native_runners_.end(), runner)); | 486 std::find(native_runners_.begin(), native_runners_.end(), runner)); |
470 } | 487 } |
471 | 488 |
472 } // namespace shell | 489 } // namespace shell |
473 } // namespace mojo | 490 } // namespace mojo |
OLD | NEW |