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

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

Issue 1343823002: Revert of Move fetching logic out of ApplicationManager, eliminate url mappings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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/fetcher/url_resolver.h ('k') | mojo/fetcher/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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "mojo/fetcher/url_resolver.h"
6
7 #include "base/base_paths.h"
8 #include "base/logging.h"
9 #include "base/strings/utf_string_conversions.h"
10 #include "mojo/shell/query_util.h"
11 #include "mojo/util/filename_util.h"
12 #include "url/url_util.h"
13
14 namespace mojo {
15 namespace fetcher {
16
17 URLResolver::URLResolver(const GURL& mojo_base_url)
18 : mojo_base_url_(util::AddTrailingSlashIfNeeded(mojo_base_url)) {
19 DCHECK(mojo_base_url_.is_valid());
20 // Needed to treat first component of mojo URLs as host, not path.
21 url::AddStandardScheme("mojo", url::SCHEME_WITHOUT_AUTHORITY);
22 }
23
24 URLResolver::~URLResolver() {
25 }
26
27 GURL URLResolver::ResolveMojoURL(const GURL& mojo_url) const {
28 if (mojo_url.scheme() != "mojo") {
29 // The mapping has produced some sort of non-mojo: URL - file:, http:, etc.
30 return mojo_url;
31 }
32
33 // It's still a mojo: URL, use the default mapping scheme.
34 std::string query;
35 GURL base_url = shell::GetBaseURLAndQuery(mojo_url, &query);
36 const std::string host = base_url.host();
37 return mojo_base_url_.Resolve(host + "/" + host + ".mojo" + query);
38 }
39
40 } // namespace fetcher
41 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/fetcher/url_resolver.h ('k') | mojo/fetcher/url_resolver_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698