blob: 2ff91fbf731c5d7eac4bd3a304131115ebb2d436 [file] [log] [blame]
Avi Drissman4e1b7bc32022-09-15 14:03:501// Copyright 2014 The Chromium Authors
danakjc492bf82020-09-09 20:02:442// 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_RENDERER_HOST_NAVIGATION_REQUEST_INFO_H_
6#define CONTENT_BROWSER_RENDERER_HOST_NAVIGATION_REQUEST_INFO_H_
7
Arthur Sonzognic686e8f2024-01-11 08:36:378#include <optional>
9
danakjc492bf82020-09-09 20:02:4410#include "base/unguessable_token.h"
11#include "content/common/content_export.h"
Avi Drissmanbd153642024-09-03 18:58:0512#include "content/public/browser/frame_tree_node_id.h"
Hiroshige Hayashizaki6e9a1892023-04-17 06:47:3813#include "content/public/browser/global_routing_id.h"
Jeremy Roman04ad4e3f2021-12-22 18:54:5414#include "content/public/browser/weak_document_ptr.h"
danakjc492bf82020-09-09 20:02:4415#include "content/public/common/referrer.h"
16#include "net/base/isolation_info.h"
Tsuyoshi Horo17846bf2025-02-20 23:28:1317#include "net/filter/source_stream_type.h"
danakjc492bf82020-09-09 20:02:4418#include "net/http/http_request_headers.h"
19#include "services/network/public/cpp/shared_url_loader_factory.h"
Titouan Rigoudy97d9fd62020-09-28 16:16:4220#include "services/network/public/mojom/client_security_state.mojom-forward.h"
Hiroshige Hayashizaki2df45292023-10-10 22:59:0321#include "third_party/blink/public/common/tokens/tokens.h"
Minggang Wangb9f3fa92021-07-01 15:30:3122#include "third_party/blink/public/mojom/navigation/navigation_params.mojom-forward.h"
danakjc492bf82020-09-09 20:02:4423#include "url/origin.h"
24
25namespace content {
26
Hiroshige Hayashizaki6a2bc752023-10-31 19:08:1127class PrefetchServingPageMetricsContainer;
28
danakjc492bf82020-09-09 20:02:4429// A struct to hold the parameters needed to start a navigation request in
30// ResourceDispatcherHost. It is initialized on the UI thread, and then passed
31// to the IO thread by a NavigationRequest object.
32struct CONTENT_EXPORT NavigationRequestInfo {
Titouan Rigoudy97d9fd62020-09-28 16:16:4233 NavigationRequestInfo(
Minggang Wangb9f3fa92021-07-01 15:30:3134 blink::mojom::CommonNavigationParamsPtr common_params,
35 blink::mojom::BeginNavigationParamsPtr begin_params,
Arthur Sonzogni038f0de2021-10-07 13:51:3436 network::mojom::WebSandboxFlags sandbox_flags,
Titouan Rigoudy97d9fd62020-09-28 16:16:4237 const net::IsolationInfo& isolation_info,
Miyoung Shinff5aec92022-03-08 08:51:5038 bool is_primary_main_frame,
David Bokan98aabfe92022-04-14 02:10:1239 bool is_outermost_main_frame,
Titouan Rigoudy97d9fd62020-09-28 16:16:4240 bool is_main_frame,
Titouan Rigoudy97d9fd62020-09-28 16:16:4241 bool are_ancestors_secure,
Avi Drissmanbd153642024-09-03 18:58:0542 FrameTreeNodeId frame_tree_node_id,
Titouan Rigoudy97d9fd62020-09-28 16:16:4243 bool report_raw_headers,
Titouan Rigoudy97d9fd62020-09-28 16:16:4244 bool upgrade_if_insecure,
45 std::unique_ptr<network::PendingSharedURLLoaderFactory>
46 blob_url_loader_factory,
47 const base::UnguessableToken& devtools_navigation_token,
48 const base::UnguessableToken& devtools_frame_token,
Titouan Rigoudy97d9fd62020-09-28 16:16:4249 net::HttpRequestHeaders cors_exempt_headers,
Alex Rudenko0e632e472021-03-24 09:57:4050 network::mojom::ClientSecurityStatePtr client_security_state,
Tsuyoshi Horo17846bf2025-02-20 23:28:1351 const std::optional<std::vector<net::SourceStreamType>>&
Daniel Hosseiniane58ff352021-10-01 05:13:4752 devtools_accepted_stream_types,
Jeremy Roman04ad4e3f2021-12-22 18:54:5453 bool is_pdf,
Hiroshige Hayashizaki2df45292023-10-10 22:59:0354 int initiator_process_id,
Arthur Sonzognic686e8f2024-01-11 08:36:3755 std::optional<blink::DocumentToken> initiator_document_token,
Hiroshige Hayashizaki6e9a1892023-04-17 06:47:3856 const GlobalRenderFrameHostId& previous_render_frame_host_id,
Hiroshige Hayashizaki6a2bc752023-10-31 19:08:1157 base::WeakPtr<PrefetchServingPageMetricsContainer>
58 prefetch_serving_page_metrics_container,
Max Curran7c0fc83d2023-06-07 22:59:2859 bool allow_cookies_from_browser,
Camillia Smith Barnes6d2966c82023-08-23 21:16:1860 int64_t navigation_id,
John Delaney4cf7d6ea2023-11-09 17:29:5661 bool shared_storage_writable,
Mustafa Emre Acer1001b3d2024-07-09 23:10:4362 bool is_ad_tagged,
63 bool force_no_https_upgrade);
danakjc492bf82020-09-09 20:02:4464 NavigationRequestInfo(const NavigationRequestInfo& other) = delete;
65 ~NavigationRequestInfo();
66
Minggang Wangb9f3fa92021-07-01 15:30:3167 blink::mojom::CommonNavigationParamsPtr common_params;
68 blink::mojom::BeginNavigationParamsPtr begin_params;
danakjc492bf82020-09-09 20:02:4469
Arthur Sonzogni038f0de2021-10-07 13:51:3470 // Sandbox flags inherited from the frame where this navigation occurs. In
71 // particular, this does not include:
72 // - Sandbox flags inherited from the creator via the PolicyContainer.
73 // - Sandbox flags forced for MHTML documents.
74 // - Sandbox flags from the future response via CSP.
75 // It is used by the ExternalProtocolHandler to ensure sandboxed iframe won't
76 // navigate the user toward a different application, which can be seen as a
77 // main frame navigation somehow.
78 const network::mojom::WebSandboxFlags sandbox_flags;
79
danakjc492bf82020-09-09 20:02:4480 // Contains information used to prevent sharing information from a navigation
81 // request across first party contexts. In particular, tracks the
82 // SiteForCookies, which controls what site's SameSite cookies may be set,
Brianna Goldsteind22b0642022-10-11 16:30:5083 // NetworkAnonymizationKey, which is used to restrict sharing of network
danakjc492bf82020-09-09 20:02:4484 // resources, and how to update them across redirects, which is different for
85 // main frames and subresources.
86 const net::IsolationInfo isolation_info;
87
David Bokan98aabfe92022-04-14 02:10:1288 // Whether this navigation is for the primary main frame of the web contents.
89 // That is, the one that the user can see and interact with (as opposed to,
90 // say, a prerendering main frame).
Miyoung Shinff5aec92022-03-08 08:51:5091 const bool is_primary_main_frame;
92
David Bokan98aabfe92022-04-14 02:10:1293 // Whether this navigation is for an outermost main frame. That is, a main
94 // frame that isn't embedded in another frame tree. A prerendering page will
95 // have an outermost main frame whereas a fenced frame will have an embedded
96 // main frame. A primary main frame is always outermost.
97 const bool is_outermost_main_frame;
98
99 // Whether this navigation is for a main frame; one that is the root of its
Adithya Srinivasan39c81912024-07-11 20:44:21100 // own frame tree. This can include embedded frame trees such as FencedFrames.
101 // Both `is_primary_main_frame` and `is_outermost_main_frame` imply
102 // `is_main_frame`, however, `is_main_frame` does not imply either primary or
103 // outermost.
danakjc492bf82020-09-09 20:02:44104 const bool is_main_frame;
danakjc492bf82020-09-09 20:02:44105
106 // Whether all ancestor frames of the frame that is navigating have a secure
107 // origin. True for main frames.
108 const bool are_ancestors_secure;
109
Avi Drissmanbd153642024-09-03 18:58:05110 const FrameTreeNodeId frame_tree_node_id;
danakjc492bf82020-09-09 20:02:44111
danakjc492bf82020-09-09 20:02:44112 const bool report_raw_headers;
113
danakjc492bf82020-09-09 20:02:44114 // If set to true, any HTTP redirects of this request will be upgraded to
115 // HTTPS. This only applies for subframe navigations.
116 const bool upgrade_if_insecure;
117
118 // URLLoaderFactory to facilitate loading blob URLs.
119 std::unique_ptr<network::PendingSharedURLLoaderFactory>
120 blob_url_loader_factory;
121
122 const base::UnguessableToken devtools_navigation_token;
123
124 const base::UnguessableToken devtools_frame_token;
125
danakjc492bf82020-09-09 20:02:44126 const net::HttpRequestHeaders cors_exempt_headers;
Titouan Rigoudy97d9fd62020-09-28 16:16:42127
128 // Specifies the security state applying to the navigation. For iframes, this
129 // is the security state of their parent. Nullptr otherwise.
Titouan Rigoudye10716b2020-09-29 13:29:55130 //
Alison Gale47d1537d2024-04-19 21:31:46131 // TODO(crbug.com/40149351): Set this for top-level navigation requests
Titouan Rigoudye10716b2020-09-29 13:29:55132 // too once the UX story is sorted out.
Titouan Rigoudy97d9fd62020-09-28 16:16:42133 const network::mojom::ClientSecurityStatePtr client_security_state;
Alex Rudenko0e632e472021-03-24 09:57:40134
135 // If not null, the network service will not advertise any stream types
136 // (via Accept-Encoding) that are not listed. Also, it will not attempt
137 // decoding any non-listed stream types.
Tsuyoshi Horo17846bf2025-02-20 23:28:13138 std::optional<std::vector<net::SourceStreamType>>
Alex Rudenko0e632e472021-03-24 09:57:40139 devtools_accepted_stream_types;
Daniel Hosseiniane58ff352021-10-01 05:13:47140
141 // Indicates that this navigation is for PDF content in a renderer.
142 const bool is_pdf;
Jeremy Roman04ad4e3f2021-12-22 18:54:54143
Hiroshige Hayashizaki2df45292023-10-10 22:59:03144 // The initiator document's token and its process ID.
145 const int initiator_process_id;
Arthur Sonzognic686e8f2024-01-11 08:36:37146 const std::optional<blink::DocumentToken> initiator_document_token;
Igor Ruvinov0ea2ebb2022-12-01 16:33:06147
Hiroshige Hayashizaki6e9a1892023-04-17 06:47:38148 // The previous document's RenderFrameHostId, used for speculation rules
149 // prefetch.
150 // This corresponds to `NavigationRequest::GetPreviousRenderFrameHostId()`.
151 const GlobalRenderFrameHostId previous_render_frame_host_id;
152
Hiroshige Hayashizaki6a2bc752023-10-31 19:08:11153 // For per-navigation metrics of speculation rules prefetch.
154 base::WeakPtr<PrefetchServingPageMetricsContainer>
155 prefetch_serving_page_metrics_container;
156
Igor Ruvinov0ea2ebb2022-12-01 16:33:06157 // Whether a Cookie header added to this request should not be overwritten by
158 // the network service.
159 const bool allow_cookies_from_browser;
Max Curran7c0fc83d2023-06-07 22:59:28160
161 // Unique id that identifies the navigation.
162 const int64_t navigation_id;
Camillia Smith Barnes6d2966c82023-08-23 21:16:18163
164 // Whether or not the request is eligible to write to shared storage from
165 // response headers. See
166 // https://github.com/WICG/shared-storage#from-response-headers.
Camillia Smith Barnes3cad1ba2023-10-30 20:10:16167 bool shared_storage_writable_eligible;
John Delaney4cf7d6ea2023-11-09 17:29:56168
169 // Whether the embedder indicated this navigation is being used for
170 // advertising purposes.
171 bool is_ad_tagged;
Mustafa Emre Acer1001b3d2024-07-09 23:10:43172
173 // If true, the navigation will not be upgraded to HTTPS.
174 bool force_no_https_upgrade;
danakjc492bf82020-09-09 20:02:44175};
176
177} // namespace content
178
179#endif // CONTENT_BROWSER_RENDERER_HOST_NAVIGATION_REQUEST_INFO_H_