OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_PUBLIC_BROWSER_RESOURCE_DISPATCHER_HOST_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_RESOURCE_DISPATCHER_HOST_H_ |
6 #define CONTENT_PUBLIC_BROWSER_RESOURCE_DISPATCHER_HOST_H_ | 6 #define CONTENT_PUBLIC_BROWSER_RESOURCE_DISPATCHER_HOST_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 #include <string> | |
11 | 12 |
12 #include "base/callback_forward.h" | 13 #include "base/callback_forward.h" |
13 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
14 | 15 |
15 namespace net { | 16 namespace net { |
16 class URLRequest; | 17 class URLRequest; |
17 } | 18 } |
18 | 19 |
19 namespace content { | 20 namespace content { |
20 | 21 |
21 class DownloadItem; | 22 class DownloadItem; |
22 class ResourceContext; | 23 class ResourceContext; |
23 class ResourceDispatcherHostDelegate; | 24 class ResourceDispatcherHostDelegate; |
24 struct DownloadSaveInfo; | 25 struct DownloadSaveInfo; |
25 struct Referrer; | 26 struct Referrer; |
26 class RenderFrameHost; | 27 class RenderFrameHost; |
27 | 28 |
28 class CONTENT_EXPORT ResourceDispatcherHost { | 29 class CONTENT_EXPORT ResourceDispatcherHost { |
29 public: | 30 public: |
31 // This enum indicates how access checks are made on registered URL origins. | |
32 // Please see the RegisterOriginForAccessChecks() method for more | |
33 // information. | |
34 enum OriginAccessCheckMask { | |
35 DENY_FOR_NON_OWNERS = 0x0, // Denied for non owner processes. | |
Charlie Reis
2016/08/09 02:07:48
What's an owner process? (We'll need to elaborate
| |
36 ALLOW_EVERYTHING = 0x1, // No access checks performed. | |
37 ALLOW_REGISTERED_ACCESS = 0x2, // Only registered processes allowed. | |
38 ACCESS_CHECK_MASK_LAST = ALLOW_REGISTERED_ACCESS, | |
39 }; | |
40 | |
30 // Returns the singleton instance of the ResourceDispatcherHost. | 41 // Returns the singleton instance of the ResourceDispatcherHost. |
31 static ResourceDispatcherHost* Get(); | 42 static ResourceDispatcherHost* Get(); |
32 | 43 |
33 // Causes all new requests for the root RenderFrameHost and its children to be | 44 // Causes all new requests for the root RenderFrameHost and its children to be |
34 // blocked (not being started) until ResumeBlockedRequestsForFrameFromUI is | 45 // blocked (not being started) until ResumeBlockedRequestsForFrameFromUI is |
35 // called. | 46 // called. |
36 static void BlockRequestsForFrameFromUI(RenderFrameHost* root_frame_host); | 47 static void BlockRequestsForFrameFromUI(RenderFrameHost* root_frame_host); |
37 | 48 |
38 // Resumes any blocked request for the specified root RenderFrameHost and | 49 // Resumes any blocked request for the specified root RenderFrameHost and |
39 // child frame hosts. | 50 // child frame hosts. |
40 static void ResumeBlockedRequestsForFrameFromUI( | 51 static void ResumeBlockedRequestsForFrameFromUI( |
41 RenderFrameHost* root_frame_host); | 52 RenderFrameHost* root_frame_host); |
42 | 53 |
43 // This does not take ownership of the delegate. It is expected that the | 54 // This does not take ownership of the delegate. It is expected that the |
44 // delegate have a longer lifetime than the ResourceDispatcherHost. | 55 // delegate have a longer lifetime than the ResourceDispatcherHost. |
45 virtual void SetDelegate(ResourceDispatcherHostDelegate* delegate) = 0; | 56 virtual void SetDelegate(ResourceDispatcherHostDelegate* delegate) = 0; |
46 | 57 |
47 // Controls whether third-party sub-content can pop-up HTTP basic auth | 58 // Controls whether third-party sub-content can pop-up HTTP basic auth |
48 // dialog boxes. | 59 // dialog boxes. |
49 virtual void SetAllowCrossOriginAuthPrompt(bool value) = 0; | 60 virtual void SetAllowCrossOriginAuthPrompt(bool value) = 0; |
50 | 61 |
51 // Clears the ResourceDispatcherHostLoginDelegate associated with the request. | 62 // Clears the ResourceDispatcherHostLoginDelegate associated with the request. |
52 virtual void ClearLoginDelegateForRequest(net::URLRequest* request) = 0; | 63 virtual void ClearLoginDelegateForRequest(net::URLRequest* request) = 0; |
53 | 64 |
65 // Specifies a scheme to be access checked. By default all schemes are | |
66 // allowed. Access check here means that any process claiming to have | |
67 // committed a URL within the scheme has to be registered via the | |
68 // AddProcessForOrigin() method below. | |
69 virtual void AddSchemeForAccessCheck(const std::string& scheme) = 0; | |
70 | |
71 // The following 4 methods add or remove access information for the url | |
72 // origin passed in. Please note that the scheme has to be registered for | |
73 // access check via a call to the AddSchemeForAccessCheck() method above. | |
74 | |
75 // Sets up access information for the |origin| passed in. This is eventually | |
76 // used to grant or deny access to the origin. By default owner processes | |
Charlie Reis
2016/08/09 02:07:48
It's not clear what an owner process is.
| |
77 // can commit to the origin. The |access_check_mask| flag controls the | |
78 // access check behavior for other processes. Please see the definition of | |
79 // OriginAccessCheckMask for more information. | |
80 virtual void RegisterOriginForAccessChecks( | |
81 const ResourceContext* context, | |
82 const std::string& origin, | |
83 OriginAccessCheckMask access_check_mask) = 0; | |
84 | |
85 // Removes access information for the url |origin| passed in. | |
86 virtual void UnregisterOriginForAccessChecks(const ResourceContext* context, | |
87 const std::string& origin) = 0; | |
88 | |
89 // Adds |process_id| to the list of processes allowed to access the |origin|. | |
90 // The |owner_process| flag indicates whether the process owns the |origin|. | |
Charlie Reis
2016/08/09 02:07:48
We'll need more guidance on what to pass for owner
| |
91 virtual void AddProcessForOrigin(const ResourceContext* context, | |
92 const std::string& origin, | |
93 int process_id, | |
94 bool owner_process) = 0; | |
95 | |
96 // Removes |process_id| from the list of processes allowed to access the | |
97 // |origin|. The |owner_process| flag indicates whether the process owns the | |
98 // |origin|. | |
99 virtual void RemoveProcessForOrigin(const ResourceContext* context, | |
100 const std::string& origin, | |
101 int process_id, | |
102 bool owner_proces) = 0; | |
Charlie Reis
2016/08/09 02:07:48
Do we need the flag on removal as well? What happ
| |
103 | |
54 protected: | 104 protected: |
55 virtual ~ResourceDispatcherHost() {} | 105 virtual ~ResourceDispatcherHost() {} |
56 }; | 106 }; |
57 | 107 |
58 } // namespace content | 108 } // namespace content |
59 | 109 |
60 #endif // CONTENT_PUBLIC_BROWSER_RESOURCE_DISPATCHER_HOST_H_ | 110 #endif // CONTENT_PUBLIC_BROWSER_RESOURCE_DISPATCHER_HOST_H_ |
OLD | NEW |