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

Side by Side Diff: mojo/shell/mojo_url_resolver.cc

Issue 414633003: Mojo: Set a default value for the --origin command line switch. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « mojo/examples/wget/wget.cc ('k') | no next file » | 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/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"
(...skipping 15 matching lines...) Expand all
26 NOTREACHED() << "dynamic loading of services not supported"; 26 NOTREACHED() << "dynamic loading of services not supported";
27 return std::string(); 27 return std::string();
28 #endif 28 #endif
29 } 29 }
30 30
31 } // namespace 31 } // namespace
32 32
33 MojoURLResolver::MojoURLResolver() { 33 MojoURLResolver::MojoURLResolver() {
34 // Needed to treat first component of mojo URLs as host, not path. 34 // Needed to treat first component of mojo URLs as host, not path.
35 url::AddStandardScheme("mojo"); 35 url::AddStandardScheme("mojo");
36
37 // By default, resolve mojo URLs to files living alongside the shell.
38 base::FilePath path;
39 PathService::Get(base::DIR_MODULE, &path);
40 origin_ = net::FilePathToFileURL(path).spec();
tim (not reviewing) 2014/07/23 22:22:32 As we were talking about, probably makes sense to
36 } 41 }
37 42
38 MojoURLResolver::~MojoURLResolver() { 43 MojoURLResolver::~MojoURLResolver() {
39 } 44 }
40 45
41 void MojoURLResolver::AddCustomMapping(const GURL& mojo_url, 46 void MojoURLResolver::AddCustomMapping(const GURL& mojo_url,
42 const GURL& resolved_url) { 47 const GURL& resolved_url) {
43 url_map_[mojo_url] = resolved_url; 48 url_map_[mojo_url] = resolved_url;
44 } 49 }
45 50
(...skipping 15 matching lines...) Expand all
61 path = path.Append(base::FilePath::FromUTF8Unsafe(lib)); 66 path = path.Append(base::FilePath::FromUTF8Unsafe(lib));
62 return net::FilePathToFileURL(path); 67 return net::FilePathToFileURL(path);
63 } 68 }
64 69
65 // Otherwise, resolve to an URL relative to origin_. 70 // Otherwise, resolve to an URL relative to origin_.
66 return GURL(origin_ + "/" + lib); 71 return GURL(origin_ + "/" + lib);
67 } 72 }
68 73
69 } // namespace shell 74 } // namespace shell
70 } // namespace mojo 75 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/examples/wget/wget.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698