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

Unified Diff: mojo/shell/mojo_url_resolver.h

Issue 323593002: Mojo: Use network service to load non-local Mojo Apps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 6 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
« no previous file with comments | « mojo/shell/loader.cc ('k') | mojo/shell/mojo_url_resolver.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/shell/mojo_url_resolver.h
diff --git a/mojo/shell/mojo_url_resolver.h b/mojo/shell/mojo_url_resolver.h
new file mode 100644
index 0000000000000000000000000000000000000000..d232a40703503105c5b32eba923f6f29ddba8600
--- /dev/null
+++ b/mojo/shell/mojo_url_resolver.h
@@ -0,0 +1,49 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MOJO_SHELL_MOJO_URL_RESOLVER_H_
+#define MOJO_SHELL_MOJO_URL_RESOLVER_H_
+
+#include <map>
+#include <set>
+
+#include "url/gurl.h"
+
+namespace mojo {
+namespace shell {
+
+// This class resolves "mojo:" URLs to physical URLs (e.g., "file:" and
+// "https:" URLs). By default, "mojo:" URLs resolve to a file location, but
+// that resolution can be customized via the AddCustomMapping method.
+class MojoURLResolver {
+ public:
+ MojoURLResolver();
+ ~MojoURLResolver();
+
+ // If specified, then unknown "mojo:" URLs will be resolved relative to this
+ // origin. That is, the portion after the colon will be appeneded to origin
+ // with platform-specific shared library prefix and suffix inserted.
+ void set_origin(const std::string& origin) { origin_ = origin; }
+
+ // Add a custom mapping for a particular "mojo:" URL.
+ void AddCustomMapping(const GURL& mojo_url, const GURL& resolved_url);
+
+ // Add a local file mapping for a particular "mojo:" URL. This causes the
+ // "mojo:" URL to be resolved to an base::DIR_EXE-relative shared library.
+ void AddLocalFileMapping(const GURL& mojo_url);
+
+ // Resolve the given "mojo:" URL to the URL that should be used to fetch the
+ // code for the corresponding Mojo App.
+ GURL Resolve(const GURL& mojo_url) const;
+
+ private:
+ std::map<GURL, GURL> url_map_;
+ std::set<GURL> local_file_set_;
+ std::string origin_;
+};
+
+} // namespace shell
+} // namespace mojo
+
+#endif // MOJO_SHELL_MOJO_URL_RESOLVER_H_
« no previous file with comments | « mojo/shell/loader.cc ('k') | mojo/shell/mojo_url_resolver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698