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

Side by Side Diff: mojo/runner/url_resolver.cc

Issue 1180653002: Build Mojo apps in subdirectories, like application packages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync and rebase; update tests. 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 unified diff | Download patch
« no previous file with comments | « mojo/runner/context.cc ('k') | mojo/runner/url_resolver_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/runner/url_resolver.h" 5 #include "mojo/runner/url_resolver.h"
6 6
7 #include "base/base_paths.h" 7 #include "base/base_paths.h"
8 #include "base/files/file_path.h"
9 #include "base/files/file_util.h"
10 #include "base/logging.h" 8 #include "base/logging.h"
11 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
12 #include "mojo/runner/switches.h" 10 #include "mojo/runner/switches.h"
13 #include "mojo/shell/query_util.h" 11 #include "mojo/shell/query_util.h"
14 #include "mojo/util/filename_util.h" 12 #include "mojo/util/filename_util.h"
15 #include "url/url_util.h" 13 #include "url/url_util.h"
16 14
17 namespace mojo { 15 namespace mojo {
18 namespace runner { 16 namespace runner {
19 17
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 102
105 GURL URLResolver::ResolveMojoURL(const GURL& mojo_url) const { 103 GURL URLResolver::ResolveMojoURL(const GURL& mojo_url) const {
106 if (mojo_url.scheme() != "mojo") { 104 if (mojo_url.scheme() != "mojo") {
107 // The mapping has produced some sort of non-mojo: URL - file:, http:, etc. 105 // The mapping has produced some sort of non-mojo: URL - file:, http:, etc.
108 return mojo_url; 106 return mojo_url;
109 } 107 }
110 108
111 // It's still a mojo: URL, use the default mapping scheme. 109 // It's still a mojo: URL, use the default mapping scheme.
112 std::string query; 110 std::string query;
113 GURL base_url = shell::GetBaseURLAndQuery(mojo_url, &query); 111 GURL base_url = shell::GetBaseURLAndQuery(mojo_url, &query);
114 if (mojo_base_url_.SchemeIsFile()) { 112 const std::string host = base_url.host();
115 const GURL url_with_directory( 113 return mojo_base_url_.Resolve(host + "/" + host + ".mojo" + query);
116 mojo_base_url_.Resolve(base_url.host() + "/"));
117 const base::FilePath dir(util::UrlToFilePath(url_with_directory));
118 if (base::DirectoryExists(dir)) {
119 const std::string mojo_file_name(base_url.host() + ".mojo");
120 const base::FilePath mojo_path =
121 dir.Append(base::FilePath::FromUTF8Unsafe(mojo_file_name));
122 // Only use the directory if the .mojo exists in the directory.
123 if (base::PathExists(mojo_path))
124 return url_with_directory.Resolve(base_url.host() + ".mojo" + query);
125 }
126 }
127 return mojo_base_url_.Resolve(base_url.host() + ".mojo" + query);
128 } 114 }
129 115
130 } // namespace runner 116 } // namespace runner
131 } // namespace mojo 117 } // namespace mojo
OLDNEW
« 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