| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 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_COMMON_RESOURCE_REQUEST_H_ | |
| 6 #define CONTENT_COMMON_RESOURCE_REQUEST_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/memory/ref_counted.h" | |
| 12 #include "base/optional.h" | |
| 13 #include "content/common/content_export.h" | |
| 14 #include "content/common/navigation_params.h" | |
| 15 #include "content/common/service_worker/service_worker_types.h" | |
| 16 #include "content/public/common/appcache_info.h" | |
| 17 #include "content/public/common/previews_state.h" | |
| 18 #include "content/public/common/request_context_frame_type.h" | |
| 19 #include "content/public/common/request_context_type.h" | |
| 20 #include "content/public/common/resource_request_body.h" | |
| 21 #include "content/public/common/resource_type.h" | |
| 22 #include "net/base/request_priority.h" | |
| 23 #include "third_party/WebKit/public/platform/WebMixedContentContextType.h" | |
| 24 #include "third_party/WebKit/public/platform/WebPageVisibilityState.h" | |
| 25 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h" | |
| 26 #include "ui/base/page_transition_types.h" | |
| 27 #include "url/gurl.h" | |
| 28 #include "url/origin.h" | |
| 29 | |
| 30 namespace content { | |
| 31 | |
| 32 struct CONTENT_EXPORT ResourceRequest { | |
| 33 ResourceRequest(); | |
| 34 ResourceRequest(const ResourceRequest& request); | |
| 35 ~ResourceRequest(); | |
| 36 | |
| 37 // The request method: GET, POST, etc. | |
| 38 std::string method; | |
| 39 | |
| 40 // The absolute requested URL encoded in ASCII per the rules of RFC-2396. | |
| 41 GURL url; | |
| 42 | |
| 43 // URL representing the first-party origin for the request, which may be | |
| 44 // checked by the third-party cookie blocking policy. This is usually the URL | |
| 45 // of the document in the top-level window. Leaving it empty may lead to | |
| 46 // undesired cookie blocking. Third-party cookie blocking can be bypassed by | |
| 47 // setting first_party_for_cookies = url, but this should ideally only be | |
| 48 // done if there really is no way to determine the correct value. | |
| 49 GURL first_party_for_cookies; | |
| 50 | |
| 51 // The origin of the context which initiated the request, which will be used | |
| 52 // for cookie checks like 'First-Party-Only'. | |
| 53 base::Optional<url::Origin> request_initiator; | |
| 54 | |
| 55 // The referrer to use (may be empty). | |
| 56 GURL referrer; | |
| 57 | |
| 58 // The referrer policy to use. | |
| 59 blink::WebReferrerPolicy referrer_policy = blink::kWebReferrerPolicyAlways; | |
| 60 | |
| 61 // The frame's visibility state. | |
| 62 blink::WebPageVisibilityState visibility_state = | |
| 63 blink::kWebPageVisibilityStateVisible; | |
| 64 | |
| 65 // Additional HTTP request headers. | |
| 66 // | |
| 67 // For HTTP(S) requests, the headers parameter can be a \r\n-delimited and | |
| 68 // \r\n-terminated list of MIME headers. They should be ASCII-encoded using | |
| 69 // the standard MIME header encoding rules. The headers parameter can also | |
| 70 // be null if no extra request headers need to be set. | |
| 71 std::string headers; | |
| 72 | |
| 73 // net::URLRequest load flags (0 by default). | |
| 74 int load_flags = 0; | |
| 75 | |
| 76 // Process ID from which this request originated, or zero if it originated | |
| 77 // in the renderer itself. | |
| 78 int origin_pid = 0; | |
| 79 | |
| 80 // What this resource load is for (main frame, sub-frame, sub-resource, | |
| 81 // object). | |
| 82 ResourceType resource_type = RESOURCE_TYPE_MAIN_FRAME; | |
| 83 | |
| 84 // The priority of this request determined by Blink. | |
| 85 net::RequestPriority priority = net::IDLE; | |
| 86 | |
| 87 // Used by plugin->browser requests to get the correct net::URLRequestContext. | |
| 88 uint32_t request_context = 0; | |
| 89 | |
| 90 // Indicates which frame (or worker context) the request is being loaded into, | |
| 91 // or kAppCacheNoHostId. | |
| 92 int appcache_host_id = kAppCacheNoHostId; | |
| 93 | |
| 94 // True if corresponding AppCache group should be resetted. | |
| 95 bool should_reset_appcache = false; | |
| 96 | |
| 97 // Indicates which frame (or worker context) the request is being loaded into, | |
| 98 // or kInvalidServiceWorkerProviderId. | |
| 99 int service_worker_provider_id = kInvalidServiceWorkerProviderId; | |
| 100 | |
| 101 // True if the request originated from a Service Worker, e.g. due to a | |
| 102 // fetch() in the Service Worker script. | |
| 103 bool originated_from_service_worker = false; | |
| 104 | |
| 105 // The service worker mode that indicates which service workers should get | |
| 106 // events for this request. | |
| 107 ServiceWorkerMode service_worker_mode = ServiceWorkerMode::ALL; | |
| 108 | |
| 109 // The request mode passed to the ServiceWorker. | |
| 110 FetchRequestMode fetch_request_mode = FETCH_REQUEST_MODE_SAME_ORIGIN; | |
| 111 | |
| 112 // The credentials mode passed to the ServiceWorker. | |
| 113 FetchCredentialsMode fetch_credentials_mode = FETCH_CREDENTIALS_MODE_OMIT; | |
| 114 | |
| 115 // The redirect mode used in Fetch API. | |
| 116 FetchRedirectMode fetch_redirect_mode = FetchRedirectMode::FOLLOW_MODE; | |
| 117 | |
| 118 // The request context passed to the ServiceWorker. | |
| 119 RequestContextType fetch_request_context_type = | |
| 120 REQUEST_CONTEXT_TYPE_UNSPECIFIED; | |
| 121 | |
| 122 // The mixed content context type to be used for mixed content checks. | |
| 123 blink::WebMixedContentContextType fetch_mixed_content_context_type = | |
| 124 blink::WebMixedContentContextType::kBlockable; | |
| 125 | |
| 126 // The frame type passed to the ServiceWorker. | |
| 127 RequestContextFrameType fetch_frame_type = | |
| 128 REQUEST_CONTEXT_FRAME_TYPE_AUXILIARY; | |
| 129 | |
| 130 // Optional resource request body (may be null). | |
| 131 scoped_refptr<ResourceRequestBody> request_body; | |
| 132 | |
| 133 // If true, then the response body will be downloaded to a file and the path | |
| 134 // to that file will be provided in ResponseInfo::download_file_path. | |
| 135 bool download_to_file = false; | |
| 136 | |
| 137 // True if the request was user initiated. | |
| 138 bool has_user_gesture = false; | |
| 139 | |
| 140 // TODO(mmenke): Investigate if enable_load_timing is safe to remove. | |
| 141 // | |
| 142 // True if load timing data should be collected for request. | |
| 143 bool enable_load_timing = false; | |
| 144 | |
| 145 // True if upload progress should be available for request. | |
| 146 bool enable_upload_progress = false; | |
| 147 | |
| 148 // True if login prompts for this request should be supressed. Cached | |
| 149 // credentials or default credentials may still be used for authentication. | |
| 150 bool do_not_prompt_for_login = false; | |
| 151 | |
| 152 // The routing id of the RenderFrame. | |
| 153 int render_frame_id = 0; | |
| 154 | |
| 155 // True if |frame_id| is the main frame of a RenderView. | |
| 156 bool is_main_frame = false; | |
| 157 | |
| 158 // True if |parent_render_frame_id| is the main frame of a RenderView. | |
| 159 bool parent_is_main_frame = false; | |
| 160 | |
| 161 // Identifies the parent frame of the frame that sent the request. | |
| 162 // -1 if unknown / invalid. | |
| 163 int parent_render_frame_id = -1; | |
| 164 | |
| 165 ui::PageTransition transition_type = ui::PAGE_TRANSITION_LINK; | |
| 166 | |
| 167 // For navigations, whether this navigation should replace the current session | |
| 168 // history entry on commit. | |
| 169 bool should_replace_current_entry = false; | |
| 170 | |
| 171 // The following two members identify a previous request that has been | |
| 172 // created before this navigation has been transferred to a new process. | |
| 173 // This serves the purpose of recycling the old request. | |
| 174 // Unless this refers to a transferred navigation, these values are -1 and -1. | |
| 175 int transferred_request_child_id = -1; | |
| 176 int transferred_request_request_id = -1; | |
| 177 | |
| 178 // Whether or not we should allow the URL to download. | |
| 179 bool allow_download = false; | |
| 180 | |
| 181 // Whether to intercept headers to pass back to the renderer. | |
| 182 bool report_raw_headers = false; | |
| 183 | |
| 184 // Whether or not to request a Preview version of the resource or let the | |
| 185 // browser decide. | |
| 186 PreviewsState previews_state = PREVIEWS_UNSPECIFIED; | |
| 187 | |
| 188 // PlzNavigate: the stream url associated with a navigation. Used to get | |
| 189 // access to the body of the response that has already been fetched by the | |
| 190 // browser. | |
| 191 GURL resource_body_stream_url; | |
| 192 | |
| 193 // Wether or not the initiator of this request is a secure context. | |
| 194 bool initiated_in_secure_context = false; | |
| 195 | |
| 196 // The response should be downloaded and stored in the network cache, but not | |
| 197 // sent back to the renderer. | |
| 198 bool download_to_network_cache_only = false; | |
| 199 }; | |
| 200 | |
| 201 } // namespace content | |
| 202 | |
| 203 #endif // CONTENT_COMMON_RESOURCE_REQUEST_H_ | |
| OLD | NEW |