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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_RESOURCE_PROTOCOL_H_
6 #define CONTENT_BROWSER_RESOURCE_PROTOCOL_H_
7
8 #include <map>
9 #include <utility>
10
11 #include "content/common/content_export.h"
12 #include "net/url_request/url_request_job_factory.h"
13 #include "ui/base/layout.h"
14
15 namespace content {
16
17 class ContentClient;
18
19 class CONTENT_EXPORT ResourceProtocolHandler
20 : public net::URLRequestJobFactory::ProtocolHandler {
21 public:
22 // Uses the global content client to fetch resources.
23 ResourceProtocolHandler();
24
25 // Uses the provided content client to fetch resources (for testing).
26 ResourceProtocolHandler(ContentClient* content_client);
27
28 ~ResourceProtocolHandler() override;
29
30 // Warning: calling this method exposes a resource to all web content.
31 // Carefully consider whether the resource could be used for XSS before
32 // 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.
33 void RegisterResource(const std::string& host,
34 const std::string& path,
35 int resource_id,
36 ui::ScaleFactor scale_factor,
37 const std::string& content_type);
38
39 // Overridden from net::URLRequestJobFactory::ProtocolHandler:
40 net::URLRequestJob* MaybeCreateJob(
41 net::URLRequest* request,
42 net::NetworkDelegate* network_delegate) const override;
43 bool IsSafeRedirectTarget(const GURL& location) const override;
44
45 // Public for the URLRequestJob subclass.
46 struct WebAccessibleResource {
47 int resource_id;
48 ui::ScaleFactor scale_factor;
49 std::string content_type;
50 };
51
52 private:
53 ContentClient* content_client_;
54 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.
55 resources_;
56 };
57
58 } // namespace content
59
60 #endif // CONTENT_BROWSER_RESOURCE_PROTOCOL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698