OLD | NEW |
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/mojo_url_resolver.h" | 5 #include "mojo/shell/mojo_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/logging.h" | 9 #include "base/logging.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "net/base/filename_util.h" | 12 #include "mojo/shell/filename_util.h" |
13 #include "url/url_util.h" | 13 #include "url/url_util.h" |
14 | 14 |
15 namespace mojo { | 15 namespace mojo { |
16 namespace shell { | 16 namespace shell { |
17 namespace { | 17 namespace { |
18 | 18 |
19 std::string MakeSharedLibraryName(std::string host_name) { | 19 std::string MakeSharedLibraryName(std::string host_name) { |
20 // TODO(aa): This should go away soon. In the Chromium repo, all the app | 20 // TODO(aa): This should go away soon. In the Chromium repo, all the app |
21 // target names start with "mojo_" by convention. But when we have an SDK, | 21 // target names start with "mojo_" by convention. But when we have an SDK, |
22 // one would assume the libraries would have names that don't have this bit. | 22 // one would assume the libraries would have names that don't have this bit. |
(...skipping 25 matching lines...) Expand all Loading... |
48 | 48 |
49 } // namespace | 49 } // namespace |
50 | 50 |
51 MojoURLResolver::MojoURLResolver() { | 51 MojoURLResolver::MojoURLResolver() { |
52 // Needed to treat first component of mojo URLs as host, not path. | 52 // Needed to treat first component of mojo URLs as host, not path. |
53 url::AddStandardScheme("mojo"); | 53 url::AddStandardScheme("mojo"); |
54 | 54 |
55 // By default, resolve mojo URLs to files living alongside the shell. | 55 // By default, resolve mojo URLs to files living alongside the shell. |
56 base::FilePath path; | 56 base::FilePath path; |
57 PathService::Get(base::DIR_MODULE, &path); | 57 PathService::Get(base::DIR_MODULE, &path); |
58 default_base_url_ = AddTrailingSlashIfNeeded(net::FilePathToFileURL(path)); | 58 default_base_url_ = AddTrailingSlashIfNeeded(FilePathToFileURL(path)); |
59 } | 59 } |
60 | 60 |
61 MojoURLResolver::~MojoURLResolver() { | 61 MojoURLResolver::~MojoURLResolver() { |
62 } | 62 } |
63 | 63 |
64 void MojoURLResolver::SetBaseURL(const GURL& base_url) { | 64 void MojoURLResolver::SetBaseURL(const GURL& base_url) { |
65 DCHECK(base_url.is_valid()); | 65 DCHECK(base_url.is_valid()); |
66 // Force a trailing slash on the base_url to simplify resolving | 66 // Force a trailing slash on the base_url to simplify resolving |
67 // relative files and URLs below. | 67 // relative files and URLs below. |
68 base_url_ = AddTrailingSlashIfNeeded(base_url); | 68 base_url_ = AddTrailingSlashIfNeeded(base_url); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 std::map<GURL, GURL>::const_iterator it = url_map_.find(mapped_url); | 102 std::map<GURL, GURL>::const_iterator it = url_map_.find(mapped_url); |
103 if (it == url_map_.end()) | 103 if (it == url_map_.end()) |
104 break; | 104 break; |
105 mapped_url = it->second; | 105 mapped_url = it->second; |
106 } | 106 } |
107 return mapped_url; | 107 return mapped_url; |
108 } | 108 } |
109 | 109 |
110 } // namespace shell | 110 } // namespace shell |
111 } // namespace mojo | 111 } // namespace mojo |
OLD | NEW |