Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Unified Diff: mojo/shell/url_resolver.cc

Issue 1109993002: Adds support for mojo apps to live in their own directory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rename Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: mojo/shell/url_resolver.cc
diff --git a/mojo/shell/url_resolver.cc b/mojo/shell/url_resolver.cc
index 20cb000893e5e609bdc6eda3ae095625a34192d6..7d4c8c270dd18f9b8405675d1614fd99d85400fa 100644
--- a/mojo/shell/url_resolver.cc
+++ b/mojo/shell/url_resolver.cc
@@ -6,6 +6,7 @@
#include "base/base_paths.h"
#include "base/files/file_path.h"
+#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/strings/utf_string_conversions.h"
#include "mojo/shell/application_manager/query_util.h"
@@ -105,13 +106,19 @@ GURL URLResolver::ResolveMojoURL(const GURL& mojo_url) const {
if (mojo_url.scheme() != "mojo") {
// The mapping has produced some sort of non-mojo: URL - file:, http:, etc.
return mojo_url;
- } else {
- // It's still a mojo: URL, use the default mapping scheme.
- std::string query;
- GURL base_url = GetBaseURLAndQuery(mojo_url, &query);
- std::string lib = base_url.host() + ".mojo" + query;
- return mojo_base_url_.Resolve(lib);
}
+
+ // It's still a mojo: URL, use the default mapping scheme.
+ std::string query;
+ GURL base_url = GetBaseURLAndQuery(mojo_url, &query);
+ if (mojo_base_url_.SchemeIsFile()) {
+ const GURL url_with_directory(
+ mojo_base_url_.Resolve(base_url.host() + "/"));
+ const base::FilePath file_path(UrlToFilePath(url_with_directory));
+ if (base::DirectoryExists(file_path))
+ return url_with_directory.Resolve(base_url.host() + ".mojo" + query);
+ }
+ return mojo_base_url_.Resolve(base_url.host() + ".mojo" + query);
}
} // namespace shell

Powered by Google App Engine
This is Rietveld 408576698