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 #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 "url/gurl.h" | 11 #include "url/gurl.h" |
12 | 12 |
13 namespace mojo { | 13 namespace mojo { |
14 namespace shell { | 14 namespace shell { |
15 | 15 |
16 // This class resolves "mojo:" URLs to physical URLs (e.g., "file:" and | 16 // 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 | 17 // "https:" URLs). By default, "mojo:" URLs resolve to a file location, but |
18 // that resolution can be customized via the AddCustomMapping method. | 18 // that resolution can be customized via the AddCustomMapping method. |
19 class MojoURLResolver { | 19 class MojoURLResolver { |
20 public: | 20 public: |
21 MojoURLResolver(); | 21 MojoURLResolver(); |
22 ~MojoURLResolver(); | 22 ~MojoURLResolver(); |
23 | 23 |
24 // If specified, then unknown "mojo:" URLs will be resolved relative to this | 24 // If specified, then unknown "mojo:" URLs will be resolved relative to this |
25 // origin. That is, the portion after the colon will be appeneded to origin | 25 // origin. That is, the portion after the colon will be appeneded to origin |
26 // with platform-specific shared library prefix and suffix inserted. | 26 // with platform-specific shared library prefix and suffix inserted. |
27 void set_origin(const std::string& origin) { origin_ = origin; } | 27 void SetOrigin(const std::string& origin); |
viettrungluu
2014/07/15 22:44:53
I wonder if this shouldn't take a GURL as an argum
tim (not reviewing)
2014/07/15 23:01:29
Heh, do either of you know a handy way to force a
tim (not reviewing)
2014/07/19 02:11:37
Done.
| |
28 | 28 |
29 // Add a custom mapping for a particular "mojo:" URL. | 29 // Add a custom mapping for a particular "mojo:" URL. |
30 void AddCustomMapping(const GURL& mojo_url, const GURL& resolved_url); | 30 void AddCustomMapping(const GURL& mojo_url, const GURL& resolved_url); |
31 | 31 |
32 // Add a local file mapping for a particular "mojo:" URL. This causes the | 32 // Add a local file mapping for a particular "mojo:" URL. This causes the |
33 // "mojo:" URL to be resolved to an base::DIR_EXE-relative shared library. | 33 // "mojo:" URL to be resolved to an base::DIR_EXE-relative shared library. |
34 void AddLocalFileMapping(const GURL& mojo_url); | 34 void AddLocalFileMapping(const GURL& mojo_url); |
35 | 35 |
36 // Resolve the given "mojo:" URL to the URL that should be used to fetch the | 36 // Resolve the given "mojo:" URL to the URL that should be used to fetch the |
37 // code for the corresponding Mojo App. | 37 // code for the corresponding Mojo App. |
38 GURL Resolve(const GURL& mojo_url) const; | 38 GURL Resolve(const GURL& mojo_url) const; |
39 | 39 |
40 private: | 40 private: |
41 std::map<GURL, GURL> url_map_; | 41 std::map<GURL, GURL> url_map_; |
42 std::set<GURL> local_file_set_; | 42 std::set<GURL> local_file_set_; |
43 std::string origin_; | 43 GURL origin_; |
44 }; | 44 }; |
45 | 45 |
46 } // namespace shell | 46 } // namespace shell |
47 } // namespace mojo | 47 } // namespace mojo |
48 | 48 |
49 #endif // MOJO_SHELL_MOJO_URL_RESOLVER_H_ | 49 #endif // MOJO_SHELL_MOJO_URL_RESOLVER_H_ |
OLD | NEW |