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

Unified Diff: mojo/runner/url_resolver.cc

Issue 1186683008: Revert of Build Mojo apps in subdirectories, like application packages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « mojo/runner/context.cc ('k') | mojo/runner/url_resolver_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/runner/url_resolver.cc
diff --git a/mojo/runner/url_resolver.cc b/mojo/runner/url_resolver.cc
index 3ae8bc01a097c769a8c4155471bde762a943243b..0dcf2f772b0cf569af257025e71f8cb9c39dba7d 100644
--- a/mojo/runner/url_resolver.cc
+++ b/mojo/runner/url_resolver.cc
@@ -5,6 +5,8 @@
#include "mojo/runner/url_resolver.h"
#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/runner/switches.h"
@@ -109,8 +111,20 @@
// It's still a mojo: URL, use the default mapping scheme.
std::string query;
GURL base_url = shell::GetBaseURLAndQuery(mojo_url, &query);
- const std::string host = base_url.host();
- return mojo_base_url_.Resolve(host + "/" + host + ".mojo" + query);
+ if (mojo_base_url_.SchemeIsFile()) {
+ const GURL url_with_directory(
+ mojo_base_url_.Resolve(base_url.host() + "/"));
+ const base::FilePath dir(util::UrlToFilePath(url_with_directory));
+ if (base::DirectoryExists(dir)) {
+ const std::string mojo_file_name(base_url.host() + ".mojo");
+ const base::FilePath mojo_path =
+ dir.Append(base::FilePath::FromUTF8Unsafe(mojo_file_name));
+ // Only use the directory if the .mojo exists in the directory.
+ if (base::PathExists(mojo_path))
+ return url_with_directory.Resolve(base_url.host() + ".mojo" + query);
+ }
+ }
+ return mojo_base_url_.Resolve(base_url.host() + ".mojo" + query);
}
} // namespace runner
« no previous file with comments | « mojo/runner/context.cc ('k') | mojo/runner/url_resolver_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698