| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "mojo/shell/test_package_manager.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "mojo/shell/fetcher.h" | |
| 9 #include "url/gurl.h" | |
| 10 | |
| 11 namespace mojo { | |
| 12 namespace shell { | |
| 13 | |
| 14 TestPackageManager::TestPackageManager() {} | |
| 15 TestPackageManager::~TestPackageManager() {} | |
| 16 | |
| 17 void TestPackageManager::RegisterContentHandler( | |
| 18 const std::string& mime_type, | |
| 19 const GURL& content_handler_url) { | |
| 20 DCHECK(content_handler_url.is_valid()) | |
| 21 << "Content handler URL is invalid for mime type " << mime_type; | |
| 22 mime_type_to_url_[mime_type] = content_handler_url; | |
| 23 } | |
| 24 | |
| 25 void TestPackageManager::SetApplicationManager(ApplicationManager* manager) { | |
| 26 } | |
| 27 | |
| 28 GURL TestPackageManager::ResolveURL(const GURL& url) { | |
| 29 return url; | |
| 30 } | |
| 31 | |
| 32 void TestPackageManager::FetchRequest( | |
| 33 URLRequestPtr request, | |
| 34 const Fetcher::FetchCallback& loader_callback) {} | |
| 35 | |
| 36 bool TestPackageManager::HandleWithContentHandler( | |
| 37 Fetcher* fetcher, | |
| 38 const GURL& unresolved_url, | |
| 39 base::TaskRunner* task_runner, | |
| 40 URLResponsePtr* new_response, | |
| 41 GURL* content_handler_url, | |
| 42 std::string* qualifier) { | |
| 43 MimeTypeToURLMap::iterator iter = mime_type_to_url_.find(fetcher->MimeType()); | |
| 44 if (iter != mime_type_to_url_.end()) { | |
| 45 *new_response = fetcher->AsURLResponse(task_runner, 0); | |
| 46 *content_handler_url = iter->second; | |
| 47 *qualifier = (*new_response)->site.To<std::string>(); | |
| 48 return true; | |
| 49 } | |
| 50 return false; | |
| 51 } | |
| 52 | |
| 53 } // namespace shell | |
| 54 } // namespace mojo | |
| OLD | NEW |