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

Side by Side Diff: content/browser/resource_protocol_handler.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: update include guards too 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_HANDLER_H_
6 #define CONTENT_BROWSER_RESOURCE_PROTOCOL_HANDLER_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 // Registers a resource (specified by its resource ID and scale factor
31 // as expected by ContentClient::GetDataResource) with the hostname
32 // and path required to request it. This resource will be made
33 // web-accessible, and served with the content type provided.
34 //
35 // Warning: calling this method exposes a resource to all web content.
36 // Carefully consider whether the resource could be used for XSS before
37 // registering it.
38 void RegisterResource(const std::string& host,
39 const std::string& path,
40 int resource_id,
41 ui::ScaleFactor scale_factor,
42 const std::string& content_type);
43
44 // Overridden from net::URLRequestJobFactory::ProtocolHandler:
45 net::URLRequestJob* MaybeCreateJob(
46 net::URLRequest* request,
47 net::NetworkDelegate* network_delegate) const override;
48 bool IsSafeRedirectTarget(const GURL& location) const override;
49
50 // Public for the URLRequestJob subclass.
51 struct WebAccessibleResource {
52 int resource_id;
53 ui::ScaleFactor scale_factor;
54 std::string content_type;
55 };
56
57 private:
58 ContentClient* content_client_;
59
60 // Map from (host, path) pairs to resource info.
61 std::map<std::pair<std::string, std::string>, WebAccessibleResource>
62 resources_;
63 };
64
65 CONTENT_EXPORT void RegisterDefaultWebAccessibleResources(
66 ResourceProtocolHandler* handler);
67
68 } // namespace content
69
70 #endif // CONTENT_BROWSER_RESOURCE_PROTOCOL_HANDLER_H_
OLDNEW
« no previous file with comments | « content/browser/child_process_security_policy_impl.cc ('k') | content/browser/resource_protocol_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698