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

Unified Diff: shell/context.cc

Issue 873253003: Resolve URLs passed on the command line relative to the CWD. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Rebase Created 5 years, 11 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 | « shell/context.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: shell/context.cc
diff --git a/shell/context.cc b/shell/context.cc
index 623bb60d03b9c7f9354d660313b6d415f42c3d29..4baac09964b8c0f019769b27295e35efe7f169bb 100644
--- a/shell/context.cc
+++ b/shell/context.cc
@@ -137,7 +137,7 @@ bool ConfigureURLMappings(base::CommandLine* command_line,
using StringPair = std::pair<std::string, std::string>;
for (const StringPair& pair : pairs) {
const GURL from(pair.first);
- const GURL to(pair.second);
+ const GURL to = context->ResolveCommandLineURL(pair.second);
if (!from.is_valid() || !to.is_valid())
return false;
resolver->AddCustomMapping(from, to);
@@ -157,6 +157,10 @@ Context::Context() : application_manager_(this) {
base::FilePath shell_dir;
PathService::Get(base::DIR_MODULE, &shell_dir);
SetShellFileRoot(shell_dir);
+
+ base::FilePath cwd;
+ PathService::Get(base::DIR_CURRENT, &cwd);
+ SetCommandLineCWD(cwd);
}
Context::~Context() {
@@ -175,6 +179,14 @@ GURL Context::ResolveShellFileURL(const std::string& path) {
return shell_file_root_.Resolve(path);
}
+void Context::SetCommandLineCWD(const base::FilePath& path) {
+ command_line_cwd_ = AddTrailingSlashIfNeeded(FilePathToFileURL(path));
+}
+
+GURL Context::ResolveCommandLineURL(const std::string& path) {
+ return command_line_cwd_.Resolve(path);
+}
+
bool Context::Init() {
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
« no previous file with comments | « shell/context.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698