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

Unified Diff: shell/url_resolver.h

Issue 926093003: AddOriginMapping() (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Comments Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: shell/url_resolver.h
diff --git a/shell/url_resolver.h b/shell/url_resolver.h
index 4cb02be67c529f3f663987e392983c50d79dad15..c3ad7df6936cd8208d268435ac6e9f3e26032ab0 100644
--- a/shell/url_resolver.h
+++ b/shell/url_resolver.h
@@ -25,14 +25,34 @@ class URLResolver {
URLResolver();
~URLResolver();
- // Add a custom mapping for a particular URL. If |resolved_url| is
+ // Used for the return value of GetOriginMappings().
+ struct OriginMapping {
+ OriginMapping(const std::string& origin, const std::string& base_url)
+ : origin(origin), base_url(base_url) {}
+
+ const std::string origin;
+ const std::string base_url;
+ };
+
+ // Returns a list of origin mappings based on command line args.
+ // The switch --map-origin can be specified multiple times. Each occurance
+ // has the format of --map-origin={origin}={base_url}
+ // For example:
+ // --map-origin=http://domokit.org=file:///source/out
+ static std::vector<OriginMapping> GetOriginMappings(
+ const std::vector<std::string> argv);
+
+ // Add a custom mapping for a particular URL. If |mapped_url| is
// itself a mojo url normal resolution rules apply.
- void AddURLMapping(const GURL& url, const GURL& resolved_url);
+ void AddURLMapping(const GURL& url, const GURL& mapped_url);
+
+ // Add a custom mapping for all urls rooted at |origin|.
+ void AddOriginMapping(const GURL& origin, const GURL& base_url);
// Applies all custom mappings for |url|, returning the last non-mapped url.
// For example, if 'a' maps to 'b' and 'b' maps to 'c' calling this with 'a'
// returns 'c'.
- GURL ApplyURLMappings(const GURL& url) const;
+ GURL ApplyMappings(const GURL& url) const;
// If specified, then "mojo:" URLs will be resolved relative to this
// URL. That is, the portion after the colon will be appeneded to
@@ -44,7 +64,9 @@ class URLResolver {
GURL ResolveMojoURL(const GURL& mojo_url) const;
private:
- std::map<GURL, GURL> url_map_;
+ using GURLToGURLMap = std::map<GURL, GURL>;
+ GURLToGURLMap url_map_;
+ GURLToGURLMap origin_map_;
GURL mojo_base_url_;
DISALLOW_COPY_AND_ASSIGN(URLResolver);

Powered by Google App Engine
This is Rietveld 408576698