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

Side by Side 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, 7 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
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/shell/url_resolver.h" 5 #include "mojo/shell/url_resolver.h"
6 6
7 #include "base/base_paths.h" 7 #include "base/base_paths.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/files/file_util.h"
9 #include "base/logging.h" 10 #include "base/logging.h"
10 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
11 #include "mojo/shell/application_manager/query_util.h" 12 #include "mojo/shell/application_manager/query_util.h"
12 #include "mojo/shell/filename_util.h" 13 #include "mojo/shell/filename_util.h"
13 #include "mojo/shell/switches.h" 14 #include "mojo/shell/switches.h"
14 #include "url/url_util.h" 15 #include "url/url_util.h"
15 16
16 namespace mojo { 17 namespace mojo {
17 namespace shell { 18 namespace shell {
18 19
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 DCHECK(mojo_base_url.is_valid()); 99 DCHECK(mojo_base_url.is_valid());
99 // Force a trailing slash on the base_url to simplify resolving 100 // Force a trailing slash on the base_url to simplify resolving
100 // relative files and URLs below. 101 // relative files and URLs below.
101 mojo_base_url_ = AddTrailingSlashIfNeeded(mojo_base_url); 102 mojo_base_url_ = AddTrailingSlashIfNeeded(mojo_base_url);
102 } 103 }
103 104
104 GURL URLResolver::ResolveMojoURL(const GURL& mojo_url) const { 105 GURL URLResolver::ResolveMojoURL(const GURL& mojo_url) const {
105 if (mojo_url.scheme() != "mojo") { 106 if (mojo_url.scheme() != "mojo") {
106 // The mapping has produced some sort of non-mojo: URL - file:, http:, etc. 107 // The mapping has produced some sort of non-mojo: URL - file:, http:, etc.
107 return mojo_url; 108 return mojo_url;
108 } else {
109 // It's still a mojo: URL, use the default mapping scheme.
110 std::string query;
111 GURL base_url = GetBaseURLAndQuery(mojo_url, &query);
112 std::string lib = base_url.host() + ".mojo" + query;
113 return mojo_base_url_.Resolve(lib);
114 } 109 }
110
111 // It's still a mojo: URL, use the default mapping scheme.
112 std::string query;
113 GURL base_url = GetBaseURLAndQuery(mojo_url, &query);
114 if (mojo_base_url_.SchemeIsFile()) {
115 const GURL url_with_directory(
116 mojo_base_url_.Resolve(base_url.host() + "/"));
117 const base::FilePath file_path(UrlToFilePath(url_with_directory));
118 if (base::DirectoryExists(file_path))
119 return url_with_directory.Resolve(base_url.host() + ".mojo" + query);
120 }
121 return mojo_base_url_.Resolve(base_url.host() + ".mojo" + query);
115 } 122 }
116 123
117 } // namespace shell 124 } // namespace shell
118 } // namespace mojo 125 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698