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

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

Issue 658503003: Enables specifying mojo url mapping on command line (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 6 years, 2 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/shell/desktop/mojo_main.cc ('k') | mojo/shell/mojo_url_resolver.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 #ifndef MOJO_SHELL_MOJO_URL_RESOLVER_H_ 5 #ifndef MOJO_SHELL_MOJO_URL_RESOLVER_H_
6 #define MOJO_SHELL_MOJO_URL_RESOLVER_H_ 6 #define MOJO_SHELL_MOJO_URL_RESOLVER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 10
11 #include "base/basictypes.h"
11 #include "url/gurl.h" 12 #include "url/gurl.h"
12 13
13 namespace mojo { 14 namespace mojo {
14 namespace shell { 15 namespace shell {
15 16
16 // This class resolves "mojo:" URLs to physical URLs (e.g., "file:" and 17 // This class resolves "mojo:" URLs to physical URLs (e.g., "file:" and
17 // "https:" URLs). By default, "mojo:" URLs resolve to a file location, but 18 // "https:" URLs). By default, "mojo:" URLs resolve to a file location, but
18 // that resolution can be customized via the AddCustomMapping method. 19 // that resolution can be customized via the AddCustomMapping method.
19 class MojoURLResolver { 20 class MojoURLResolver {
20 public: 21 public:
21 MojoURLResolver(); 22 MojoURLResolver();
22 ~MojoURLResolver(); 23 ~MojoURLResolver();
23 24
24 // If specified, then unknown "mojo:" URLs will be resolved relative to this 25 // If specified, then unknown "mojo:" URLs will be resolved relative to this
25 // base URL. That is, the portion after the colon will be appeneded to 26 // base URL. That is, the portion after the colon will be appeneded to
26 // |base_url| with platform-specific shared library prefix and suffix 27 // |base_url| with platform-specific shared library prefix and suffix
27 // inserted. 28 // inserted.
28 void SetBaseURL(const GURL& base_url); 29 void SetBaseURL(const GURL& base_url);
29 30
30 // Add a custom mapping for a particular "mojo:" URL. 31 // Add a custom mapping for a particular "mojo:" URL. If |resolved_url| is
32 // itself a mojo url normal resolution rules apply.
31 void AddCustomMapping(const GURL& mojo_url, const GURL& resolved_url); 33 void AddCustomMapping(const GURL& mojo_url, const GURL& resolved_url);
32 34
33 // Add a local file mapping for a particular "mojo:" URL. This causes the 35 // Add a local file mapping for a particular "mojo:" URL. This causes the
34 // "mojo:" URL to be resolved to a base::DIR_MODULE-relative shared library. 36 // "mojo:" URL to be resolved to a base::DIR_MODULE-relative shared library.
35 void AddLocalFileMapping(const GURL& mojo_url); 37 void AddLocalFileMapping(const GURL& mojo_url);
36 38
37 // Resolve the given "mojo:" URL to the URL that should be used to fetch the 39 // Resolve the given "mojo:" URL to the URL that should be used to fetch the
38 // code for the corresponding Mojo App. 40 // code for the corresponding Mojo App.
39 GURL Resolve(const GURL& mojo_url) const; 41 GURL Resolve(const GURL& mojo_url) const;
40 42
41 private: 43 private:
44 // Applies all custom mappings for |url|, returning the last non-mapped url.
45 // For example, if 'a' maps to 'b' and 'b' maps to 'c' calling this with 'a'
46 // returns 'c'.
47 GURL ApplyCustomMappings(const GURL& url) const;
48
42 std::map<GURL, GURL> url_map_; 49 std::map<GURL, GURL> url_map_;
43 std::set<GURL> local_file_set_; 50 std::set<GURL> local_file_set_;
44 GURL default_base_url_; 51 GURL default_base_url_;
45 GURL base_url_; 52 GURL base_url_;
53
54 DISALLOW_COPY_AND_ASSIGN(MojoURLResolver);
46 }; 55 };
47 56
48 } // namespace shell 57 } // namespace shell
49 } // namespace mojo 58 } // namespace mojo
50 59
51 #endif // MOJO_SHELL_MOJO_URL_RESOLVER_H_ 60 #endif // MOJO_SHELL_MOJO_URL_RESOLVER_H_
OLDNEW
« no previous file with comments | « mojo/shell/desktop/mojo_main.cc ('k') | mojo/shell/mojo_url_resolver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698