OLD | NEW |
---|---|
(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 public: | |
Tom Sepez
2014/11/17 18:09:11
nit: duplicate public:
jbroman
2014/11/17 18:35:16
You mean this doesn't make it super-extra-public?
| |
31 // Warning: calling this method exposes a resource to all web content. | |
32 // Carefully consider whether the resource could be used for XSS before | |
33 // registering it. | |
34 void RegisterResource(const std::string& host, | |
35 const std::string& path, | |
36 int resource_id, | |
37 ui::ScaleFactor scale_factor, | |
38 const std::string& content_type); | |
39 | |
40 // Overridden from net::URLRequestJobFactory::ProtocolHandler: | |
41 net::URLRequestJob* MaybeCreateJob( | |
42 net::URLRequest* request, | |
43 net::NetworkDelegate* network_delegate) const override; | |
44 bool IsSafeRedirectTarget(const GURL& location) const override; | |
45 | |
46 // Public for the URLRequestJob subclass. | |
47 struct WebAccessibleResource { | |
48 int resource_id; | |
49 ui::ScaleFactor scale_factor; | |
50 std::string content_type; | |
51 }; | |
52 | |
53 private: | |
54 ContentClient* content_client_; | |
55 std::map<std::pair<std::string, std::string>, WebAccessibleResource> | |
56 resources_; | |
57 }; | |
58 | |
59 } // namespace content | |
60 | |
61 #endif // CONTENT_BROWSER_RESOURCE_PROTOCOL_H_ | |
OLD | NEW |