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

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: brace for two-line if statement (why didn't clang-format change this?) 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..e65c8ffb186ee0db113520a75c53fd1fa67a844d
--- /dev/null
+++ b/content/browser/resource_protocol.h
@@ -0,0 +1,61 @@
+// 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;
+
+ public:
+ // Warning: calling this method exposes a resource to all web content.
+ // Carefully consider whether the resource could be used for XSS before
+ // registering it.
+ 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>
+ resources_;
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_RESOURCE_PROTOCOL_H_

Powered by Google App Engine
This is Rietveld 408576698