Index: shell/mojo_url_resolver.cc |
diff --git a/shell/mojo_url_resolver.cc b/shell/mojo_url_resolver.cc |
index 1e77629a47259719688ce44784b499ff92a5bdb3..9e93aa1142763a71f68a09f947258f07670bf8e8 100644 |
--- a/shell/mojo_url_resolver.cc |
+++ b/shell/mojo_url_resolver.cc |
@@ -7,33 +7,15 @@ |
#include "base/base_paths.h" |
#include "base/files/file_path.h" |
#include "base/logging.h" |
-#include "base/path_service.h" |
#include "shell/filename_util.h" |
#include "url/url_util.h" |
namespace mojo { |
namespace shell { |
-namespace { |
- |
-GURL AddTrailingSlashIfNeeded(const GURL& url) { |
- if (!url.has_path() || *url.path().rbegin() == '/') |
- return url; |
- |
- std::string path(url.path() + '/'); |
- GURL::Replacements replacements; |
- replacements.SetPathStr(path); |
- return url.ReplaceComponents(replacements); |
-} |
- |
-} // namespace |
MojoURLResolver::MojoURLResolver() { |
// Needed to treat first component of mojo URLs as host, not path. |
url::AddStandardScheme("mojo"); |
- // By default assume that the local apps reside alongside the shell. |
- base::FilePath path; |
- PathService::Get(base::DIR_MODULE, &path); |
- local_apps_url_ = AddTrailingSlashIfNeeded(FilePathToFileURL(path)); |
} |
MojoURLResolver::~MojoURLResolver() { |
@@ -46,38 +28,22 @@ void MojoURLResolver::SetBaseURL(const GURL& base_url) { |
base_url_ = AddTrailingSlashIfNeeded(base_url); |
} |
-void MojoURLResolver::SetLocalAppsPath(const base::FilePath& local_apps_path) { |
- local_apps_url_ = |
- AddTrailingSlashIfNeeded(FilePathToFileURL(local_apps_path)); |
- DCHECK(local_apps_url_.is_valid()); |
-} |
- |
void MojoURLResolver::AddCustomMapping(const GURL& mojo_url, |
const GURL& resolved_url) { |
url_map_[mojo_url] = resolved_url; |
} |
-void MojoURLResolver::AddLocalFileMapping(const GURL& mojo_url) { |
- local_file_set_.insert(mojo_url); |
-} |
- |
GURL MojoURLResolver::Resolve(const GURL& mojo_url) const { |
const GURL mapped_url(ApplyCustomMappings(mojo_url)); |
- // Continue resolving if the mapped url is a mojo: url. |
- if (mapped_url.scheme() != "mojo") |
+ if (mapped_url.scheme() != "mojo") { |
+ // The mapping has produced some sort of non-mojo: URL - file:, http:, etc. |
return mapped_url; |
- |
- std::string lib = mapped_url.host() + ".mojo"; |
- |
- if (!base_url_.is_valid() || |
- local_file_set_.find(mapped_url) != local_file_set_.end()) { |
- // Resolve to a local file URL. |
- return local_apps_url_.Resolve(lib); |
+ } else { |
+ // It's still a mojo: URL, use the default mapping scheme. |
+ std::string lib = mapped_url.host() + ".mojo"; |
+ return base_url_.Resolve(lib); |
} |
- |
- // Otherwise, resolve to an URL relative to base_url_. |
- return base_url_.Resolve(lib); |
} |
GURL MojoURLResolver::ApplyCustomMappings(const GURL& url) const { |