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

Unified Diff: content/browser/resource_protocol.h

Issue 647853002: Create a proprietary scheme for loading web-accessible resources. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use https://codereview.chromium.org/730203007/ to permit only images and CSS on resource protocol Created 6 years, 1 month 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: content/browser/resource_protocol.h
diff --git a/content/browser/resource_protocol.h b/content/browser/resource_protocol.h
new file mode 100644
index 0000000000000000000000000000000000000000..b03718ff62c4859b97e5f025ebd09c9844ddbf71
--- /dev/null
+++ b/content/browser/resource_protocol.h
@@ -0,0 +1,60 @@
+// 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 CONTENT_BROWSER_RESOURCE_PROTOCOL_H_
+#define CONTENT_BROWSER_RESOURCE_PROTOCOL_H_
+
+#include <map>
+#include <utility>
+
+#include "content/common/content_export.h"
+#include "net/url_request/url_request_job_factory.h"
+#include "ui/base/layout.h"
+
+namespace content {
+
+class ContentClient;
+
+class CONTENT_EXPORT ResourceProtocolHandler
+ : public net::URLRequestJobFactory::ProtocolHandler {
+ public:
+ // Uses the global content client to fetch resources.
+ ResourceProtocolHandler();
+
+ // Uses the provided content client to fetch resources (for testing).
+ ResourceProtocolHandler(ContentClient* content_client);
+
+ ~ResourceProtocolHandler() override;
+
+ // Warning: calling this method exposes a resource to all web content.
+ // Carefully consider whether the resource could be used for XSS before
+ // registering it.
davidben 2014/11/19 00:21:21 What are resource_id, scale_factor, and content_ty
jbroman 2014/11/19 15:06:54 Done.
+ void RegisterResource(const std::string& host,
+ const std::string& path,
+ int resource_id,
+ ui::ScaleFactor scale_factor,
+ const std::string& content_type);
+
+ // Overridden from net::URLRequestJobFactory::ProtocolHandler:
+ net::URLRequestJob* MaybeCreateJob(
+ net::URLRequest* request,
+ net::NetworkDelegate* network_delegate) const override;
+ bool IsSafeRedirectTarget(const GURL& location) const override;
+
+ // Public for the URLRequestJob subclass.
+ struct WebAccessibleResource {
+ int resource_id;
+ ui::ScaleFactor scale_factor;
+ std::string content_type;
+ };
+
+ private:
+ ContentClient* content_client_;
+ std::map<std::pair<std::string, std::string>, WebAccessibleResource>
davidben 2014/11/19 00:21:21 I'd either add a comment or a dedicated struct so
jbroman 2014/11/19 15:06:54 Done.
+ resources_;
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_RESOURCE_PROTOCOL_H_

Powered by Google App Engine
This is Rietveld 408576698