| 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/mojo_url_resolver.h" | 5 #include "mojo/shell/mojo_url_resolver.h" |
| 6 | 6 |
| 7 #include "base/base_paths.h" | 7 #include "base/base_paths.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "net/base/filename_util.h" | 11 #include "mojo/shell/filename_util.h" |
| 12 #include "url/url_util.h" | 12 #include "url/url_util.h" |
| 13 | 13 |
| 14 namespace mojo { | 14 namespace mojo { |
| 15 namespace shell { | 15 namespace shell { |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 std::string MakeSharedLibraryName(const std::string& host_name) { | 18 std::string MakeSharedLibraryName(const std::string& host_name) { |
| 19 #if defined(OS_WIN) | 19 #if defined(OS_WIN) |
| 20 return host_name + ".dll"; | 20 return host_name + ".dll"; |
| 21 #elif defined(OS_LINUX) || defined(OS_ANDROID) | 21 #elif defined(OS_LINUX) || defined(OS_ANDROID) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 } // namespace | 41 } // namespace |
| 42 | 42 |
| 43 MojoURLResolver::MojoURLResolver() { | 43 MojoURLResolver::MojoURLResolver() { |
| 44 // Needed to treat first component of mojo URLs as host, not path. | 44 // Needed to treat first component of mojo URLs as host, not path. |
| 45 url::AddStandardScheme("mojo"); | 45 url::AddStandardScheme("mojo"); |
| 46 | 46 |
| 47 // By default, resolve mojo URLs to files living alongside the shell. | 47 // By default, resolve mojo URLs to files living alongside the shell. |
| 48 base::FilePath path; | 48 base::FilePath path; |
| 49 PathService::Get(base::DIR_MODULE, &path); | 49 PathService::Get(base::DIR_MODULE, &path); |
| 50 default_base_url_ = AddTrailingSlashIfNeeded(net::FilePathToFileURL(path)); | 50 default_base_url_ = AddTrailingSlashIfNeeded(FilePathToFileURL(path)); |
| 51 } | 51 } |
| 52 | 52 |
| 53 MojoURLResolver::~MojoURLResolver() { | 53 MojoURLResolver::~MojoURLResolver() { |
| 54 } | 54 } |
| 55 | 55 |
| 56 void MojoURLResolver::SetBaseURL(const GURL& base_url) { | 56 void MojoURLResolver::SetBaseURL(const GURL& base_url) { |
| 57 DCHECK(base_url.is_valid()); | 57 DCHECK(base_url.is_valid()); |
| 58 // Force a trailing slash on the base_url to simplify resolving | 58 // Force a trailing slash on the base_url to simplify resolving |
| 59 // relative files and URLs below. | 59 // relative files and URLs below. |
| 60 base_url_ = AddTrailingSlashIfNeeded(base_url); | 60 base_url_ = AddTrailingSlashIfNeeded(base_url); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 std::map<GURL, GURL>::const_iterator it = url_map_.find(mapped_url); | 94 std::map<GURL, GURL>::const_iterator it = url_map_.find(mapped_url); |
| 95 if (it == url_map_.end()) | 95 if (it == url_map_.end()) |
| 96 break; | 96 break; |
| 97 mapped_url = it->second; | 97 mapped_url = it->second; |
| 98 } | 98 } |
| 99 return mapped_url; | 99 return mapped_url; |
| 100 } | 100 } |
| 101 | 101 |
| 102 } // namespace shell | 102 } // namespace shell |
| 103 } // namespace mojo | 103 } // namespace mojo |
| OLD | NEW |